-
Notifications
You must be signed in to change notification settings - Fork 260
adding olm.bundle image/relatedImages pullspec format validation #1905
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -506,6 +506,57 @@ func TestConvertToModel(t *testing.T) { | |
| })}, | ||
| }, | ||
| }, | ||
| { | ||
| name: "Error/BundleImageInvalidPullSpecUnsupportedDigestSsha256", | ||
| assertion: hasErrorContaining("invalid image pull spec"), | ||
| cfg: DeclarativeConfig{ | ||
| Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, | ||
| Channels: []Channel{newTestChannel("foo", "alpha", ChannelEntry{Name: testBundleName("foo", "0.1.0")})}, | ||
| Bundles: []Bundle{newTestBundle("foo", "0.1.0", func(b *Bundle) { | ||
| // Misspelled digest algorithm: ssha256 instead of sha256 (unsupported hash type) | ||
| b.Image = "quay.io/operator-framework/foo-bundle@ssha256:abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234" | ||
| })}, | ||
| }, | ||
| }, | ||
| { | ||
| name: "Error/BundleImageInvalidPullSpecUnsupportedDigestMd5", | ||
| assertion: hasErrorContaining("invalid image pull spec"), | ||
| cfg: DeclarativeConfig{ | ||
| Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, | ||
| Channels: []Channel{newTestChannel("foo", "alpha", ChannelEntry{Name: testBundleName("foo", "0.1.0")})}, | ||
| Bundles: []Bundle{newTestBundle("foo", "0.1.0", func(b *Bundle) { | ||
| b.Image = "quay.io/operator-framework/foo-bundle@md5:abcd1234abcd1234abcd1234abcd1234" | ||
| })}, | ||
| }, | ||
| }, | ||
| { | ||
| name: "Error/BundleRelatedImageInvalidPullSpecSsha256", | ||
| assertion: hasErrorContaining("invalid image pull spec"), | ||
| cfg: DeclarativeConfig{ | ||
| Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, | ||
| Channels: []Channel{newTestChannel("foo", "alpha", ChannelEntry{Name: testBundleName("foo", "0.1.0")})}, | ||
| Bundles: []Bundle{newTestBundle("foo", "0.1.0", func(b *Bundle) { | ||
| b.RelatedImages = []RelatedImage{ | ||
| {Name: "bundle", Image: testBundleImage("foo", "0.1.0")}, | ||
| {Name: "operator", Image: "quay.io/operator-framework/my-operator@ssha256:abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234"}, | ||
| } | ||
| })}, | ||
| }, | ||
| }, | ||
| { | ||
| name: "Success/BundleImageValidSha256Digest", | ||
| assertion: require.NoError, | ||
| cfg: DeclarativeConfig{ | ||
| Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, | ||
| Channels: []Channel{newTestChannel("foo", "alpha", ChannelEntry{Name: testBundleName("foo", "0.1.0")})}, | ||
| Bundles: []Bundle{newTestBundle("foo", "0.1.0", func(b *Bundle) { | ||
| b.Image = "quay.io/operator-framework/foo-bundle@sha256:abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234" | ||
| b.RelatedImages = []RelatedImage{ | ||
| {Name: "bundle", Image: "quay.io/operator-framework/foo-bundle@sha256:abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234"}, | ||
| } | ||
| })}, | ||
| }, | ||
| }, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add here a test to ensure that we still allowing usage of tags
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we allow tags, since we have to pin as digests in catalogs.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OLM supports this upstream—it's not an OLM limitation. What you’re describing is a downstream requirement specific to Red Hat OCP, mainly because of disconnected environment constraints. OLM can work with tags.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 on a test showing that tags work. I think it is also valid to have a pullspec that looks like this: In this case, my understanding is that the tag becomes informational/ignored and the digest is what is used. |
||
| } | ||
|
|
||
| for _, s := range specs { | ||
|
|
@@ -577,3 +628,14 @@ func hasError(expectedError string) require.ErrorAssertionFunc { | |
| t.FailNow() | ||
| } | ||
| } | ||
|
|
||
| // hasErrorContaining returns an ErrorAssertionFunc that passes when the error message contains the given substring. | ||
| func hasErrorContaining(substring string) require.ErrorAssertionFunc { | ||
| return func(t require.TestingT, actualError error, args ...interface{}) { | ||
| if stdt, ok := t.(*testing.T); ok { | ||
| stdt.Helper() | ||
| } | ||
| require.Error(t, actualError) | ||
| require.Contains(t, actualError.Error(), substring, "expected error to contain %q", substring) | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we link to the go docs since the above 404's?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest using the parsers from
container-lib/imagesince that's the underlying library that OPM itself uses by default and that most of the rest of the typical OLM ecosystem uses (e.g. skopeo and cri-o).