mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 10:51:29 +00:00
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.
This commit is contained in:
parent
74497632f4
commit
8acab3cc49
@ -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, "-")
|
||||
|
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user