Skip to content

Commit 358ec12

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 4c791dc commit 358ec12

File tree

4 files changed

+57
-863
lines changed

4 files changed

+57
-863
lines changed

store/random_names.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package store
2+
3+
var adjectives = []string{
4+
"able", "alert", "basic", "bold", "brisk", "bright", "brisk", "calm",
5+
"clean", "clear", "clever", "close", "cool", "crisp", "curious", "damp",
6+
"dark", "deep", "dry", "eager", "early", "empty", "even", "fair",
7+
"fast", "fine", "firm", "flat", "fresh", "gentle", "good", "grand",
8+
"great", "green", "hard", "high", "honest", "hot", "just", "keen",
9+
"kind", "large", "late", "lazy", "light", "long", "low", "lucky",
10+
"main", "major", "mild", "minor", "modern", "narrow", "neat", "new",
11+
"nice", "odd", "open", "plain", "prime", "proud", "pure", "quick",
12+
"quiet", "rapid", "rare", "raw", "ready", "rich", "right", "rough",
13+
"round", "safe", "sharp", "short", "shy", "simple", "slim", "slow",
14+
"smart", "smooth", "soft", "solid", "sound", "square", "stable", "steep",
15+
"still", "straight", "strong", "sure", "sweet", "tall", "thick", "tidy",
16+
"tight", "tiny", "true", "vast", "warm", "weak", "wide", "wild",
17+
"wise", "young", "zesty", "blank", "brief", "chill", "dry", "faint",
18+
}
19+
20+
var nouns = []string{
21+
"arch", "atom", "aura", "band", "bank", "beam", "bell", "berry",
22+
"blade", "block", "bloom", "bluff", "bolt", "breeze", "bridge", "brook",
23+
"brush", "burst", "cabin", "cable", "camp", "cell", "chalk", "chime",
24+
"cloud", "cliff", "core", "craft", "crest", "curve", "dawn", "disk",
25+
"dome", "drift", "drop", "dust", "edge", "ember", "field", "fire",
26+
"flake", "flash", "flock", "flow", "fog", "forge", "frame", "gap",
27+
"gem", "glade", "gleam", "glow", "grain", "grove", "gust", "halo",
28+
"harbor", "haze", "hill", "hollow", "ice", "isle", "knot", "lake",
29+
"leaf", "light", "line", "link", "loop", "map", "maze", "meadow",
30+
"mist", "moon", "moss", "mount", "nest", "node", "note", "ocean",
31+
"orb", "pack", "path", "peak", "pebble", "petal", "pine", "plane",
32+
"plate", "plume", "pond", "pool", "pulse", "quest", "raven", "reef",
33+
"ridge", "ring", "rise", "river", "rock", "root", "sail", "scale",
34+
"scope", "shade", "shard", "shell", "shine", "ship", "shock", "shore",
35+
"signal", "sky", "slate", "snow", "song", "spark", "spike", "spore",
36+
"spring", "stack", "star", "stem", "stone", "storm", "stream", "stripe",
37+
"sun", "surf", "swirl", "tail", "tide", "track", "trail", "tree",
38+
"trunk", "vale", "vault", "veil", "vibe", "void", "wake", "wave",
39+
"web", "wheel", "whirl", "wind", "wing", "wire", "wood", "yard",
40+
"zone", "badge", "bar", "base", "beacon", "bin", "blade", "blaze",
41+
"branch", "brick", "bud", "bulb", "button", "byte", "carve", "catch",
42+
"chain", "chip", "clamp", "clip", "coil", "cradle", "crash", "crest",
43+
"dash", "dial", "dock", "echo", "engine", "flick", "frame", "fuse",
44+
"gear", "grid", "groove", "guard", "hinge", "hook", "joint", "key",
45+
"knob", "lever", "lock", "loop", "lug", "mesh", "motor", "nail",
46+
"pad", "peg", "pin", "plate", "plug", "port", "press", "rack",
47+
"rail", "ramp", "rivet", "rod", "roll", "rope", "seal", "shaft",
48+
"sheet", "shelf", "skid", "slot", "snap", "socket", "spark", "spool",
49+
"spur", "stack", "stalk", "strap", "stud", "tab", "tag", "tape",
50+
"tile", "track", "tray", "tube", "valve", "vent", "vessel", "wedge",
51+
}

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)