Skip to content

Commit 87a05fb

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 87a05fb

File tree

4 files changed

+355
-863
lines changed

4 files changed

+355
-863
lines changed

store/random_names.go

Lines changed: 349 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,349 @@
1+
package store
2+
3+
var adjectives = []string{
4+
"able",
5+
"alert",
6+
"basic",
7+
"blank",
8+
"bold",
9+
"brief",
10+
"bright",
11+
"brisk",
12+
"calm",
13+
"chill",
14+
"clean",
15+
"clear",
16+
"clever",
17+
"close",
18+
"cool",
19+
"crisp",
20+
"curious",
21+
"damp",
22+
"dark",
23+
"deep",
24+
"dry",
25+
"eager",
26+
"early",
27+
"empty",
28+
"even",
29+
"faint",
30+
"fair",
31+
"fast",
32+
"fine",
33+
"firm",
34+
"flat",
35+
"fresh",
36+
"gentle",
37+
"good",
38+
"grand",
39+
"great",
40+
"green",
41+
"hard",
42+
"high",
43+
"honest",
44+
"hot",
45+
"just",
46+
"keen",
47+
"kind",
48+
"large",
49+
"late",
50+
"lazy",
51+
"light",
52+
"long",
53+
"low",
54+
"lucky",
55+
"main",
56+
"major",
57+
"mild",
58+
"minor",
59+
"modern",
60+
"narrow",
61+
"neat",
62+
"new",
63+
"nice",
64+
"odd",
65+
"open",
66+
"plain",
67+
"prime",
68+
"proud",
69+
"pure",
70+
"quick",
71+
"quiet",
72+
"rapid",
73+
"rare",
74+
"raw",
75+
"ready",
76+
"rich",
77+
"right",
78+
"rough",
79+
"round",
80+
"safe",
81+
"sharp",
82+
"short",
83+
"shy",
84+
"simple",
85+
"slim",
86+
"slow",
87+
"smart",
88+
"smooth",
89+
"soft",
90+
"solid",
91+
"sound",
92+
"square",
93+
"stable",
94+
"steep",
95+
"still",
96+
"straight",
97+
"strong",
98+
"sure",
99+
"sweet",
100+
"tall",
101+
"thick",
102+
"tidy",
103+
"tight",
104+
"tiny",
105+
"true",
106+
"vast",
107+
"warm",
108+
"weak",
109+
"wide",
110+
"wild",
111+
"wise",
112+
"young",
113+
"zesty",
114+
}
115+
116+
var nouns = []string{
117+
"arch",
118+
"atom",
119+
"aura",
120+
"badge",
121+
"band",
122+
"bank",
123+
"bar",
124+
"base",
125+
"beacon",
126+
"beam",
127+
"bell",
128+
"berry",
129+
"bin",
130+
"blade",
131+
"blaze",
132+
"block",
133+
"bloom",
134+
"bluff",
135+
"bolt",
136+
"branch",
137+
"breeze",
138+
"brick",
139+
"bridge",
140+
"brook",
141+
"brush",
142+
"bud",
143+
"bulb",
144+
"burst",
145+
"button",
146+
"byte",
147+
"cabin",
148+
"cable",
149+
"camp",
150+
"carve",
151+
"catch",
152+
"cell",
153+
"chain",
154+
"chalk",
155+
"chime",
156+
"chip",
157+
"clamp",
158+
"cliff",
159+
"clip",
160+
"cloud",
161+
"coil",
162+
"core",
163+
"cradle",
164+
"craft",
165+
"crash",
166+
"crest",
167+
"curve",
168+
"dash",
169+
"dawn",
170+
"dial",
171+
"disk",
172+
"dock",
173+
"dome",
174+
"drift",
175+
"drop",
176+
"dust",
177+
"echo",
178+
"edge",
179+
"ember",
180+
"engine",
181+
"field",
182+
"fire",
183+
"flake",
184+
"flash",
185+
"flick",
186+
"flock",
187+
"flow",
188+
"fog",
189+
"forge",
190+
"frame",
191+
"fuse",
192+
"gap",
193+
"gear",
194+
"gem",
195+
"glade",
196+
"gleam",
197+
"glow",
198+
"grain",
199+
"grid",
200+
"groove",
201+
"grove",
202+
"guard",
203+
"gust",
204+
"halo",
205+
"harbor",
206+
"haze",
207+
"hill",
208+
"hinge",
209+
"hollow",
210+
"hook",
211+
"ice",
212+
"isle",
213+
"joint",
214+
"key",
215+
"knob",
216+
"knot",
217+
"lake",
218+
"leaf",
219+
"lever",
220+
"light",
221+
"line",
222+
"link",
223+
"lock",
224+
"loop",
225+
"lug",
226+
"map",
227+
"maze",
228+
"meadow",
229+
"mesh",
230+
"mist",
231+
"moon",
232+
"moss",
233+
"motor",
234+
"mount",
235+
"nail",
236+
"nest",
237+
"node",
238+
"note",
239+
"ocean",
240+
"orb",
241+
"pack",
242+
"pad",
243+
"path",
244+
"peak",
245+
"pebble",
246+
"peg",
247+
"petal",
248+
"pin",
249+
"pine",
250+
"plane",
251+
"plate",
252+
"plug",
253+
"plume",
254+
"pond",
255+
"pool",
256+
"port",
257+
"press",
258+
"pulse",
259+
"quest",
260+
"rack",
261+
"rail",
262+
"ramp",
263+
"raven",
264+
"reef",
265+
"ridge",
266+
"ring",
267+
"rise",
268+
"river",
269+
"rivet",
270+
"rock",
271+
"rod",
272+
"roll",
273+
"root",
274+
"rope",
275+
"sail",
276+
"scale",
277+
"scope",
278+
"seal",
279+
"shade",
280+
"shaft",
281+
"shard",
282+
"sheet",
283+
"shelf",
284+
"shell",
285+
"shine",
286+
"ship",
287+
"shock",
288+
"shore",
289+
"signal",
290+
"skid",
291+
"sky",
292+
"slate",
293+
"slot",
294+
"snap",
295+
"snow",
296+
"socket",
297+
"song",
298+
"spark",
299+
"spike",
300+
"spool",
301+
"spore",
302+
"spring",
303+
"spur",
304+
"stack",
305+
"stalk",
306+
"star",
307+
"stem",
308+
"stone",
309+
"storm",
310+
"strap",
311+
"stream",
312+
"stripe",
313+
"stud",
314+
"sun",
315+
"surf",
316+
"swirl",
317+
"tab",
318+
"tag",
319+
"tail",
320+
"tape",
321+
"tide",
322+
"tile",
323+
"track",
324+
"trail",
325+
"tray",
326+
"tree",
327+
"trunk",
328+
"tube",
329+
"vale",
330+
"valve",
331+
"vault",
332+
"veil",
333+
"vent",
334+
"vessel",
335+
"vibe",
336+
"void",
337+
"wake",
338+
"wave",
339+
"web",
340+
"wedge",
341+
"wheel",
342+
"whirl",
343+
"wind",
344+
"wing",
345+
"wire",
346+
"wood",
347+
"yard",
348+
"zone",
349+
}

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)