-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug: run bundle-upgrade with long image names
Signed-off-by: Nahshon Unna-Tsameret <[email protected]>
- Loading branch information
Showing
3 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# entries is a list of entries to include in | ||
# release notes and/or the migration guide | ||
entries: | ||
- description: In `run bundle-upgrade`, hash the cache directory name to avoid error of too long file name. | ||
kind: "bugfix" | ||
breaking: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package fbcutil | ||
|
||
import ( | ||
"crypto/sha256" | ||
"fmt" | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("test fbutil", func() { | ||
|
||
emptyListHash := fmt.Sprintf("%x", sha256.New().Sum(nil)) | ||
|
||
Context("test dirNameFromRefs", func() { | ||
DescribeTable("should name the directory with sha256 of the concatenation of the bundle image names", func(refs []string, expectedHash string) { | ||
dirName := dirNameFromRefs(refs) | ||
|
||
Expect(dirName).Should(HaveLen(sha256.Size * 2)) // in hex representation, each byte is two hex digits | ||
Expect(dirName).Should(Equal(expectedHash)) | ||
}, | ||
Entry("long image names", []string{ | ||
"registry.build03.ci.openshift.org/ci/op/dl9pitlh/pipeline@sha256:123d009f7fb9d5b760b3eac831e0f50413d36199816d651b569367642c138ccd", | ||
"registry.build03.ci.openshift.org/ci/op/dl9pitlh/pipeline@sha256:5498f1b841946c8da823fb11c08969efb36119f7867701f2cedac4a2e8f7cefc", | ||
}, "6fe356da2fd4646b823936045b81d6312e9d7597af3b49d12c7f83d5089c2c11"), | ||
Entry("multiple refs", []string{"a/b/c", "d/e/f", "g/h/i/j", "k/l/m/n/o"}, "df22ac3ac9e59ed300f70b9c2fdd7128be064652839a813948ee9fd1a2f36581"), | ||
Entry("single ref", []string{"a/b/c"}, "cbd2be7b96f770a0326948ebd158cf539fab0627e8adbddc97f7a65c6a8ae59a"), | ||
Entry("no refs", []string{}, emptyListHash), | ||
Entry("no refs (nil)", nil, emptyListHash), | ||
) | ||
}) | ||
}) | ||
|
||
func TestRegistry(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "fbutil Suite") | ||
} |