From 8acab3cc4916d939c13bd2bafb948947d6f8a567 Mon Sep 17 00:00:00 2001 From: Maciej Szulik Date: Thu, 15 Apr 2021 15:36:47 +0200 Subject: [PATCH] Limit image spec's hash length To be able to properly limit the length of hash string we should limit after encoding to base, not before. --- test/utils/image/manifest.go | 2 +- test/utils/image/manifest_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/utils/image/manifest.go b/test/utils/image/manifest.go index ae9aa951b12..827396e422d 100644 --- a/test/utils/image/manifest.go +++ b/test/utils/image/manifest.go @@ -306,7 +306,7 @@ func getRepositoryMappedConfig(index int, config Config, repo string) Config { h := sha256.New() h.Write([]byte(pullSpec)) - hash := base64.RawURLEncoding.EncodeToString(h.Sum(nil)[:16]) + hash := base64.RawURLEncoding.EncodeToString(h.Sum(nil))[:16] shortName := reCharSafe.ReplaceAllLiteralString(pullSpec, "-") shortName = reDashes.ReplaceAllLiteralString(shortName, "-") diff --git a/test/utils/image/manifest_test.go b/test/utils/image/manifest_test.go index b02560806c3..80484b649f6 100644 --- a/test/utils/image/manifest_test.go +++ b/test/utils/image/manifest_test.go @@ -149,7 +149,7 @@ func TestGetMappedImageConfigs(t *testing.T) { actual[source.GetE2EImage()] = mapping.GetE2EImage() } expected := map[string]string{ - "docker.io/source/repo:1.0": "quay.io/repo/for-test:e2e-0-docker-io-source-repo-1-0-72R4aXm7YnxQ4_ekf1DrFA", + "docker.io/source/repo:1.0": "quay.io/repo/for-test:e2e-0-docker-io-source-repo-1-0-72R4aXm7YnxQ4_ek", } if !reflect.DeepEqual(expected, actual) { t.Fatal(diff.ObjectReflectDiff(expected, actual))