Skip to content

Commit 886a61b

Browse files
committed
store: remove uses of docker namesgenerator
It will not be part of the api or client modules, so replace it with a local implementation, that's not using names of hackers/scientists, so that we don't have to carry the debates around those choices here. Thanks to ChatGPT for generating some lists (I haven't fully checked them). Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 8f57074 commit 886a61b

File tree

4 files changed

+264
-863
lines changed

4 files changed

+264
-863
lines changed

store/random_names.go

Lines changed: 258 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,258 @@
1+
package store
2+
3+
var adjectives = []string{
4+
"able",
5+
"alert",
6+
"basic",
7+
"bold",
8+
"bouncy",
9+
"breezy",
10+
"brief",
11+
"bright",
12+
"brisk",
13+
"calm",
14+
"chill",
15+
"clean",
16+
"clear",
17+
"clever",
18+
"cool",
19+
"crisp",
20+
"curious",
21+
"eager",
22+
"early",
23+
"even",
24+
"fair",
25+
"fast",
26+
"fine",
27+
"firm",
28+
"flat",
29+
"fresh",
30+
"gentle",
31+
"glossy",
32+
"good",
33+
"grand",
34+
"great",
35+
"green",
36+
"happy",
37+
"hearty",
38+
"high",
39+
"honest",
40+
"hot",
41+
"just",
42+
"keen",
43+
"kind",
44+
"large",
45+
"light",
46+
"long",
47+
"lucky",
48+
"major",
49+
"merry",
50+
"modern",
51+
"neat",
52+
"new",
53+
"nice",
54+
"nifty",
55+
"open",
56+
"peppy",
57+
"perky",
58+
"plain",
59+
"prime",
60+
"proud",
61+
"pure",
62+
"quick",
63+
"quiet",
64+
"rapid",
65+
"rare",
66+
"ready",
67+
"rich",
68+
"right",
69+
"round",
70+
"safe",
71+
"sharp",
72+
"short",
73+
"shy",
74+
"simple",
75+
"slim",
76+
"smart",
77+
"smooth",
78+
"snappy",
79+
"snug",
80+
"soft",
81+
"solid",
82+
"sound",
83+
"spunky",
84+
"square",
85+
"stable",
86+
"steep",
87+
"still",
88+
"straight",
89+
"strong",
90+
"sunny",
91+
"sure",
92+
"sweet",
93+
"tall",
94+
"thick",
95+
"tidy",
96+
"tight",
97+
"tiny",
98+
"vivid",
99+
"warm",
100+
"wide",
101+
"wild",
102+
"wise",
103+
"young",
104+
"zesty",
105+
}
106+
107+
var nouns = []string{
108+
"aura",
109+
"badge",
110+
"band",
111+
"bar",
112+
"base",
113+
"beacon",
114+
"beam",
115+
"bell",
116+
"berry",
117+
"bloom",
118+
"bluff",
119+
"bolt",
120+
"branch",
121+
"breeze",
122+
"brick",
123+
"bridge",
124+
"brook",
125+
"brush",
126+
"bud",
127+
"bulb",
128+
"burst",
129+
"button",
130+
"cabin",
131+
"camp",
132+
"carve",
133+
"catch",
134+
"chalk",
135+
"chime",
136+
"cliff",
137+
"cloud",
138+
"coil",
139+
"cradle",
140+
"craft",
141+
"crest",
142+
"curve",
143+
"dash",
144+
"dawn",
145+
"dome",
146+
"drift",
147+
"drop",
148+
"dust",
149+
"edge",
150+
"ember",
151+
"field",
152+
"fire",
153+
"flake",
154+
"flash",
155+
"flick",
156+
"flock",
157+
"fog",
158+
"forge",
159+
"frame",
160+
"gem",
161+
"glade",
162+
"gleam",
163+
"glow",
164+
"grain",
165+
"groove",
166+
"grove",
167+
"guard",
168+
"gust",
169+
"halo",
170+
"harbor",
171+
"haze",
172+
"hill",
173+
"hollow",
174+
"hook",
175+
"ice",
176+
"isle",
177+
"knot",
178+
"lake",
179+
"leaf",
180+
"lever",
181+
"light",
182+
"maze",
183+
"meadow",
184+
"mist",
185+
"moon",
186+
"moss",
187+
"nest",
188+
"note",
189+
"ocean",
190+
"orb",
191+
"pack",
192+
"peak",
193+
"pebble",
194+
"peg",
195+
"petal",
196+
"pine",
197+
"plate",
198+
"plume",
199+
"pond",
200+
"pool",
201+
"quest",
202+
"reef",
203+
"ridge",
204+
"ring",
205+
"rise",
206+
"river",
207+
"rock",
208+
"roll",
209+
"rope",
210+
"sail",
211+
"scale",
212+
"seal",
213+
"shade",
214+
"shard",
215+
"shine",
216+
"ship",
217+
"shore",
218+
"skid",
219+
"sky",
220+
"slate",
221+
"snow",
222+
"song",
223+
"spark",
224+
"spike",
225+
"spool",
226+
"spore",
227+
"spring",
228+
"spur",
229+
"stack",
230+
"star",
231+
"stem",
232+
"stone",
233+
"storm",
234+
"strap",
235+
"stripe",
236+
"sun",
237+
"surf",
238+
"swirl",
239+
"tail",
240+
"tide",
241+
"tile",
242+
"trail",
243+
"tree",
244+
"trunk",
245+
"tube",
246+
"vale",
247+
"veil",
248+
"vent",
249+
"vessel",
250+
"vibe",
251+
"wave",
252+
"whirl",
253+
"wind",
254+
"wing",
255+
"wood",
256+
"yard",
257+
"zone",
258+
}

store/util.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package store
22

33
import (
4+
"fmt"
5+
"math/rand/v2"
46
"os"
57
"regexp"
68
"strings"
79

8-
"github.com/docker/docker/pkg/namesgenerator"
910
"github.com/pkg/errors"
1011
)
1112

@@ -40,7 +41,10 @@ func ValidateName(s string) (string, error) {
4041
func GenerateName(txn *Txn) (string, error) {
4142
var name string
4243
for i := range 6 {
43-
name = namesgenerator.GetRandomName(i)
44+
name = adjectives[rand.IntN(len(adjectives))] + "_" + nouns[rand.IntN(len(nouns))] // #nosec G404 -- ignore "Use of weak random number generator"
45+
if i > 0 {
46+
name += fmt.Sprint(rand.IntN(10)) // #nosec G404 -- ignore "Use of weak random number generator"
47+
}
4448
if _, err := txn.NodeGroupByName(name); err != nil {
4549
if !os.IsNotExist(errors.Cause(err)) {
4650
return "", err

0 commit comments

Comments
 (0)