mirror of
https://github.com/containers/podman.git
synced 2026-03-13 08:01:19 +08:00
Merge pull request #28223 from jankaluza/namesgenerator
libpod: include names-generator.go
This commit is contained in:
2
go.mod
2
go.mod
@@ -22,7 +22,6 @@ require (
|
||||
github.com/cyphar/filepath-securejoin v0.6.1
|
||||
github.com/digitalocean/go-qemu v0.0.0-20250212194115-ee9b0668d242
|
||||
github.com/docker/distribution v2.8.3+incompatible
|
||||
github.com/docker/docker v28.5.2+incompatible
|
||||
github.com/docker/go-connections v0.6.0
|
||||
github.com/docker/go-plugins-helpers v0.0.0-20240701071450-45e2431495c8
|
||||
github.com/docker/go-units v0.5.0
|
||||
@@ -110,6 +109,7 @@ require (
|
||||
github.com/digitalocean/go-libvirt v0.0.0-20220804181439-8648fbde413e // indirect
|
||||
github.com/disiqueira/gotree/v3 v3.0.2 // indirect
|
||||
github.com/distribution/reference v0.6.0 // indirect
|
||||
github.com/docker/docker v28.5.2+incompatible // indirect
|
||||
github.com/docker/docker-credential-helpers v0.9.5 // indirect
|
||||
github.com/ebitengine/purego v0.9.1 // indirect
|
||||
github.com/felixge/httpsnoop v1.0.4 // indirect
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
// This file has been copied from
|
||||
// https://github.com/moby/moby/tree/a52171f5eeb6e553e7c4744abf6b722962b2aca4/internal/namesgenerator.
|
||||
// It is licensed under the Apache License 2.0.
|
||||
// See https://github.com/moby/moby/blob/a52171f5eeb6e553e7c4744abf6b722962b2aca4/LICENSE.
|
||||
//
|
||||
// Package namesgenerator generates random names.
|
||||
//
|
||||
// This package is officially "frozen" - no new additions will be accepted.
|
||||
@@ -263,7 +268,7 @@ var (
|
||||
// David Lee Chaum - American computer scientist and cryptographer. Known for his seminal contributions in the field of anonymous communication. https://en.wikipedia.org/wiki/David_Chaum
|
||||
"chaum",
|
||||
|
||||
// Pafnuty Chebyshev - Russian mathematician. He is known fo his works on probability, statistics, mechanics, analytical geometry and number theory https://en.wikipedia.org/wiki/Pafnuty_Chebyshev
|
||||
// Pafnuty Chebyshev - Russian mathematician. He is known for his works on probability, statistics, mechanics, analytical geometry and number theory https://en.wikipedia.org/wiki/Pafnuty_Chebyshev
|
||||
"chebyshev",
|
||||
|
||||
// Joan Clarke - Bletchley Park code breaker during the Second World War who pioneered techniques that remained top secret for decades. Also an accomplished numismatist https://en.wikipedia.org/wiki/Joan_Clarke
|
||||
@@ -793,7 +798,7 @@ var (
|
||||
// Dorothy Vaughan was a NASA mathematician and computer programmer on the SCOUT launch vehicle program that put America's first satellites into space - https://en.wikipedia.org/wiki/Dorothy_Vaughan
|
||||
"vaughan",
|
||||
|
||||
// Cédric Villani - French mathematician, won Fields Medal, Fermat Prize and Poincaré Price for his work in differential geometry and statistical mechanics. https://en.wikipedia.org/wiki/C%C3%A9dric_Villani
|
||||
// Cédric Villani - French mathematician, won Fields Medal, Fermat Prize and Poincaré Prize for his work in differential geometry and statistical mechanics. https://en.wikipedia.org/wiki/C%C3%A9dric_Villani
|
||||
"villani",
|
||||
|
||||
// Sir Mokshagundam Visvesvaraya - is a notable Indian engineer. He is a recipient of the Indian Republic's highest honour, the Bharat Ratna, in 1955. On his birthday, 15 September is celebrated as Engineer's Day in India in his memory - https://en.wikipedia.org/wiki/Visvesvaraya
|
||||
40
libpod/namesgenerator/names-generator_test.go
Normal file
40
libpod/namesgenerator/names-generator_test.go
Normal file
@@ -0,0 +1,40 @@
|
||||
// This file has been copied from
|
||||
// https://github.com/moby/moby/tree/a52171f5eeb6e553e7c4744abf6b722962b2aca4/internal/namesgenerator.
|
||||
// It is licensed under the Apache License 2.0.
|
||||
// See https://github.com/moby/moby/blob/a52171f5eeb6e553e7c4744abf6b722962b2aca4/LICENSE.
|
||||
|
||||
package namesgenerator
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestNameFormat(t *testing.T) {
|
||||
name := GetRandomName(0)
|
||||
if !strings.Contains(name, "_") {
|
||||
t.Fatalf("Generated name does not contain an underscore")
|
||||
}
|
||||
if strings.ContainsAny(name, "0123456789") {
|
||||
t.Fatalf("Generated name contains numbers!")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNameRetries(t *testing.T) {
|
||||
name := GetRandomName(1)
|
||||
if !strings.Contains(name, "_") {
|
||||
t.Fatalf("Generated name does not contain an underscore")
|
||||
}
|
||||
if !strings.ContainsAny(name, "0123456789") {
|
||||
t.Fatalf("Generated name doesn't contain a number")
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkGetRandomName(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
var out string
|
||||
for b.Loop() {
|
||||
out = GetRandomName(5)
|
||||
}
|
||||
b.Log("Last result:", out)
|
||||
}
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
"github.com/containers/podman/v6/libpod/define"
|
||||
"github.com/containers/podman/v6/libpod/events"
|
||||
"github.com/containers/podman/v6/libpod/lock"
|
||||
"github.com/containers/podman/v6/libpod/namesgenerator"
|
||||
"github.com/containers/podman/v6/libpod/plugin"
|
||||
"github.com/containers/podman/v6/libpod/shutdown"
|
||||
"github.com/containers/podman/v6/pkg/domain/entities"
|
||||
@@ -26,7 +27,6 @@ import (
|
||||
"github.com/containers/podman/v6/pkg/rootless"
|
||||
"github.com/containers/podman/v6/pkg/systemd"
|
||||
"github.com/containers/podman/v6/pkg/util"
|
||||
"github.com/docker/docker/pkg/namesgenerator"
|
||||
"github.com/hashicorp/go-multierror"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
spec "github.com/opencontainers/runtime-spec/specs-go"
|
||||
|
||||
1
vendor/modules.txt
vendored
1
vendor/modules.txt
vendored
@@ -251,7 +251,6 @@ github.com/docker/docker/api/types/swarm/runtime
|
||||
github.com/docker/docker/api/types/versions
|
||||
github.com/docker/docker/pkg/homedir
|
||||
github.com/docker/docker/pkg/jsonmessage
|
||||
github.com/docker/docker/pkg/namesgenerator
|
||||
github.com/docker/docker/pkg/stdcopy
|
||||
# github.com/docker/docker-credential-helpers v0.9.5
|
||||
## explicit; go 1.21
|
||||
|
||||
Reference in New Issue
Block a user