Skip to content

Commit 1a116d1

Browse files
Merge pull request #17315 from TomSweeneyRedHat/dev/tsweeney/randomfix_4.2
[v4.2.0-rhel] all: stop using deprecated GenerateNonCryptoID
2 parents e1f0d65 + f19c033 commit 1a116d1

21 files changed

+104
-102
lines changed

libpod/container_exec.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ func (c *Container) ExecCreate(config *ExecConfig) (string, error) {
182182
}
183183

184184
// Generate an ID for our new exec session
185-
sessionID := stringid.GenerateNonCryptoID()
185+
sessionID := stringid.GenerateRandomID()
186186
found := true
187187
// This really ought to be a do-while, but Go doesn't have those...
188188
for found {
@@ -194,7 +194,7 @@ func (c *Container) ExecCreate(config *ExecConfig) (string, error) {
194194
}
195195
}
196196
if found {
197-
sessionID = stringid.GenerateNonCryptoID()
197+
sessionID = stringid.GenerateRandomID()
198198
}
199199
}
200200

libpod/pod_internal.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
func newPod(runtime *Runtime) *Pod {
1717
pod := new(Pod)
1818
pod.config = new(PodConfig)
19-
pod.config.ID = stringid.GenerateNonCryptoID()
19+
pod.config.ID = stringid.GenerateRandomID()
2020
pod.config.Labels = make(map[string]string)
2121
pod.config.CreatedTime = time.Now()
2222
// pod.config.InfraContainer = new(ContainerConfig)

libpod/runtime_ctr.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ func (r *Runtime) initContainerVariables(rSpec *spec.Spec, config *ContainerConf
169169
ctr.state = new(ContainerState)
170170

171171
if config == nil {
172-
ctr.config.ID = stringid.GenerateNonCryptoID()
172+
ctr.config.ID = stringid.GenerateRandomID()
173173
size, err := units.FromHumanSize(r.config.Containers.ShmSize)
174174
if err != nil {
175175
return nil, fmt.Errorf("converting containers.conf ShmSize %s to an int: %w", r.config.Containers.ShmSize, err)
@@ -188,7 +188,7 @@ func (r *Runtime) initContainerVariables(rSpec *spec.Spec, config *ContainerConf
188188
}
189189
// If the ID is empty a new name for the restored container was requested
190190
if ctr.config.ID == "" {
191-
ctr.config.ID = stringid.GenerateNonCryptoID()
191+
ctr.config.ID = stringid.GenerateRandomID()
192192
}
193193
// Reset the log path to point to the default
194194
ctr.config.LogPath = ""
@@ -461,7 +461,7 @@ func (r *Runtime) setupContainer(ctx context.Context, ctr *Container) (_ *Contai
461461
if vol.Name == "" {
462462
// Anonymous volume. We'll need to create it.
463463
// It needs a name first.
464-
vol.Name = stringid.GenerateNonCryptoID()
464+
vol.Name = stringid.GenerateRandomID()
465465
isAnonymous = true
466466
} else {
467467
// Check if it exists already

libpod/runtime_volume_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (r *Runtime) newVolume(noCreatePluginVolume bool, options ...VolumeCreateOp
4242
}
4343

4444
if volume.config.Name == "" {
45-
volume.config.Name = stringid.GenerateNonCryptoID()
45+
volume.config.Name = stringid.GenerateRandomID()
4646
}
4747
if volume.config.Driver == "" {
4848
volume.config.Driver = define.VolumeDriverLocal

test/e2e/common_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ func PodmanTestCreateUtil(tempDir string, remote bool) *PodmanTestIntegration {
306306
// happens. So, use a podman-%s.sock-lock empty file as a marker.
307307
tries := 0
308308
for {
309-
uuid := stringid.GenerateNonCryptoID()
309+
uuid := stringid.GenerateRandomID()
310310
lockPath := fmt.Sprintf("%s-%s.sock-lock", pathPrefix, uuid)
311311
lockFile, err := os.OpenFile(lockPath, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0700)
312312
if err == nil {
@@ -894,7 +894,7 @@ func generateNetworkConfig(p *PodmanTestIntegration) (string, string) {
894894
conf string
895895
)
896896
// generate a random name to prevent conflicts with other tests
897-
name := "net" + stringid.GenerateNonCryptoID()
897+
name := "net" + stringid.GenerateRandomID()
898898
if p.NetworkBackend != Netavark {
899899
path = filepath.Join(p.NetworkConfigDir, fmt.Sprintf("%s.conflist", name))
900900
conf = fmt.Sprintf(`{
@@ -1030,7 +1030,7 @@ func ncz(port int) bool {
10301030
}
10311031

10321032
func createNetworkName(name string) string {
1033-
return name + stringid.GenerateNonCryptoID()[:10]
1033+
return name + stringid.GenerateRandomID()[:10]
10341034
}
10351035

10361036
var IPRegex = `(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}`

test/e2e/create_staticmac_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ var _ = Describe("Podman run with --mac-address flag", func() {
4848
})
4949

5050
It("Podman run --mac-address with custom network", func() {
51-
net := "n1" + stringid.GenerateNonCryptoID()
51+
net := "n1" + stringid.GenerateRandomID()
5252
session := podmanTest.Podman([]string{"network", "create", net})
5353
session.WaitWithDefaultTimeout()
5454
defer podmanTest.removeNetwork(net)

test/e2e/create_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ var _ = Describe("Podman create", func() {
593593
pod.WaitWithDefaultTimeout()
594594
Expect(pod).Should(Exit(0))
595595

596-
netName := "pod" + stringid.GenerateNonCryptoID()
596+
netName := "pod" + stringid.GenerateRandomID()
597597
session := podmanTest.Podman([]string{"network", "create", netName})
598598
session.WaitWithDefaultTimeout()
599599
Expect(session).Should(Exit(0))

test/e2e/diff_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ var _ = Describe("Podman diff", func() {
9393
})
9494

9595
It("podman image diff", func() {
96-
file1 := "/" + stringid.GenerateNonCryptoID()
97-
file2 := "/" + stringid.GenerateNonCryptoID()
98-
file3 := "/" + stringid.GenerateNonCryptoID()
96+
file1 := "/" + stringid.GenerateRandomID()
97+
file2 := "/" + stringid.GenerateRandomID()
98+
file3 := "/" + stringid.GenerateRandomID()
9999

100100
// Create container image with the files
101101
containerfile := fmt.Sprintf(`
@@ -152,8 +152,8 @@ RUN echo test
152152
})
153153

154154
It("podman diff container and image with same name", func() {
155-
imagefile := "/" + stringid.GenerateNonCryptoID()
156-
confile := "/" + stringid.GenerateNonCryptoID()
155+
imagefile := "/" + stringid.GenerateRandomID()
156+
confile := "/" + stringid.GenerateRandomID()
157157

158158
// Create container image with the files
159159
containerfile := fmt.Sprintf(`

test/e2e/events_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@ var _ = Describe("Podman events", func() {
156156
})
157157

158158
It("podman events --until future", func() {
159-
name1 := stringid.GenerateNonCryptoID()
160-
name2 := stringid.GenerateNonCryptoID()
161-
name3 := stringid.GenerateNonCryptoID()
159+
name1 := stringid.GenerateRandomID()
160+
name2 := stringid.GenerateRandomID()
161+
name3 := stringid.GenerateRandomID()
162162
session := podmanTest.Podman([]string{"create", "--name", name1, ALPINE})
163163
session.WaitWithDefaultTimeout()
164164
Expect(session).Should(Exit(0))

test/e2e/logs_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ var _ = Describe("Podman logs", func() {
376376
skipIfJournaldInContainer()
377377

378378
cname := "log-test"
379-
content := stringid.GenerateNonCryptoID()
379+
content := stringid.GenerateRandomID()
380380
// use printf to print no extra newline
381381
logc := podmanTest.Podman([]string{"run", "--log-driver", log, "--name", cname, ALPINE, "printf", content})
382382
logc.WaitWithDefaultTimeout()

0 commit comments

Comments
 (0)