Skip to content

Commit b4c3d6c

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 b4c3d6c

File tree

4 files changed

+266
-863
lines changed

4 files changed

+266
-863
lines changed

store/random_names.go

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

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)