From 13e4f4fe8727f019f21fc546673753f4d6cdd869 Mon Sep 17 00:00:00 2001 From: Joe Lanford Date: Fri, 27 Aug 2021 21:29:50 -0400 Subject: [PATCH 1/5] add olm.channel schema In this PR, the `olm.channel` schema has an extensible `strategy` field with an initial `legacy` implementation that allows each entry to define channel-specific replaces, skips, and skipRange. Conversions from the model to the file-based config format use the `olm.channel` blob rather than generating `olm.channel`, `olm.skips`, and `olm.skipRange` properties on `olm.bundle` properties. If a package has any `olm.channel` blobs, that means that package has opted into fully defining its channels and upgrade edges with `olm.channel` blobs, which means: 1. `olm.channel`, `olm.skips` and `olm.skipRange` properties are not allowed on any bundles in that package. 2. It is an error if an `olm.channel` blob references a non-existent bundle 3. It is an error if a bundle exists in a channel that is not referenced by an `olm.channel` blob. This is an improvement on the the existing `olm.bundle` properties because: 1. `olm.skips` and `olm.skipRange` properties apply to all channels. This causes channel upgrade graphs to be defined by channel-specific replaces values from the `olm.channel` property and by the global skips and skipRange properties, which can make it extremely difficult to define usable upgrade graphs when multiple channels are involved. 2. It centralizes all of the channel membership and upgrade edge information in a single place, making it easier for humans to visualize and for computers to quickly parse and generate upgrade graphs. 3. It simplifies implementation of veneer APIs that focus on different upgrade graph definitions. Different channel and upgrade graph definitions can be built without touching any `olm.bundle` blobs. Signed-off-by: Joe Lanford --- alpha/action/render.go | 1 + alpha/action/render_test.go | 36 +-- .../foo/index.yaml | 95 ++++++++ .../index-declcfgs/exp-headsonly/index.yaml | 72 +++--- .../index-declcfgs/exp-latest/index.yaml | 66 ++++-- alpha/declcfg/declcfg.go | 24 ++ alpha/declcfg/declcfg_to_model.go | 179 ++++++++++---- alpha/declcfg/declcfg_to_model_test.go | 221 ++++++++++++++++-- alpha/declcfg/diff_test.go | 109 +++++++-- alpha/declcfg/helpers_test.go | 77 +++--- alpha/declcfg/load.go | 7 + alpha/declcfg/model_to_declcfg.go | 64 ++++- alpha/declcfg/write.go | 16 ++ alpha/declcfg/write_test.go | 172 ++++++++------ alpha/model/model.go | 1 + alpha/model/model_test.go | 2 +- pkg/api/api_to_model.go | 11 +- pkg/api/conversion_test.go | 2 - pkg/api/model_to_api.go | 10 +- pkg/server/server_test.go | 4 - pkg/sqlite/conversion.go | 4 +- 21 files changed, 868 insertions(+), 305 deletions(-) create mode 100644 alpha/action/testdata/foo-index-v0.2.0-declcfg-with-channel/foo/index.yaml diff --git a/alpha/action/render.go b/alpha/action/render.go index a4a09ba4e..389c8ff44 100644 --- a/alpha/action/render.go +++ b/alpha/action/render.go @@ -381,6 +381,7 @@ func combineConfigs(cfgs []declcfg.DeclarativeConfig) *declcfg.DeclarativeConfig out := &declcfg.DeclarativeConfig{} for _, in := range cfgs { out.Packages = append(out.Packages, in.Packages...) + out.Channels = append(out.Channels, in.Channels...) out.Bundles = append(out.Bundles, in.Bundles...) out.Others = append(out.Others, in.Others...) } diff --git a/alpha/action/render_test.go b/alpha/action/render_test.go index ac3511a51..743ce8015 100644 --- a/alpha/action/render_test.go +++ b/alpha/action/render_test.go @@ -75,6 +75,16 @@ func TestRender(t *testing.T) { DefaultChannel: "beta", }, }, + Channels: []declcfg.Channel{ + {Schema: "olm.channel", Package: "foo", Name: "beta", Strategy: declcfg.ChannelStrategy{Legacy: &declcfg.LegacyChannelStrategy{Entries: []declcfg.LegacyChannelEntry{ + {Name: "foo.v0.1.0", SkipRange: "<0.1.0"}, + {Name: "foo.v0.2.0", Replaces: "foo.v0.1.0", SkipRange: "<0.2.0", Skips: []string{"foo.v0.1.1", "foo.v0.1.2"}}, + }}}}, + {Schema: "olm.channel", Package: "foo", Name: "stable", Strategy: declcfg.ChannelStrategy{Legacy: &declcfg.LegacyChannelStrategy{Entries: []declcfg.LegacyChannelEntry{ + {Name: "foo.v0.1.0", SkipRange: "<0.1.0"}, + {Name: "foo.v0.2.0", Replaces: "foo.v0.1.0", SkipRange: "<0.2.0", Skips: []string{"foo.v0.1.1", "foo.v0.1.2"}}, + }}}}, + }, Bundles: []declcfg.Bundle{ { Schema: "olm.bundle", @@ -82,13 +92,10 @@ func TestRender(t *testing.T) { Package: "foo", Image: "test.registry/foo-operator/foo-bundle:v0.1.0", Properties: []property.Property{ - property.MustBuildChannel("beta", ""), - property.MustBuildChannel("stable", ""), property.MustBuildGVK("test.foo", "v1", "Foo"), property.MustBuildGVKRequired("test.bar", "v1alpha1", "Bar"), property.MustBuildPackage("foo", "0.1.0"), property.MustBuildPackageRequired("bar", "<0.1.0"), - property.MustBuildSkipRange("<0.1.0"), property.MustBuildBundleObjectData(foov1csv), property.MustBuildBundleObjectData(foov1crd), }, @@ -110,15 +117,10 @@ func TestRender(t *testing.T) { Package: "foo", Image: "test.registry/foo-operator/foo-bundle:v0.2.0", Properties: []property.Property{ - property.MustBuildChannel("beta", "foo.v0.1.0"), - property.MustBuildChannel("stable", "foo.v0.1.0"), property.MustBuildGVK("test.foo", "v1", "Foo"), property.MustBuildGVKRequired("test.bar", "v1alpha1", "Bar"), property.MustBuildPackage("foo", "0.2.0"), property.MustBuildPackageRequired("bar", "<0.1.0"), - property.MustBuildSkipRange("<0.2.0"), - property.MustBuildSkips("foo.v0.1.1"), - property.MustBuildSkips("foo.v0.1.2"), property.MustBuildBundleObjectData(foov2csv), property.MustBuildBundleObjectData(foov2crd), }, @@ -165,6 +167,16 @@ func TestRender(t *testing.T) { DefaultChannel: "beta", }, }, + Channels: []declcfg.Channel{ + {Schema: "olm.channel", Package: "foo", Name: "beta", Strategy: declcfg.ChannelStrategy{Legacy: &declcfg.LegacyChannelStrategy{Entries: []declcfg.LegacyChannelEntry{ + {Name: "foo.v0.1.0", SkipRange: "<0.1.0"}, + {Name: "foo.v0.2.0", Replaces: "foo.v0.1.0", SkipRange: "<0.2.0", Skips: []string{"foo.v0.1.1", "foo.v0.1.2"}}, + }}}}, + {Schema: "olm.channel", Package: "foo", Name: "stable", Strategy: declcfg.ChannelStrategy{Legacy: &declcfg.LegacyChannelStrategy{Entries: []declcfg.LegacyChannelEntry{ + {Name: "foo.v0.1.0", SkipRange: "<0.1.0"}, + {Name: "foo.v0.2.0", Replaces: "foo.v0.1.0", SkipRange: "<0.2.0", Skips: []string{"foo.v0.1.1", "foo.v0.1.2"}}, + }}}}, + }, Bundles: []declcfg.Bundle{ { Schema: "olm.bundle", @@ -172,13 +184,10 @@ func TestRender(t *testing.T) { Package: "foo", Image: "test.registry/foo-operator/foo-bundle:v0.1.0", Properties: []property.Property{ - property.MustBuildChannel("beta", ""), - property.MustBuildChannel("stable", ""), property.MustBuildGVK("test.foo", "v1", "Foo"), property.MustBuildGVKRequired("test.bar", "v1alpha1", "Bar"), property.MustBuildPackage("foo", "0.1.0"), property.MustBuildPackageRequired("bar", "<0.1.0"), - property.MustBuildSkipRange("<0.1.0"), property.MustBuildBundleObjectData(foov1csv), property.MustBuildBundleObjectData(foov1crd), }, @@ -200,15 +209,10 @@ func TestRender(t *testing.T) { Package: "foo", Image: "test.registry/foo-operator/foo-bundle:v0.2.0", Properties: []property.Property{ - property.MustBuildChannel("beta", "foo.v0.1.0"), - property.MustBuildChannel("stable", "foo.v0.1.0"), property.MustBuildGVK("test.foo", "v1", "Foo"), property.MustBuildGVKRequired("test.bar", "v1alpha1", "Bar"), property.MustBuildPackage("foo", "0.2.0"), property.MustBuildPackageRequired("bar", "<0.1.0"), - property.MustBuildSkipRange("<0.2.0"), - property.MustBuildSkips("foo.v0.1.1"), - property.MustBuildSkips("foo.v0.1.2"), property.MustBuildBundleObjectData(foov2csv), property.MustBuildBundleObjectData(foov2crd), }, diff --git a/alpha/action/testdata/foo-index-v0.2.0-declcfg-with-channel/foo/index.yaml b/alpha/action/testdata/foo-index-v0.2.0-declcfg-with-channel/foo/index.yaml new file mode 100644 index 000000000..fddc55bca --- /dev/null +++ b/alpha/action/testdata/foo-index-v0.2.0-declcfg-with-channel/foo/index.yaml @@ -0,0 +1,95 @@ +--- +schema: olm.package +name: foo +defaultChannel: beta +--- +schema: olm.channel +name: beta +package: foo +strategy: + legacy: + entries: + - name: foo.v0.1.0 + skipRange: <0.1.0 + - name: foo.v0.2.0 + replaces: foo.v0.1.0 + skips: + - foo.v0.1.1 + - foo.v0.1.2 + skipRange: <0.2.0 +--- +schema: olm.channel +name: stable +package: foo +strategy: + legacy: + entries: + - name: foo.v0.2.0 +--- +schema: olm.bundle +package: foo +name: foo.v0.1.0 +image: test.registry/foo-operator/foo-bundle:v0.1.0 +properties: + - type: olm.gvk + value: + group: test.foo + kind: Foo + version: v1 + - type: olm.gvk.required + value: + group: test.bar + kind: Bar + version: v1alpha1 + - type: olm.package + value: + packageName: foo + version: 0.1.0 + - type: olm.package.required + value: + packageName: bar + versionRange: <0.1.0 + - type: olm.bundle.object + value: + data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsiYW5ub3RhdGlvbnMiOnsib2xtLnNraXBSYW5nZSI6Ilx1MDAzYzAuMS4wIn0sIm5hbWUiOiJmb28udjAuMS4wIn0sInNwZWMiOnsiY3VzdG9tcmVzb3VyY2VkZWZpbml0aW9ucyI6eyJvd25lZCI6W3siZ3JvdXAiOiJ0ZXN0LmZvbyIsImtpbmQiOiJGb28iLCJuYW1lIjoiZm9vcy50ZXN0LmZvbyIsInZlcnNpb24iOiJ2MSJ9XX0sImRpc3BsYXlOYW1lIjoiRm9vIE9wZXJhdG9yIiwicmVsYXRlZEltYWdlcyI6W3siaW1hZ2UiOiJ0ZXN0LnJlZ2lzdHJ5L2Zvby1vcGVyYXRvci9mb286djAuMS4wIiwibmFtZSI6Im9wZXJhdG9yIn1dLCJ2ZXJzaW9uIjoiMC4xLjAifX0= + - type: olm.bundle.object + value: + data: eyJhcGlWZXJzaW9uIjoiYXBpZXh0ZW5zaW9ucy5rOHMuaW8vdjEiLCJraW5kIjoiQ3VzdG9tUmVzb3VyY2VEZWZpbml0aW9uIiwibWV0YWRhdGEiOnsibmFtZSI6ImZvb3MudGVzdC5mb28ifSwic3BlYyI6eyJncm91cCI6InRlc3QuZm9vIiwibmFtZXMiOnsia2luZCI6IkZvbyIsInBsdXJhbCI6ImZvb3MifSwidmVyc2lvbnMiOlt7Im5hbWUiOiJ2MSJ9XX19 +relatedImages: + - image: test.registry/foo-operator/foo:v0.1.0 + name: operator + - image: test.registry/foo-operator/foo-bundle:v0.1.0 +--- +schema: olm.bundle +package: foo +name: foo.v0.2.0 +image: test.registry/foo-operator/foo-bundle:v0.2.0 +properties: + - type: olm.gvk + value: + group: test.foo + kind: Foo + version: v1 + - type: olm.gvk.required + value: + group: test.bar + kind: Bar + version: v1alpha1 + - type: olm.package + value: + packageName: foo + version: 0.2.0 + - type: olm.package.required + value: + packageName: bar + versionRange: <0.1.0 + - type: olm.bundle.object + value: + data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsiYW5ub3RhdGlvbnMiOnsib2xtLnNraXBSYW5nZSI6Ilx1MDAzYzAuMi4wIn0sIm5hbWUiOiJmb28udjAuMi4wIn0sInNwZWMiOnsiY3VzdG9tcmVzb3VyY2VkZWZpbml0aW9ucyI6eyJvd25lZCI6W3siZ3JvdXAiOiJ0ZXN0LmZvbyIsImtpbmQiOiJGb28iLCJuYW1lIjoiZm9vcy50ZXN0LmZvbyIsInZlcnNpb24iOiJ2MSJ9XX0sImRpc3BsYXlOYW1lIjoiRm9vIE9wZXJhdG9yIiwicmVsYXRlZEltYWdlcyI6W3siaW1hZ2UiOiJ0ZXN0LnJlZ2lzdHJ5L2Zvby1vcGVyYXRvci9mb286djAuMi4wIiwibmFtZSI6Im9wZXJhdG9yIn1dLCJyZXBsYWNlcyI6ImZvby52MC4xLjAiLCJza2lwcyI6WyJmb28udjAuMS4xIiwiZm9vLnYwLjEuMiJdLCJ2ZXJzaW9uIjoiMC4yLjAifX0= + - type: olm.bundle.object + value: + data: eyJhcGlWZXJzaW9uIjoiYXBpZXh0ZW5zaW9ucy5rOHMuaW8vdjEiLCJraW5kIjoiQ3VzdG9tUmVzb3VyY2VEZWZpbml0aW9uIiwibWV0YWRhdGEiOnsibmFtZSI6ImZvb3MudGVzdC5mb28ifSwic3BlYyI6eyJncm91cCI6InRlc3QuZm9vIiwibmFtZXMiOnsia2luZCI6IkZvbyIsInBsdXJhbCI6ImZvb3MifSwidmVyc2lvbnMiOlt7Im5hbWUiOiJ2MSJ9XX19 +relatedImages: + - image: test.registry/foo-operator/foo:v0.2.0 + name: operator + - image: test.registry/foo-operator/foo-bundle:v0.2.0 diff --git a/alpha/action/testdata/index-declcfgs/exp-headsonly/index.yaml b/alpha/action/testdata/index-declcfgs/exp-headsonly/index.yaml index ac7ee30f8..19ed3576b 100644 --- a/alpha/action/testdata/index-declcfgs/exp-headsonly/index.yaml +++ b/alpha/action/testdata/index-declcfgs/exp-headsonly/index.yaml @@ -3,6 +3,27 @@ defaultChannel: stable name: bar schema: olm.package --- +name: alpha +package: bar +schema: olm.channel +strategy: + legacy: + entries: + - name: bar.v0.1.0 + - name: bar.v0.2.0 + skips: + - bar.v0.1.0 + - name: bar.v1.0.0 + replaces: bar.v0.2.0 +--- +name: stable +package: bar +schema: olm.channel +strategy: + legacy: + entries: + - name: bar.v1.0.0 +--- # Added because foo.v0.3.1 depends on bar <0.2.0 image: test.registry/bar-operator/bar-bundle:v0.1.0 name: bar.v0.1.0 @@ -14,9 +35,6 @@ properties: - type: olm.bundle.object value: data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsibmFtZSI6ImJhci52MC4xLjAifSwic3BlYyI6eyJjdXN0b21yZXNvdXJjZWRlZmluaXRpb25zIjp7Im93bmVkIjpbeyJncm91cCI6InRlc3QuYmFyIiwia2luZCI6IkJhciIsIm5hbWUiOiJiYXJzLnRlc3QuYmFyIiwidmVyc2lvbiI6InYxYWxwaGExIn1dfSwicmVsYXRlZEltYWdlcyI6W3siaW1hZ2UiOiJ0ZXN0LnJlZ2lzdHJ5L2Jhci1vcGVyYXRvci9iYXI6djAuMS4wIiwibmFtZSI6Im9wZXJhdG9yIn1dLCJ2ZXJzaW9uIjoiMC4xLjAifX0= -- type: olm.channel - value: - name: alpha - type: olm.gvk value: group: test.bar @@ -44,9 +62,6 @@ properties: - type: olm.bundle.object value: data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsiYW5ub3RhdGlvbnMiOnsib2xtLnNraXBSYW5nZSI6Ilx1MDAzYzAuMi4wIn0sIm5hbWUiOiJiYXIudjAuMi4wIn0sInNwZWMiOnsiY3VzdG9tcmVzb3VyY2VkZWZpbml0aW9ucyI6eyJvd25lZCI6W3siZ3JvdXAiOiJ0ZXN0LmJhciIsImtpbmQiOiJCYXIiLCJuYW1lIjoiYmFycy50ZXN0LmJhciIsInZlcnNpb24iOiJ2MWFscGhhMSJ9XX0sInJlbGF0ZWRJbWFnZXMiOlt7ImltYWdlIjoidGVzdC5yZWdpc3RyeS9iYXItb3BlcmF0b3IvYmFyOnYwLjIuMCIsIm5hbWUiOiJvcGVyYXRvciJ9XSwic2tpcHMiOlsiYmFyLnYwLjEuMCJdLCJ2ZXJzaW9uIjoiMC4yLjAifX0= -- type: olm.channel - value: - name: alpha - type: olm.gvk value: group: test.bar @@ -56,10 +71,6 @@ properties: value: packageName: bar version: 0.2.0 -- type: olm.skipRange - value: <0.2.0 -- type: olm.skips - value: bar.v0.1.0 relatedImages: - image: test.registry/bar-operator/bar:v0.2.0 name: operator @@ -75,13 +86,6 @@ properties: - type: olm.bundle.object value: data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsibmFtZSI6ImJhci52MS4wLjAifSwic3BlYyI6eyJjdXN0b21yZXNvdXJjZWRlZmluaXRpb25zIjp7Im93bmVkIjpbeyJncm91cCI6InRlc3QuYmFyIiwia2luZCI6IkJhciIsIm5hbWUiOiJiYXJzLnRlc3QuYmFyIiwidmVyc2lvbiI6InYxYWxwaGExIn0seyJncm91cCI6InRlc3QuYmFyIiwia2luZCI6IkJhciIsIm5hbWUiOiJiYXJzLnRlc3QuYmFyIiwidmVyc2lvbiI6InYxIn1dfSwicmVsYXRlZEltYWdlcyI6W3siaW1hZ2UiOiJ0ZXN0LnJlZ2lzdHJ5L2Jhci1vcGVyYXRvci9iYXI6djEuMC4wIiwibmFtZSI6Im9wZXJhdG9yIn1dLCJyZXBsYWNlcyI6ImJhci52MC4yLjAiLCJ2ZXJzaW9uIjoiMS4wLjAifX0= -- type: olm.channel - value: - name: alpha - replaces: bar.v0.2.0 -- type: olm.channel - value: - name: stable - type: olm.gvk value: group: test.bar @@ -105,6 +109,17 @@ defaultChannel: stable name: baz schema: olm.package --- +name: stable +package: baz +schema: olm.channel +strategy: + legacy: + entries: + - name: baz.v1.1.0 + replaces: baz.v1.0.0 + skips: + - baz.v1.0.1 +--- image: test.registry/baz-operator/baz-bundle:v1.1.0 name: baz.v1.1.0 package: baz @@ -115,10 +130,6 @@ properties: - type: olm.bundle.object value: data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsibmFtZSI6ImJhei52MS4xLjAifSwic3BlYyI6eyJjdXN0b21yZXNvdXJjZWRlZmluaXRpb25zIjp7Im93bmVkIjpbeyJncm91cCI6InRlc3QuYmF6Iiwia2luZCI6IkJheiIsIm5hbWUiOiJiYXpzLnRlc3QuYmF6IiwidmVyc2lvbiI6InYxIn1dfSwicmVsYXRlZEltYWdlcyI6W3siaW1hZ2UiOiJ0ZXN0LnJlZ2lzdHJ5L2Jhei1vcGVyYXRvci9iYXo6djEuMS4wIiwibmFtZSI6Im9wZXJhdG9yIn1dLCJyZXBsYWNlcyI6ImJhei52MS4wLjAiLCJ2ZXJzaW9uIjoiMS4xLjAifX0= -- type: olm.channel - value: - name: stable - replaces: baz.v1.0.0 - type: olm.gvk value: group: test.baz @@ -128,8 +139,6 @@ properties: value: packageName: baz version: 1.1.0 -- type: olm.skips - value: baz.v1.0.1 relatedImages: - image: test.registry/baz-operator/baz:v1.1.0 name: operator @@ -139,6 +148,17 @@ defaultChannel: beta name: foo schema: olm.package --- +name: beta +package: foo +schema: olm.channel +strategy: + legacy: + entries: + - name: foo.v0.3.1 + replaces: foo.v0.2.0 + skips: + - foo.v0.3.0 +--- image: test.registry/foo-operator/foo-bundle:v0.3.1 name: foo.v0.3.1 package: foo @@ -149,10 +169,6 @@ properties: - type: olm.bundle.object value: data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsibmFtZSI6ImZvby52MC4zLjEifSwic3BlYyI6eyJjdXN0b21yZXNvdXJjZWRlZmluaXRpb25zIjp7Im93bmVkIjpbeyJncm91cCI6InRlc3QuZm9vIiwia2luZCI6IkZvbyIsIm5hbWUiOiJmb29zLnRlc3QuZm9vIiwidmVyc2lvbiI6InYxIn0seyJncm91cCI6InRlc3QuZm9vIiwia2luZCI6IkZvbyIsIm5hbWUiOiJmb29zLnRlc3QuZm9vIiwidmVyc2lvbiI6InYyIn1dfSwicmVsYXRlZEltYWdlcyI6W3siaW1hZ2UiOiJ0ZXN0LnJlZ2lzdHJ5L2Zvby1vcGVyYXRvci9mb286djAuMy4xIiwibmFtZSI6Im9wZXJhdG9yIn1dLCJyZXBsYWNlcyI6ImZvby52MC4yLjAiLCJza2lwcyI6WyJmb28udjAuMy4wIl0sInZlcnNpb24iOiIwLjMuMSJ9fQ== -- type: olm.channel - value: - name: beta - replaces: foo.v0.2.0 - type: olm.gvk value: group: test.foo @@ -176,8 +192,6 @@ properties: value: packageName: bar versionRange: <0.2.0 -- type: olm.skips - value: foo.v0.3.0 relatedImages: - image: test.registry/foo-operator/foo:v0.3.1 name: operator diff --git a/alpha/action/testdata/index-declcfgs/exp-latest/index.yaml b/alpha/action/testdata/index-declcfgs/exp-latest/index.yaml index 4b9766352..4b53f3688 100644 --- a/alpha/action/testdata/index-declcfgs/exp-latest/index.yaml +++ b/alpha/action/testdata/index-declcfgs/exp-latest/index.yaml @@ -3,6 +3,23 @@ defaultChannel: stable name: bar schema: olm.package --- +name: alpha +package: bar +schema: olm.channel +strategy: + legacy: + entries: + - name: bar.v1.0.0 + replaces: bar.v0.2.0 +--- +name: stable +package: bar +schema: olm.channel +strategy: + legacy: + entries: + - name: bar.v1.0.0 +--- image: test.registry/bar-operator/bar-bundle:v1.0.0 name: bar.v1.0.0 package: bar @@ -13,13 +30,6 @@ properties: - type: olm.bundle.object value: data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsibmFtZSI6ImJhci52MS4wLjAifSwic3BlYyI6eyJjdXN0b21yZXNvdXJjZWRlZmluaXRpb25zIjp7Im93bmVkIjpbeyJncm91cCI6InRlc3QuYmFyIiwia2luZCI6IkJhciIsIm5hbWUiOiJiYXJzLnRlc3QuYmFyIiwidmVyc2lvbiI6InYxYWxwaGExIn0seyJncm91cCI6InRlc3QuYmFyIiwia2luZCI6IkJhciIsIm5hbWUiOiJiYXJzLnRlc3QuYmFyIiwidmVyc2lvbiI6InYxIn1dfSwicmVsYXRlZEltYWdlcyI6W3siaW1hZ2UiOiJ0ZXN0LnJlZ2lzdHJ5L2Jhci1vcGVyYXRvci9iYXI6djEuMC4wIiwibmFtZSI6Im9wZXJhdG9yIn1dLCJyZXBsYWNlcyI6ImJhci52MC4yLjAiLCJ2ZXJzaW9uIjoiMS4wLjAifX0= -- type: olm.channel - value: - name: alpha - replaces: bar.v0.2.0 -- type: olm.channel - value: - name: stable - type: olm.gvk value: group: test.bar @@ -43,6 +53,19 @@ defaultChannel: stable name: baz schema: olm.package --- +name: stable +package: baz +schema: olm.channel +strategy: + legacy: + entries: + - name: baz.v1.0.1 + replaces: baz.v1.0.0 + - name: baz.v1.1.0 + replaces: baz.v1.0.0 + skips: + - baz.v1.0.1 +--- image: test.registry/baz-operator/baz-bundle:v1.0.1 name: baz.v1.0.1 package: baz @@ -53,10 +76,6 @@ properties: - type: olm.bundle.object value: data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsiYW5ub3RhdGlvbnMiOnsib2xtLnNraXBSYW5nZSI6Ilx1MDAzYzEuMC4xIn0sIm5hbWUiOiJiYXoudjEuMC4xIn0sInNwZWMiOnsiY3VzdG9tcmVzb3VyY2VkZWZpbml0aW9ucyI6eyJvd25lZCI6W3siZ3JvdXAiOiJ0ZXN0LmJheiIsImtpbmQiOiJCYXoiLCJuYW1lIjoiYmF6cy50ZXN0LmJheiIsInZlcnNpb24iOiJ2MSJ9XX0sInJlbGF0ZWRJbWFnZXMiOlt7ImltYWdlIjoidGVzdC5yZWdpc3RyeS9iYXotb3BlcmF0b3IvYmF6OnYxLjAuMSIsIm5hbWUiOiJvcGVyYXRvciJ9XSwic2tpcHMiOlsiYmF6LnYxLjAuMCJdLCJ2ZXJzaW9uIjoiMS4wLjEifX0= -- type: olm.channel - value: - name: stable - replaces: baz.v1.0.0 - type: olm.gvk value: group: test.baz @@ -66,8 +85,6 @@ properties: value: packageName: baz version: 1.0.1 -- type: olm.skipRange - value: <1.0.0 relatedImages: - image: test.registry/baz-operator/baz:v1.0.1 name: operator @@ -83,10 +100,6 @@ properties: - type: olm.bundle.object value: data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsibmFtZSI6ImJhei52MS4xLjAifSwic3BlYyI6eyJjdXN0b21yZXNvdXJjZWRlZmluaXRpb25zIjp7Im93bmVkIjpbeyJncm91cCI6InRlc3QuYmF6Iiwia2luZCI6IkJheiIsIm5hbWUiOiJiYXpzLnRlc3QuYmF6IiwidmVyc2lvbiI6InYxIn1dfSwicmVsYXRlZEltYWdlcyI6W3siaW1hZ2UiOiJ0ZXN0LnJlZ2lzdHJ5L2Jhei1vcGVyYXRvci9iYXo6djEuMS4wIiwibmFtZSI6Im9wZXJhdG9yIn1dLCJyZXBsYWNlcyI6ImJhei52MS4wLjAiLCJ2ZXJzaW9uIjoiMS4xLjAifX0= -- type: olm.channel - value: - name: stable - replaces: baz.v1.0.0 - type: olm.gvk value: group: test.baz @@ -96,8 +109,6 @@ properties: value: packageName: baz version: 1.1.0 -- type: olm.skips - value: baz.v1.0.1 relatedImages: - image: test.registry/baz-operator/baz:v1.1.0 name: operator @@ -107,6 +118,17 @@ defaultChannel: beta name: foo schema: olm.package --- +name: beta +package: foo +schema: olm.channel +strategy: + legacy: + entries: + - name: foo.v0.3.1 + replaces: foo.v0.2.0 + skips: + - foo.v0.3.0 +--- image: test.registry/foo-operator/foo-bundle:v0.3.1 name: foo.v0.3.1 package: foo @@ -117,10 +139,6 @@ properties: - type: olm.bundle.object value: data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsibmFtZSI6ImZvby52MC4zLjEifSwic3BlYyI6eyJjdXN0b21yZXNvdXJjZWRlZmluaXRpb25zIjp7Im93bmVkIjpbeyJncm91cCI6InRlc3QuZm9vIiwia2luZCI6IkZvbyIsIm5hbWUiOiJmb29zLnRlc3QuZm9vIiwidmVyc2lvbiI6InYxIn0seyJncm91cCI6InRlc3QuZm9vIiwia2luZCI6IkZvbyIsIm5hbWUiOiJmb29zLnRlc3QuZm9vIiwidmVyc2lvbiI6InYyIn1dfSwicmVsYXRlZEltYWdlcyI6W3siaW1hZ2UiOiJ0ZXN0LnJlZ2lzdHJ5L2Zvby1vcGVyYXRvci9mb286djAuMy4xIiwibmFtZSI6Im9wZXJhdG9yIn1dLCJyZXBsYWNlcyI6ImZvby52MC4yLjAiLCJza2lwcyI6WyJmb28udjAuMy4wIl0sInZlcnNpb24iOiIwLjMuMSJ9fQ== -- type: olm.channel - value: - name: beta - replaces: foo.v0.2.0 - type: olm.gvk value: group: test.foo @@ -144,8 +162,6 @@ properties: value: packageName: bar versionRange: <0.2.0 -- type: olm.skips - value: foo.v0.3.0 relatedImages: - image: test.registry/foo-operator/foo:v0.3.1 name: operator diff --git a/alpha/declcfg/declcfg.go b/alpha/declcfg/declcfg.go index 3bb64c035..6ed802661 100644 --- a/alpha/declcfg/declcfg.go +++ b/alpha/declcfg/declcfg.go @@ -8,11 +8,13 @@ import ( const ( schemaPackage = "olm.package" + schemaChannel = "olm.channel" schemaBundle = "olm.bundle" ) type DeclarativeConfig struct { Packages []Package + Channels []Channel Bundles []Bundle Others []Meta } @@ -30,6 +32,28 @@ type Icon struct { MediaType string `json:"mediatype"` } +type Channel struct { + Schema string `json:"schema"` + Name string `json:"name"` + Package string `json:"package"` + Strategy ChannelStrategy `json:"strategy"` +} + +type ChannelStrategy struct { + Legacy *LegacyChannelStrategy `json:"legacy,omitempty"` +} + +type LegacyChannelStrategy struct { + Entries []LegacyChannelEntry `json:"entries"` +} + +type LegacyChannelEntry struct { + Name string `json:"name"` + Replaces string `json:"replaces,omitempty"` + Skips []string `json:"skips,omitempty"` + SkipRange string `json:"skipRange,omitempty"` +} + // Bundle specifies all metadata and data of a bundle object. // Top-level fields are the source of truth, i.e. not CSV values. // diff --git a/alpha/declcfg/declcfg_to_model.go b/alpha/declcfg/declcfg_to_model.go index 0493558b3..ac4770416 100644 --- a/alpha/declcfg/declcfg_to_model.go +++ b/alpha/declcfg/declcfg_to_model.go @@ -1,10 +1,10 @@ package declcfg import ( - "encoding/json" "fmt" "github.com/blang/semver" + "k8s.io/apimachinery/pkg/util/sets" "github.com/operator-framework/operator-registry/alpha/model" "github.com/operator-framework/operator-registry/alpha/property" @@ -14,6 +14,10 @@ func ConvertToModel(cfg DeclarativeConfig) (model.Model, error) { mpkgs := model.Model{} defaultChannels := map[string]string{} for _, p := range cfg.Packages { + if p.Name == "" { + return nil, fmt.Errorf("config contains package with no name") + } + mpkg := &model.Package{ Name: p.Name, Description: p.Description, @@ -29,6 +33,53 @@ func ConvertToModel(cfg DeclarativeConfig) (model.Model, error) { mpkgs[p.Name] = mpkg } + channelDefinedEdges := sets.NewString() + channelDefinedEntries := map[string]sets.String{} + for _, c := range cfg.Channels { + mpkg, ok := mpkgs[c.Package] + if !ok { + return nil, fmt.Errorf("unknown package %q for channel %q", c.Package, c.Name) + } + + if c.Name == "" { + return nil, fmt.Errorf("package %q contains channel with no name", c.Package) + } + + mch := &model.Channel{ + Package: mpkg, + Name: c.Name, + Bundles: map[string]*model.Bundle{}, + } + + cde := sets.NewString() + if c.Strategy.Legacy == nil { + return nil, fmt.Errorf("package %q, channel %q has no defined strategy", c.Package, c.Name) + } + for _, entry := range c.Strategy.Legacy.Entries { + if _, ok := mch.Bundles[entry.Name]; ok { + return nil, fmt.Errorf("invalid package %q, channel %q: duplicate entry %q", c.Package, c.Name, entry.Name) + } + cde = cde.Insert(entry.Name) + mch.Bundles[entry.Name] = &model.Bundle{ + Package: mpkg, + Channel: mch, + Name: entry.Name, + Replaces: entry.Replaces, + Skips: entry.Skips, + SkipRange: entry.SkipRange, + } + } + channelDefinedEntries[c.Package] = cde + channelDefinedEdges = channelDefinedEdges.Insert(c.Package) + + mpkg.Channels[c.Name] = mch + + defaultChannelName := defaultChannels[c.Package] + if defaultChannelName == c.Name { + mpkg.DefaultChannel = mch + } + } + for _, b := range cfg.Bundles { defaultChannelName := defaultChannels[b.Package] if b.Package == "" { @@ -44,62 +95,98 @@ func ConvertToModel(cfg DeclarativeConfig) (model.Model, error) { return nil, fmt.Errorf("parse properties for bundle %q: %v", b.Name, err) } - if len(props.Packages) == 0 { - return nil, fmt.Errorf("missing package property for bundle %q", b.Name) + if len(props.Packages) != 1 { + return nil, fmt.Errorf("package %q bundle %q must have exactly 1 %q property, found %d", b.Package, b.Name, property.TypePackage, len(props.Packages)) } if b.Package != props.Packages[0].PackageName { return nil, fmt.Errorf("package %q does not match %q property %q", b.Package, property.TypePackage, props.Packages[0].PackageName) } - if len(props.Channels) == 0 { - return nil, fmt.Errorf("bundle %q is missing channel information", b.Name) + // Parse version from the package property. + ver, err := semver.Parse(props.Packages[0].Version) + if err != nil { + return nil, fmt.Errorf("error parsing bundle version: %v", err) } - for _, bundleChannel := range props.Channels { - pkgChannel, ok := mpkg.Channels[bundleChannel.Name] - if !ok { - pkgChannel = &model.Channel{ - Package: mpkg, - Name: bundleChannel.Name, - Bundles: map[string]*model.Bundle{}, - } - if bundleChannel.Name == defaultChannelName { - mpkg.DefaultChannel = pkgChannel + if channelDefinedEdges.Has(b.Package) { + if len(props.Channels) > 0 { + return nil, fmt.Errorf("invalid package %q, bundle %q: cannot use %q properties with %q blobs", b.Package, b.Name, property.TypeChannel, schemaChannel) + } + if len(props.Skips) > 0 { + return nil, fmt.Errorf("invalid package %q, bundle %q: cannot use %q properties with %q blobs", b.Package, b.Name, property.TypeSkips, schemaChannel) + } + if len(props.SkipRanges) > 0 { + return nil, fmt.Errorf("invalid package %q, bundle %q: cannot use %q properties with %q blobs", b.Package, b.Name, property.TypeSkipRange, schemaChannel) + } + + channelDefinedEntries[b.Package] = channelDefinedEntries[b.Package].Delete(b.Name) + found := false + for _, mch := range mpkg.Channels { + if mb, ok := mch.Bundles[b.Name]; ok { + found = true + mb.Image = b.Image + mb.Properties = b.Properties + mb.RelatedImages = relatedImagesToModelRelatedImages(b.RelatedImages) + mb.CsvJSON = b.CsvJSON + mb.Objects = b.Objects + mb.PropertiesP = props + mb.Version = ver } - mpkg.Channels[bundleChannel.Name] = pkgChannel + } + if !found { + return nil, fmt.Errorf("package %q, bundle %q not found in any channel entries", b.Package, b.Name) + } + } else { + if len(props.Channels) == 0 { + return nil, fmt.Errorf("package %q bundle %q is missing channel information", b.Package, b.Name) + } + + if len(props.SkipRanges) > 1 { + return nil, fmt.Errorf("package %q bundle %q is invalid: multiple properties of type %q not allowed", b.Package, b.Name, property.TypeSkipRange) + } + + skipRange := "" + if len(props.SkipRanges) > 0 { + skipRange = string(props.SkipRanges[0]) } - // Parse version from the package property, falling back to the CSV's spec.version field. - var ver semver.Version - for _, pkgProp := range props.Packages { - if pkgProp.PackageName == mpkg.Name && pkgProp.Version != "" { - if ver, err = semver.Parse(pkgProp.Version); err != nil { - return nil, fmt.Errorf("error parsing bundle version: %v", err) + for _, bundleChannel := range props.Channels { + pkgChannel, ok := mpkg.Channels[bundleChannel.Name] + if !ok { + pkgChannel = &model.Channel{ + Package: mpkg, + Name: bundleChannel.Name, + Bundles: map[string]*model.Bundle{}, } - break + if bundleChannel.Name == defaultChannelName { + mpkg.DefaultChannel = pkgChannel + } + mpkg.Channels[bundleChannel.Name] = pkgChannel } - } - if ver.Equals(semver.Version{}) { - if ver, err = getCSVVersion([]byte(b.CsvJSON)); err != nil { - return nil, fmt.Errorf("error reading bundle version from CSV: %v", err) + + pkgChannel.Bundles[b.Name] = &model.Bundle{ + Package: mpkg, + Channel: pkgChannel, + Name: b.Name, + Image: b.Image, + Replaces: bundleChannel.Replaces, + Skips: skipsToStrings(props.Skips), + SkipRange: skipRange, + Properties: b.Properties, + RelatedImages: relatedImagesToModelRelatedImages(b.RelatedImages), + CsvJSON: b.CsvJSON, + Objects: b.Objects, + PropertiesP: props, + Version: ver, } } + } + } - pkgChannel.Bundles[b.Name] = &model.Bundle{ - Package: mpkg, - Channel: pkgChannel, - Name: b.Name, - Image: b.Image, - Replaces: bundleChannel.Replaces, - Skips: skipsToStrings(props.Skips), - Properties: b.Properties, - RelatedImages: relatedImagesToModelRelatedImages(b.RelatedImages), - CsvJSON: b.CsvJSON, - Objects: b.Objects, - PropertiesP: props, - Version: ver, - } + for pkg, entries := range channelDefinedEntries { + if entries.Len() > 0 { + return nil, fmt.Errorf("no olm.bundle blobs found in package %q for olm.channel entries %s", pkg, entries.List()) } } @@ -141,13 +228,3 @@ func relatedImagesToModelRelatedImages(in []RelatedImage) []model.RelatedImage { } return out } - -func getCSVVersion(csvJSON []byte) (semver.Version, error) { - var tmp struct { - Spec struct { - Version semver.Version `json:"version"` - } `json:"spec"` - } - err := json.Unmarshal(csvJSON, &tmp) - return tmp.Spec.Version, err -} diff --git a/alpha/declcfg/declcfg_to_model_test.go b/alpha/declcfg/declcfg_to_model_test.go index 039510294..7d389fe28 100644 --- a/alpha/declcfg/declcfg_to_model_test.go +++ b/alpha/declcfg/declcfg_to_model_test.go @@ -5,6 +5,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/operator-framework/operator-registry/alpha/property" ) func TestConvertToModel(t *testing.T) { @@ -15,17 +17,25 @@ func TestConvertToModel(t *testing.T) { } specs := []spec{ + { + name: "Error/PackageNoName", + assertion: hasError(`config contains package with no name`), + cfg: DeclarativeConfig{ + Packages: []Package{newTestPackage("", "alpha", svgSmallCircle)}, + Bundles: []Bundle{{Name: "foo.v0.1.0"}}, + }, + }, { name: "Error/BundleMissingPackageName", - assertion: require.Error, + assertion: hasError(`package name must be set for bundle "foo.v0.1.0"`), cfg: DeclarativeConfig{ Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, - Bundles: []Bundle{{}}, + Bundles: []Bundle{{Name: "foo.v0.1.0"}}, }, }, { name: "Error/BundleUnknownPackage", - assertion: require.Error, + assertion: hasError(`unknown package "bar" for bundle "bar.v0.1.0"`), cfg: DeclarativeConfig{ Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, Bundles: []Bundle{newTestBundle("bar", "0.1.0", withChannel("alpha", ""))}, @@ -33,46 +43,101 @@ func TestConvertToModel(t *testing.T) { }, { name: "Error/BundleMissingChannel", - assertion: require.Error, + assertion: hasError(`package "foo" bundle "foo.v0.1.0" is missing channel information`), cfg: DeclarativeConfig{ Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, Bundles: []Bundle{newTestBundle("foo", "0.1.0")}, }, }, { - name: "Error/InvalidProperties", - assertion: require.Error, + name: "Error/BundleInvalidProperties", + assertion: hasError(`parse properties for bundle "foo.v0.1.0": duplicate property of type "olm.channel" found with key "alpha"`), cfg: DeclarativeConfig{ Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, Bundles: []Bundle{newTestBundle("foo", "0.1.0", withChannel("alpha", "1"), withChannel("alpha", "2"))}, }, }, { - name: "Error/BundleMissingDefaultChannel", - assertion: require.Error, + name: "Error/BundleMultipleSkipRanges", + assertion: hasError(`package "foo" bundle "foo.v0.1.0" is invalid: multiple properties of type "olm.skipRange" not allowed`), + cfg: DeclarativeConfig{ + Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, + Bundles: []Bundle{newTestBundle("foo", "0.1.0", withChannel("alpha", ""), func(b *Bundle) { + b.Properties = append(b.Properties, + property.MustBuildSkipRange("<0.1.0"), + property.MustBuildSkipRange("<=0.1.0"), + ) + })}, + }, + }, + { + name: "Error/BundlePackageMismatch", + assertion: hasError(`package "foo" does not match "olm.package" property "foooperator"`), + cfg: DeclarativeConfig{ + Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, + Bundles: []Bundle{newTestBundle("foo", "0.1.0", func(b *Bundle) { + b.Properties = []property.Property{ + property.MustBuildPackage("foooperator", "0.1.0"), + } + })}, + }, + }, + { + name: "Error/BundleInvalidVersion", + assertion: hasError(`error parsing bundle version: Invalid character(s) found in patch number "0.1"`), + cfg: DeclarativeConfig{ + Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, + Bundles: []Bundle{newTestBundle("foo", "0.1.0", func(b *Bundle) { + b.Properties = []property.Property{ + property.MustBuildPackage("foo", "0.1.0.1"), + } + })}, + }, + }, + { + name: "Error/PackageMissingDefaultChannel", + assertion: hasError(`invalid index: +└── invalid package "foo": + └── default channel must be set`), cfg: DeclarativeConfig{ Packages: []Package{newTestPackage("foo", "", svgSmallCircle)}, Bundles: []Bundle{newTestBundle("foo", "0.1.0", withChannel("alpha", ""))}, }, }, { - name: "Error/BundleMissingImageAndData", - assertion: require.Error, + name: "Error/PackageNonExistentDefaultChannel", + assertion: hasError(`invalid index: +└── invalid package "foo": + └── invalid channel "bar": + └── channel must contain at least one bundle`), + cfg: DeclarativeConfig{ + Packages: []Package{newTestPackage("foo", "bar", svgSmallCircle)}, + Bundles: []Bundle{newTestBundle("foo", "0.1.0", withChannel("alpha", ""))}, + }, + }, + { + name: "Error/BundleMissingPackageProperty", + assertion: hasError(`package "foo" bundle "foo.v0.1.0" must have exactly 1 "olm.package" property, found 0`), cfg: DeclarativeConfig{ Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, - Bundles: []Bundle{newTestBundle("foo", "0.1.0", withChannel("alpha", ""), withNoBundleImage(), withNoBundleData())}, + Bundles: []Bundle{newTestBundle("foo", "0.1.0", withNoProperties())}, }, }, { - name: "NoError/BundleMissingProperties", - assertion: require.Error, + name: "Error/BundleMultiplePackageProperty", + assertion: hasError(`package "foo" bundle "foo.v0.1.0" must have exactly 1 "olm.package" property, found 2`), cfg: DeclarativeConfig{ Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, - Bundles: []Bundle{newTestBundle("foo", "0.1.0", withChannel("alpha", ""), withNoProperties())}, + Bundles: []Bundle{newTestBundle("foo", "0.1.0", func(b *Bundle) { + b.Properties = []property.Property{ + property.MustBuildPackage("foo", "0.1.0"), + property.MustBuildPackage("foo", "0.1.0"), + } + })}, }, }, { - name: "NoError/BundleWithDataButMissingImage", + name: "Success/BundleWithDataButMissingImage", assertion: require.NoError, cfg: DeclarativeConfig{ Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, @@ -80,13 +145,122 @@ func TestConvertToModel(t *testing.T) { }, }, { - name: "Success/ValidModel", - assertion: require.NoError, + name: "Error/ChannelAndBundleChannel", + assertion: hasError(`invalid package "foo", bundle "foo.v0.1.0": cannot use "olm.channel" properties with "olm.channel" blobs`), cfg: DeclarativeConfig{ Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, + Channels: []Channel{newTestChannel("foo", "alpha", LegacyChannelEntry{Name: "foo.v0.1.0"})}, Bundles: []Bundle{newTestBundle("foo", "0.1.0", withChannel("alpha", ""))}, }, }, + { + name: "Error/ChannelAndBundleSkips", + assertion: hasError(`invalid package "foo", bundle "foo.v0.1.0": cannot use "olm.skips" properties with "olm.channel" blobs`), + cfg: DeclarativeConfig{ + Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, + Channels: []Channel{newTestChannel("foo", "alpha", LegacyChannelEntry{Name: "foo.v0.1.0"})}, + Bundles: []Bundle{newTestBundle("foo", "0.1.0", func(b *Bundle) { + b.Properties = append(b.Properties, property.MustBuildSkips("foo.v0.0.1")) + })}, + }, + }, + { + name: "Error/ChannelAndBundleSkipRange", + assertion: hasError(`invalid package "foo", bundle "foo.v0.1.0": cannot use "olm.skipRange" properties with "olm.channel" blobs`), + cfg: DeclarativeConfig{ + Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, + Channels: []Channel{newTestChannel("foo", "alpha", LegacyChannelEntry{Name: "foo.v0.1.0"})}, + Bundles: []Bundle{newTestBundle("foo", "0.1.0", func(b *Bundle) { + b.Properties = append(b.Properties, property.MustBuildSkipRange("<0.1.0")) + })}, + }, + }, + { + name: "Error/ChannelEntryWithoutBundle", + assertion: hasError(`no olm.bundle blobs found in package "foo" for olm.channel entries [foo.v0.1.0]`), + cfg: DeclarativeConfig{ + Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, + Channels: []Channel{newTestChannel("foo", "alpha", LegacyChannelEntry{Name: "foo.v0.1.0"})}, + }, + }, + { + name: "Error/BundleWithoutChannelEntry", + assertion: hasError(`package "foo", bundle "foo.v0.2.0" not found in any channel entries`), + cfg: DeclarativeConfig{ + Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, + Channels: []Channel{newTestChannel("foo", "alpha", LegacyChannelEntry{Name: "foo.v0.1.0"})}, + Bundles: []Bundle{newTestBundle("foo", "0.2.0")}, + }, + }, + { + name: "Error/ChannelMissingName", + assertion: hasError(`package "foo" contains channel with no name`), + cfg: DeclarativeConfig{ + Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, + Channels: []Channel{newTestChannel("foo", "", LegacyChannelEntry{Name: "foo.v0.1.0"})}, + Bundles: []Bundle{newTestBundle("foo", "0.2.0")}, + }, + }, + { + name: "Error/ChannelMissingPackageName", + assertion: hasError(`unknown package "" for channel "alpha"`), + cfg: DeclarativeConfig{ + Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, + Channels: []Channel{newTestChannel("", "alpha", LegacyChannelEntry{Name: "foo.v0.1.0"})}, + Bundles: []Bundle{newTestBundle("foo", "0.2.0")}, + }, + }, + { + name: "Error/ChannelMissingStrategy", + assertion: hasError(`package "foo", channel "alpha" has no defined strategy`), + cfg: DeclarativeConfig{ + Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, + Channels: []Channel{{Schema: schemaChannel, Package: "foo", Name: "alpha"}}, + Bundles: []Bundle{newTestBundle("foo", "0.2.0")}, + }, + }, + { + name: "Error/ChannelNonExistentPackage", + assertion: hasError(`unknown package "non-existent" for channel "alpha"`), + cfg: DeclarativeConfig{ + Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, + Channels: []Channel{newTestChannel("non-existent", "alpha", LegacyChannelEntry{Name: "foo.v0.1.0"})}, + Bundles: []Bundle{newTestBundle("foo", "0.1.0")}, + }, + }, + { + name: "Error/ChannelDuplicateEntry", + assertion: hasError(`invalid package "foo", channel "alpha": duplicate entry "foo.v0.1.0"`), + cfg: DeclarativeConfig{ + Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, + Channels: []Channel{newTestChannel("foo", "alpha", + LegacyChannelEntry{Name: "foo.v0.1.0"}, + LegacyChannelEntry{Name: "foo.v0.1.0"}, + )}, + Bundles: []Bundle{newTestBundle("foo", "0.1.0")}, + }, + }, + { + name: "Success/WithChannel/ValidModel", + assertion: require.NoError, + cfg: DeclarativeConfig{ + Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, + Channels: []Channel{newTestChannel("foo", "alpha", LegacyChannelEntry{Name: "foo.v0.1.0"})}, + Bundles: []Bundle{newTestBundle("foo", "0.1.0")}, + }, + }, + { + name: "Success/WithoutChannel/ValidModel", + assertion: require.NoError, + cfg: DeclarativeConfig{ + Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, + Bundles: []Bundle{newTestBundle("foo", "0.1.0", withChannel("alpha", ""), func(b *Bundle) { + b.Properties = append(b.Properties, + property.MustBuildSkipRange("<0.1.0"), + ) + })}, + }, + }, } for _, s := range specs { @@ -111,3 +285,16 @@ func TestConvertToModelRoundtrip(t *testing.T) { assert.Equal(t, expected.Bundles, actual.Bundles) assert.Len(t, actual.Others, 0, "expected unrecognized schemas not to make the roundtrip") } + +func hasError(expectedError string) require.ErrorAssertionFunc { + return func(t require.TestingT, actualError error, args ...interface{}) { + if stdt, ok := t.(*testing.T); ok { + stdt.Helper() + } + if actualError.Error() == expectedError { + return + } + t.Errorf("expected error to be `%s`, got `%s`", expectedError, actualError) + t.FailNow() + } +} diff --git a/alpha/declcfg/diff_test.go b/alpha/declcfg/diff_test.go index 850e658d8..8da56b500 100644 --- a/alpha/declcfg/diff_test.go +++ b/alpha/declcfg/diff_test.go @@ -155,6 +155,11 @@ func TestDiffLatest(t *testing.T) { Packages: []Package{ {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, + Channels: []Channel{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.1.0"}, + }}}}, + }, Bundles: []Bundle{ { Schema: schemaBundle, @@ -162,7 +167,6 @@ func TestDiffLatest(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("foo", "0.1.0"), property.MustBuildPackageRequired("bar", ">=1.0.0"), }, @@ -273,6 +277,15 @@ func TestDiffLatest(t *testing.T) { Packages: []Package{ {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, + Channels: []Channel{ + {Schema: schemaChannel, Name: "clusterwide", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.1.0-clusterwide"}, + }}}}, + {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.1.0"}, + {Name: "foo.v0.2.0", Skips: []string{"foo.v0.1.0"}}, + }}}}, + }, Bundles: []Bundle{ { Schema: schemaBundle, @@ -280,7 +293,6 @@ func TestDiffLatest(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuild(&deprecated{}), property.MustBuildPackage("foo", "0.1.0"), }, @@ -291,7 +303,6 @@ func TestDiffLatest(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("clusterwide", ""), property.MustBuildPackage("foo", "0.1.0-clusterwide"), }, }, @@ -301,9 +312,7 @@ func TestDiffLatest(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("foo", "0.2.0"), - property.MustBuildSkips("foo.v0.1.0"), }, }, }, @@ -373,6 +382,11 @@ func TestDiffLatest(t *testing.T) { Packages: []Package{ {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, + Channels: []Channel{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.1.0"}, + }}}}, + }, Bundles: []Bundle{ { Schema: schemaBundle, @@ -380,7 +394,6 @@ func TestDiffLatest(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("foo", "0.1.0"), property.MustBuildPackageRequired("etcd", ">=0.9.0"), }, @@ -442,6 +455,14 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "etcd", DefaultChannel: "stable"}, {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, + Channels: []Channel{ + {Schema: schemaChannel, Name: "stable", Package: "etcd", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "etcd.v0.9.1"}, + }}}}, + {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.1.0"}, + }}}}, + }, Bundles: []Bundle{ { Schema: schemaBundle, @@ -449,7 +470,6 @@ func TestDiffLatest(t *testing.T) { Package: "etcd", Image: "reg/etcd:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("etcd", "0.9.1"), }, }, @@ -459,7 +479,6 @@ func TestDiffLatest(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("foo", "0.1.0"), property.MustBuildPackageRequired("etcd", ">=0.9.0"), }, @@ -531,6 +550,14 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "etcd", DefaultChannel: "stable"}, {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, + Channels: []Channel{ + {Schema: schemaChannel, Name: "stable", Package: "etcd", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "etcd.v0.9.1"}, + }}}}, + {Schema: schemaChannel, Name: "clusterwide", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.1.0-clusterwide"}, + }}}}, + }, Bundles: []Bundle{ { Schema: schemaBundle, @@ -538,7 +565,6 @@ func TestDiffLatest(t *testing.T) { Package: "etcd", Image: "reg/etcd:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("etcd", "0.9.1"), }, }, @@ -548,7 +574,6 @@ func TestDiffLatest(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("clusterwide", ""), property.MustBuildPackage("foo", "0.1.0-clusterwide"), property.MustBuildPackageRequired("etcd", ">=0.9.0"), }, @@ -631,6 +656,11 @@ func TestDiffLatest(t *testing.T) { Packages: []Package{ {Schema: schemaPackage, Name: "etcd", DefaultChannel: "stable"}, }, + Channels: []Channel{ + {Schema: schemaChannel, Name: "stable", Package: "etcd", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "etcd.v0.9.2", Replaces: "etcd.v0.9.1"}, + }}}}, + }, Bundles: []Bundle{ { Schema: schemaBundle, @@ -638,7 +668,6 @@ func TestDiffLatest(t *testing.T) { Package: "etcd", Image: "reg/etcd:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", "etcd.v0.9.1"), property.MustBuildPackage("etcd", "0.9.2"), }, }, @@ -720,6 +749,16 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "etcd", DefaultChannel: "stable"}, {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, + Channels: []Channel{ + {Schema: schemaChannel, Name: "stable", Package: "etcd", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "etcd.v0.9.1"}, + {Name: "etcd.v0.9.2", Replaces: "etcd.v0.9.1"}, + }}}}, + {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.1.0"}, + {Name: "foo.v0.2.0", Replaces: "foo.v0.1.0"}, + }}}}, + }, Bundles: []Bundle{ { Schema: schemaBundle, @@ -727,7 +766,6 @@ func TestDiffLatest(t *testing.T) { Package: "etcd", Image: "reg/etcd:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("etcd", "0.9.1"), }, }, @@ -737,7 +775,6 @@ func TestDiffLatest(t *testing.T) { Package: "etcd", Image: "reg/etcd:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", "etcd.v0.9.1"), property.MustBuildPackage("etcd", "0.9.2"), }, }, @@ -747,7 +784,6 @@ func TestDiffLatest(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("foo", "0.1.0"), property.MustBuildPackageRequired("etcd", ">=0.9.0 <0.9.2"), }, @@ -758,7 +794,6 @@ func TestDiffLatest(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", "foo.v0.1.0"), property.MustBuildPackage("foo", "0.2.0"), property.MustBuildPackageRequired("etcd", ">=0.9.2"), }, @@ -821,6 +856,14 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "etcd", DefaultChannel: "stable"}, {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, + Channels: []Channel{ + {Schema: schemaChannel, Name: "stable", Package: "etcd", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "etcd.v0.9.1"}, + }}}}, + {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.1.0"}, + }}}}, + }, Bundles: []Bundle{ { Schema: schemaBundle, @@ -828,7 +871,6 @@ func TestDiffLatest(t *testing.T) { Package: "etcd", Image: "reg/etcd:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildGVK("etcd.database.coreos.com", "v1beta2", "EtcdBackup"), property.MustBuildPackage("etcd", "0.9.1"), }, @@ -839,7 +881,6 @@ func TestDiffLatest(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildGVKRequired("etcd.database.coreos.com", "v1beta2", "EtcdBackup"), property.MustBuildPackage("foo", "0.1.0"), }, @@ -910,6 +951,11 @@ func TestDiffHeadsOnly(t *testing.T) { Packages: []Package{ {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, + Channels: []Channel{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.1.0"}, + }}}}, + }, Bundles: []Bundle{ { Schema: schemaBundle, @@ -917,7 +963,6 @@ func TestDiffHeadsOnly(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("foo", "0.1.0"), }, }, @@ -1011,6 +1056,20 @@ func TestDiffHeadsOnly(t *testing.T) { {Schema: schemaPackage, Name: "etcd", DefaultChannel: "stable"}, {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, + Channels: []Channel{ + {Schema: schemaChannel, Name: "clusterwide", Package: "etcd", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "etcd.v0.9.1-clusterwide"}, + }}}}, + {Schema: schemaChannel, Name: "stable", Package: "etcd", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "etcd.v0.9.1", Replaces: "etcd.v0.9.0"}, + }}}}, + {Schema: schemaChannel, Name: "alpha", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.2.0", Replaces: "foo.v0.2.0-alpha.1"}, + }}}}, + {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.2.0", Replaces: "foo.v0.1.0"}, + }}}}, + }, Bundles: []Bundle{ { Schema: schemaBundle, @@ -1018,7 +1077,6 @@ func TestDiffHeadsOnly(t *testing.T) { Package: "etcd", Image: "reg/etcd:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", "etcd.v0.9.0"), property.MustBuildPackage("etcd", "0.9.1"), }, }, @@ -1028,7 +1086,6 @@ func TestDiffHeadsOnly(t *testing.T) { Package: "etcd", Image: "reg/etcd:latest", Properties: []property.Property{ - property.MustBuildChannel("clusterwide", ""), property.MustBuildPackage("etcd", "0.9.1-clusterwide"), }, }, @@ -1038,8 +1095,6 @@ func TestDiffHeadsOnly(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("alpha", "foo.v0.2.0-alpha.1"), - property.MustBuildChannel("stable", "foo.v0.1.0"), property.MustBuildPackage("foo", "0.2.0"), }, }, @@ -1099,6 +1154,14 @@ func TestDiffHeadsOnly(t *testing.T) { {Schema: schemaPackage, Name: "etcd", DefaultChannel: "stable"}, {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, + Channels: []Channel{ + {Schema: schemaChannel, Name: "stable", Package: "etcd", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "etcd.v0.9.2", Replaces: "etcd.v0.9.1"}, + }}}}, + {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.1.0"}, + }}}}, + }, Bundles: []Bundle{ { Schema: schemaBundle, @@ -1106,7 +1169,6 @@ func TestDiffHeadsOnly(t *testing.T) { Package: "etcd", Image: "reg/etcd:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", "etcd.v0.9.1"), property.MustBuildGVK("etcd.database.coreos.com", "v1beta2", "EtcdBackup"), property.MustBuildPackage("etcd", "0.9.2"), }, @@ -1117,7 +1179,6 @@ func TestDiffHeadsOnly(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("foo", "0.1.0"), property.MustBuildPackageRequired("etcd", "<=0.9.1"), }, diff --git a/alpha/declcfg/helpers_test.go b/alpha/declcfg/helpers_test.go index 6f3ab0ada..a4d1bdde0 100644 --- a/alpha/declcfg/helpers_test.go +++ b/alpha/declcfg/helpers_test.go @@ -15,24 +15,11 @@ import ( ) func buildValidDeclarativeConfig(includeUnrecognized bool) DeclarativeConfig { - a001 := newTestBundle("anakin", "0.0.1", - withChannel("light", ""), - withChannel("dark", ""), - ) - a010 := newTestBundle("anakin", "0.1.0", - withChannel("light", testBundleName("anakin", "0.0.1")), - withChannel("dark", testBundleName("anakin", "0.0.1")), - ) - a011 := newTestBundle("anakin", "0.1.1", - withChannel("dark", testBundleName("anakin", "0.0.1")), - withSkips(testBundleName("anakin", "0.1.0")), - ) - b1 := newTestBundle("boba-fett", "1.0.0", - withChannel("mando", ""), - ) - b2 := newTestBundle("boba-fett", "2.0.0", - withChannel("mando", testBundleName("boba-fett", "1.0.0")), - ) + a001 := newTestBundle("anakin", "0.0.1") + a010 := newTestBundle("anakin", "0.1.0") + a011 := newTestBundle("anakin", "0.1.1") + b1 := newTestBundle("boba-fett", "1.0.0") + b2 := newTestBundle("boba-fett", "2.0.0") var others []Meta if includeUnrecognized { @@ -57,6 +44,40 @@ func buildValidDeclarativeConfig(includeUnrecognized bool) DeclarativeConfig { newTestPackage("anakin", "dark", svgSmallCircle), newTestPackage("boba-fett", "mando", svgBigCircle), }, + Channels: []Channel{ + newTestChannel("anakin", "dark", + LegacyChannelEntry{ + Name: testBundleName("anakin", "0.0.1"), + }, + LegacyChannelEntry{ + Name: testBundleName("anakin", "0.1.0"), + Replaces: testBundleName("anakin", "0.0.1"), + }, + LegacyChannelEntry{ + Name: testBundleName("anakin", "0.1.1"), + Replaces: testBundleName("anakin", "0.0.1"), + Skips: []string{testBundleName("anakin", "0.1.0")}, + }, + ), + newTestChannel("anakin", "light", + LegacyChannelEntry{ + Name: testBundleName("anakin", "0.0.1"), + }, + LegacyChannelEntry{ + Name: testBundleName("anakin", "0.1.0"), + Replaces: testBundleName("anakin", "0.0.1"), + }, + ), + newTestChannel("boba-fett", "mando", + LegacyChannelEntry{ + Name: testBundleName("boba-fett", "1.0.0"), + }, + LegacyChannelEntry{ + Name: testBundleName("boba-fett", "2.0.0"), + Replaces: testBundleName("boba-fett", "1.0.0"), + }, + ), + }, Bundles: []Bundle{ a001, a010, a011, b1, b2, @@ -73,12 +94,6 @@ func withChannel(name, replaces string) func(*Bundle) { } } -func withSkips(name string) func(*Bundle) { - return func(b *Bundle) { - b.Properties = append(b.Properties, property.MustBuildSkips(name)) - } -} - func withNoProperties() func(*Bundle) { return func(b *Bundle) { b.Properties = []property.Property{} @@ -150,6 +165,15 @@ func newTestPackage(packageName, defaultChannel, svgData string) Package { return p } +func newTestChannel(packageName, channelName string, entries ...LegacyChannelEntry) Channel { + return Channel{ + Schema: schemaChannel, + Name: channelName, + Package: packageName, + Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: entries}}, + } +} + func buildTestModel() model.Model { return model.Model{ "anakin": buildAnakinPkgModel(), @@ -196,15 +220,13 @@ func buildAnakinPkgModel() *model.Package { property.MustBuildBundleObjectData([]byte(crdJson)), } for _, channel := range channels { - props = append(props, property.MustBuild(&channel)) ch := pkg.Channels[channel.Name] bName := testBundleName(pkgName, version) bImage := testBundleImage(pkgName, version) - skips := []string{} + var skips []string if version == "0.1.1" { skip := testBundleName(pkgName, "0.1.0") skips = append(skips, skip) - props = append(props, property.MustBuildSkips(skip)) } props = append(props) @@ -265,7 +287,6 @@ func buildBobaFettPkgModel() *model.Package { property.MustBuildBundleObjectData([]byte(crdJson)), } for _, channel := range channels { - props = append(props, property.MustBuild(&channel)) ch := pkg.Channels[channel.Name] bName := testBundleName(pkgName, version) bImage := testBundleImage(pkgName, version) diff --git a/alpha/declcfg/load.go b/alpha/declcfg/load.go index 0f3277138..aa601a1d6 100644 --- a/alpha/declcfg/load.go +++ b/alpha/declcfg/load.go @@ -73,6 +73,7 @@ func LoadFS(root fs.FS) (*DeclarativeConfig, error) { return err } cfg.Packages = append(cfg.Packages, fcfg.Packages...) + cfg.Channels = append(cfg.Channels, fcfg.Channels...) cfg.Bundles = append(cfg.Bundles, fcfg.Bundles...) cfg.Others = append(cfg.Others, fcfg.Others...) return nil @@ -138,6 +139,12 @@ func readYAMLOrJSON(r io.Reader) (*DeclarativeConfig, error) { return nil, fmt.Errorf("parse package: %v", err) } cfg.Packages = append(cfg.Packages, p) + case schemaChannel: + var c Channel + if err := json.Unmarshal(doc, &c); err != nil { + return nil, fmt.Errorf("parse channel: %v", err) + } + cfg.Channels = append(cfg.Channels, c) case schemaBundle: var b Bundle if err := json.Unmarshal(doc, &b); err != nil { diff --git a/alpha/declcfg/model_to_declcfg.go b/alpha/declcfg/model_to_declcfg.go index 0ec7ef321..f34fed36a 100644 --- a/alpha/declcfg/model_to_declcfg.go +++ b/alpha/declcfg/model_to_declcfg.go @@ -10,7 +10,7 @@ import ( func ConvertFromModel(mpkgs model.Model) DeclarativeConfig { cfg := DeclarativeConfig{} for _, mpkg := range mpkgs { - bundles := traverseModelChannels(*mpkg) + channels, bundles := traverseModelChannels(*mpkg) var i *Icon if mpkg.Icon != nil { @@ -30,25 +30,57 @@ func ConvertFromModel(mpkgs model.Model) DeclarativeConfig { Icon: i, Description: mpkg.Description, }) + cfg.Channels = append(cfg.Channels, channels...) cfg.Bundles = append(cfg.Bundles, bundles...) } sort.Slice(cfg.Packages, func(i, j int) bool { return cfg.Packages[i].Name < cfg.Packages[j].Name }) + sort.Slice(cfg.Channels, func(i, j int) bool { + if cfg.Channels[i].Package != cfg.Channels[j].Package { + return cfg.Channels[i].Package < cfg.Channels[j].Package + } + return cfg.Channels[i].Name < cfg.Channels[j].Name + }) sort.Slice(cfg.Bundles, func(i, j int) bool { + if cfg.Bundles[i].Package != cfg.Bundles[j].Package { + return cfg.Bundles[i].Package < cfg.Bundles[j].Package + } return cfg.Bundles[i].Name < cfg.Bundles[j].Name }) return cfg } -func traverseModelChannels(mpkg model.Package) []Bundle { - bundles := map[string]*Bundle{} +func traverseModelChannels(mpkg model.Package) ([]Channel, []Bundle) { + channels := []Channel{} + bundleMap := map[string]*Bundle{} for _, ch := range mpkg.Channels { + // initialize channel + c := Channel{ + Schema: schemaChannel, + Name: ch.Name, + Package: ch.Package.Name, + Strategy: ChannelStrategy{ + Legacy: &LegacyChannelStrategy{ + Entries: []LegacyChannelEntry{}, + }, + }, + } + for _, chb := range ch.Bundles { - b, ok := bundles[chb.Name] + // populate channel entry + c.Strategy.Legacy.Entries = append(c.Strategy.Legacy.Entries, LegacyChannelEntry{ + Name: chb.Name, + Replaces: chb.Replaces, + Skips: chb.Skips, + SkipRange: chb.SkipRange, + }) + + // create or update bundle + b, ok := bundleMap[chb.Name] if !ok { b = &Bundle{ Schema: schemaBundle, @@ -59,14 +91,26 @@ func traverseModelChannels(mpkg model.Package) []Bundle { CsvJSON: chb.CsvJSON, Objects: chb.Objects, } - bundles[b.Name] = b + bundleMap[b.Name] = b + } + for _, p := range chb.Properties { + // drop olm.channel, olm.skips, and olm.skipRange properties from the declarative config + // representation because we've already created an `olm.channel` blob containing this information. + if p.Type != property.TypeChannel && p.Type != property.TypeSkips && p.Type != property.TypeSkipRange { + b.Properties = append(b.Properties, p) + } } - b.Properties = append(b.Properties, chb.Properties...) } + + // sort channel entries by name + sort.Slice(c.Strategy.Legacy.Entries, func(i, j int) bool { + return c.Strategy.Legacy.Entries[i].Name < c.Strategy.Legacy.Entries[j].Name + }) + channels = append(channels, c) } - var out []Bundle - for _, b := range bundles { + var bundles []Bundle + for _, b := range bundleMap { b.Properties = property.Deduplicate(b.Properties) sort.Slice(b.Properties, func(i, j int) bool { @@ -76,9 +120,9 @@ func traverseModelChannels(mpkg model.Package) []Bundle { return string(b.Properties[i].Value) < string(b.Properties[j].Value) }) - out = append(out, *b) + bundles = append(bundles, *b) } - return out + return channels, bundles } func modelRelatedImagesToRelatedImages(relatedImages []model.RelatedImage) []RelatedImage { diff --git a/alpha/declcfg/write.go b/alpha/declcfg/write.go index 5df463c8f..d03e1315f 100644 --- a/alpha/declcfg/write.go +++ b/alpha/declcfg/write.go @@ -65,6 +65,12 @@ func writeToEncoder(cfg DeclarativeConfig, enc encoder) error { pkgNames.Insert(pkgName) packagesByName[pkgName] = append(packagesByName[pkgName], p) } + channelsByPackage := map[string][]Channel{} + for _, c := range cfg.Channels { + pkgName := c.Package + pkgNames.Insert(pkgName) + channelsByPackage[pkgName] = append(channelsByPackage[pkgName], c) + } bundlesByPackage := map[string][]Bundle{} for _, b := range cfg.Bundles { pkgName := b.Package @@ -89,6 +95,16 @@ func writeToEncoder(cfg DeclarativeConfig, enc encoder) error { } } + channels := channelsByPackage[pName] + sort.Slice(channels, func(i, j int) bool { + return channels[i].Name < channels[j].Name + }) + for _, c := range channels { + if err := enc.Encode(c); err != nil { + return err + } + } + bundles := bundlesByPackage[pName] sort.Slice(bundles, func(i, j int) bool { return bundles[i].Name < bundles[j].Name diff --git a/alpha/declcfg/write_test.go b/alpha/declcfg/write_test.go index 4b69bc5b0..522861323 100644 --- a/alpha/declcfg/write_test.go +++ b/alpha/declcfg/write_test.go @@ -28,6 +28,49 @@ func TestWriteJSON(t *testing.T) { }, "description": "anakin operator" } +{ + "schema": "olm.channel", + "name": "dark", + "package": "anakin", + "strategy": { + "legacy": { + "entries": [ + { + "name": "anakin.v0.0.1" + }, + { + "name": "anakin.v0.1.0", + "replaces": "anakin.v0.0.1" + }, + { + "name": "anakin.v0.1.1", + "replaces": "anakin.v0.0.1", + "skips": [ + "anakin.v0.1.0" + ] + } + ] + } + } +} +{ + "schema": "olm.channel", + "name": "light", + "package": "anakin", + "strategy": { + "legacy": { + "entries": [ + { + "name": "anakin.v0.0.1" + }, + { + "name": "anakin.v0.1.0", + "replaces": "anakin.v0.0.1" + } + ] + } + } +} { "schema": "olm.bundle", "name": "anakin.v0.0.1", @@ -46,18 +89,6 @@ func TestWriteJSON(t *testing.T) { "ref": "objects/anakin.v0.0.1.csv.yaml" } }, - { - "type": "olm.channel", - "value": { - "name": "dark" - } - }, - { - "type": "olm.channel", - "value": { - "name": "light" - } - }, { "type": "olm.package", "value": { @@ -91,20 +122,6 @@ func TestWriteJSON(t *testing.T) { "ref": "objects/anakin.v0.1.0.csv.yaml" } }, - { - "type": "olm.channel", - "value": { - "name": "dark", - "replaces": "anakin.v0.0.1" - } - }, - { - "type": "olm.channel", - "value": { - "name": "light", - "replaces": "anakin.v0.0.1" - } - }, { "type": "olm.package", "value": { @@ -138,23 +155,12 @@ func TestWriteJSON(t *testing.T) { "ref": "objects/anakin.v0.1.1.csv.yaml" } }, - { - "type": "olm.channel", - "value": { - "name": "dark", - "replaces": "anakin.v0.0.1" - } - }, { "type": "olm.package", "value": { "packageName": "anakin", "version": "0.1.1" } - }, - { - "type": "olm.skips", - "value": "anakin.v0.1.0" } ], "relatedImages": [ @@ -179,6 +185,24 @@ func TestWriteJSON(t *testing.T) { }, "description": "boba-fett operator" } +{ + "schema": "olm.channel", + "name": "mando", + "package": "boba-fett", + "strategy": { + "legacy": { + "entries": [ + { + "name": "boba-fett.v1.0.0" + }, + { + "name": "boba-fett.v2.0.0", + "replaces": "boba-fett.v1.0.0" + } + ] + } + } +} { "schema": "olm.bundle", "name": "boba-fett.v1.0.0", @@ -197,12 +221,6 @@ func TestWriteJSON(t *testing.T) { "ref": "objects/boba-fett.v1.0.0.csv.yaml" } }, - { - "type": "olm.channel", - "value": { - "name": "mando" - } - }, { "type": "olm.package", "value": { @@ -236,13 +254,6 @@ func TestWriteJSON(t *testing.T) { "ref": "objects/boba-fett.v2.0.0.csv.yaml" } }, - { - "type": "olm.channel", - "value": { - "name": "mando", - "replaces": "boba-fett.v1.0.0" - } - }, { "type": "olm.package", "value": { @@ -301,6 +312,30 @@ icon: name: anakin schema: olm.package --- +name: dark +package: anakin +schema: olm.channel +strategy: + legacy: + entries: + - name: anakin.v0.0.1 + - name: anakin.v0.1.0 + replaces: anakin.v0.0.1 + - name: anakin.v0.1.1 + replaces: anakin.v0.0.1 + skips: + - anakin.v0.1.0 +--- +name: light +package: anakin +schema: olm.channel +strategy: + legacy: + entries: + - name: anakin.v0.0.1 + - name: anakin.v0.1.0 + replaces: anakin.v0.0.1 +--- image: anakin-bundle:v0.0.1 name: anakin.v0.0.1 package: anakin @@ -311,12 +346,6 @@ properties: - type: olm.bundle.object value: ref: objects/anakin.v0.0.1.csv.yaml -- type: olm.channel - value: - name: dark -- type: olm.channel - value: - name: light - type: olm.package value: packageName: anakin @@ -336,14 +365,6 @@ properties: - type: olm.bundle.object value: ref: objects/anakin.v0.1.0.csv.yaml -- type: olm.channel - value: - name: dark - replaces: anakin.v0.0.1 -- type: olm.channel - value: - name: light - replaces: anakin.v0.0.1 - type: olm.package value: packageName: anakin @@ -363,16 +384,10 @@ properties: - type: olm.bundle.object value: ref: objects/anakin.v0.1.1.csv.yaml -- type: olm.channel - value: - name: dark - replaces: anakin.v0.0.1 - type: olm.package value: packageName: anakin version: 0.1.1 -- type: olm.skips - value: anakin.v0.1.0 relatedImages: - image: anakin-bundle:v0.1.1 name: bundle @@ -390,6 +405,16 @@ icon: name: boba-fett schema: olm.package --- +name: mando +package: boba-fett +schema: olm.channel +strategy: + legacy: + entries: + - name: boba-fett.v1.0.0 + - name: boba-fett.v2.0.0 + replaces: boba-fett.v1.0.0 +--- image: boba-fett-bundle:v1.0.0 name: boba-fett.v1.0.0 package: boba-fett @@ -400,9 +425,6 @@ properties: - type: olm.bundle.object value: ref: objects/boba-fett.v1.0.0.csv.yaml -- type: olm.channel - value: - name: mando - type: olm.package value: packageName: boba-fett @@ -422,10 +444,6 @@ properties: - type: olm.bundle.object value: ref: objects/boba-fett.v2.0.0.csv.yaml -- type: olm.channel - value: - name: mando - replaces: boba-fett.v1.0.0 - type: olm.package value: packageName: boba-fett diff --git a/alpha/model/model.go b/alpha/model/model.go index e627df8c3..babcd08cc 100644 --- a/alpha/model/model.go +++ b/alpha/model/model.go @@ -256,6 +256,7 @@ type Bundle struct { Image string Replaces string Skips []string + SkipRange string Properties []property.Property RelatedImages []RelatedImage diff --git a/alpha/model/model_test.go b/alpha/model/model_test.go index 463ee6173..e9da20821 100644 --- a/alpha/model/model_test.go +++ b/alpha/model/model_test.go @@ -192,7 +192,7 @@ func hasError(expectedError string) require.ErrorAssertionFunc { return } } - t.Errorf("expected error to be or contain suberror %q, got %v", expectedError, actualError) + t.Errorf("expected error to be or contain suberror `%s`, got `%s`", expectedError, actualError) t.FailNow() } } diff --git a/pkg/api/api_to_model.go b/pkg/api/api_to_model.go index 1e64c1fff..d203f40b4 100644 --- a/pkg/api/api_to_model.go +++ b/pkg/api/api_to_model.go @@ -25,6 +25,7 @@ func ConvertAPIBundleToModelBundle(b *Bundle) (*model.Bundle, error) { Image: b.BundlePath, Replaces: b.Replaces, Skips: b.Skips, + SkipRange: b.SkipRange, CsvJSON: b.CsvJson, Objects: b.Object, Properties: bundleProps, @@ -35,16 +36,6 @@ func ConvertAPIBundleToModelBundle(b *Bundle) (*model.Bundle, error) { func convertAPIBundleToModelProperties(b *Bundle) ([]property.Property, error) { var out []property.Property - for _, skip := range b.Skips { - out = append(out, property.MustBuildSkips(skip)) - } - - if b.SkipRange != "" { - out = append(out, property.MustBuildSkipRange(b.SkipRange)) - } - - out = append(out, property.MustBuildChannel(b.ChannelName, b.Replaces)) - providedGVKs := map[property.GVK]struct{}{} requiredGVKs := map[property.GVKRequired]struct{}{} diff --git a/pkg/api/conversion_test.go b/pkg/api/conversion_test.go index d5fef5154..0a332b91a 100644 --- a/pkg/api/conversion_test.go +++ b/pkg/api/conversion_test.go @@ -25,7 +25,6 @@ func TestConvertModelBundleToAPIBundle(t *testing.T) { modelBundle.Channel = &model.Channel{Name: "singlenamespace-alpha"} expected := testAPIBundle() expected.Properties = append(expected.Properties, - &Property{Type: "olm.channel", Value: "{\"name\":\"singlenamespace-alpha\",\"replaces\":\"etcdoperator.v0.9.2\"}"}, &Property{Type: "olm.package.required", Value: "{\"packageName\":\"test\",\"versionRange\":\">=1.2.3 <2.0.0-0\"}"}, &Property{Type: "olm.gvk.required", Value: "{\"group\":\"testapi.coreos.com\",\"kind\":\"Testapi\",\"version\":\"v1\"}"}, ) @@ -49,7 +48,6 @@ func testModelBundle() model.Bundle { Replaces: "etcdoperator.v0.9.2", Skips: nil, Properties: []property.Property{ - property.MustBuildChannel("singlenamespace-alpha", "etcdoperator.v0.9.2"), property.MustBuildPackage("etcd", "0.9.4"), property.MustBuildPackageRequired("test", ">=1.2.3 <2.0.0-0"), property.MustBuildGVKRequired("testapi.coreos.com", "v1", "Testapi"), diff --git a/pkg/api/model_to_api.go b/pkg/api/model_to_api.go index 1175c30b8..26f8b745c 100644 --- a/pkg/api/model_to_api.go +++ b/pkg/api/model_to_api.go @@ -13,10 +13,6 @@ func ConvertModelBundleToAPIBundle(b model.Bundle) (*Bundle, error) { if err != nil { return nil, fmt.Errorf("parse properties: %v", err) } - skipRange := "" - if len(props.SkipRanges) > 0 { - skipRange = string(props.SkipRanges[0]) - } apiDeps, err := convertModelPropertiesToAPIDependencies(b.Properties) if err != nil { @@ -30,7 +26,7 @@ func ConvertModelBundleToAPIBundle(b model.Bundle) (*Bundle, error) { ProvidedApis: gvksProvidedtoAPIGVKs(props.GVKs), RequiredApis: gvksRequirestoAPIGVKs(props.GVKsRequired), Version: props.Packages[0].Version, - SkipRange: skipRange, + SkipRange: b.SkipRange, Dependencies: apiDeps, Properties: convertModelPropertiesToAPIProperties(b.Properties), Replaces: b.Replaces, @@ -50,10 +46,6 @@ func parseProperties(in []property.Property) (*property.Properties, error) { return nil, fmt.Errorf("expected exactly 1 property of type %q, found %d", property.TypePackage, len(props.Packages)) } - if len(props.SkipRanges) > 1 { - return nil, fmt.Errorf("multiple properties of type %q not allowed", property.TypeSkipRange) - } - return props, nil } diff --git a/pkg/server/server_test.go b/pkg/server/server_test.go index f79725165..9fba96a57 100644 --- a/pkg/server/server_test.go +++ b/pkg/server/server_test.go @@ -1,7 +1,6 @@ package server import ( - "fmt" "io" "io/ioutil" "net" @@ -743,9 +742,6 @@ func etcdoperator_v0_9_2(channel string, addSkipsReplaces, addExtraProperties bo } if addExtraProperties { b.Properties = append(b.Properties, []*api.Property{ - {Type: "olm.skipRange", Value: `"< 0.6.0"`}, - {Type: "olm.skips", Value: `"etcdoperator.v0.9.1"`}, - {Type: "olm.channel", Value: fmt.Sprintf(`{"name":%q,"replaces":"etcdoperator.v0.9.0"}`, channel)}, {Type: "olm.gvk.required", Value: `{"group":"etcd.database.coreos.com","kind":"EtcdCluster","version":"v1beta2"}`}, }...) } diff --git a/pkg/sqlite/conversion.go b/pkg/sqlite/conversion.go index 7c3d9d92f..e94d052cf 100644 --- a/pkg/sqlite/conversion.go +++ b/pkg/sqlite/conversion.go @@ -51,10 +51,10 @@ func initializeModelPackages(ctx context.Context, q *SQLQuerier) (model.Model, e pkgs := model.Model{} for _, rPkg := range rPkgs { pkg := model.Package{ - Name: rPkg.PackageName, + Name: rPkg.PackageName, + Channels: map[string]*model.Channel{}, } - pkg.Channels = map[string]*model.Channel{} for _, ch := range rPkg.Channels { channel := &model.Channel{ Package: &pkg, From 297a149e2a3229f6ed05742adaf3191a8aee2e9d Mon Sep 17 00:00:00 2001 From: Joe Lanford Date: Mon, 30 Aug 2021 14:06:03 -0400 Subject: [PATCH 2/5] render: don't render upgrade edge properties in bundles Signed-off-by: Joe Lanford --- alpha/action/render_test.go | 5 ----- pkg/registry/registry_to_model.go | 29 ----------------------------- 2 files changed, 34 deletions(-) diff --git a/alpha/action/render_test.go b/alpha/action/render_test.go index 743ce8015..08de7faeb 100644 --- a/alpha/action/render_test.go +++ b/alpha/action/render_test.go @@ -437,15 +437,10 @@ func TestRender(t *testing.T) { Package: "foo", Image: "test.registry/foo-operator/foo-bundle:v0.2.0", Properties: []property.Property{ - property.MustBuildChannel("beta", "foo.v0.1.0"), - property.MustBuildChannel("stable", "foo.v0.1.0"), property.MustBuildGVK("test.foo", "v1", "Foo"), property.MustBuildGVKRequired("test.bar", "v1alpha1", "Bar"), property.MustBuildPackage("foo", "0.2.0"), property.MustBuildPackageRequired("bar", "<0.1.0"), - property.MustBuildSkipRange("<0.2.0"), - property.MustBuildSkips("foo.v0.1.1"), - property.MustBuildSkips("foo.v0.1.2"), }, RelatedImages: []declcfg.RelatedImage{ { diff --git a/pkg/registry/registry_to_model.go b/pkg/registry/registry_to_model.go index f96a5239a..2deba2c15 100644 --- a/pkg/registry/registry_to_model.go +++ b/pkg/registry/registry_to_model.go @@ -88,34 +88,6 @@ func registryBundleToModelBundle(b *Bundle) (*model.Bundle, error) { } func PropertiesFromBundle(b *Bundle) ([]property.Property, error) { - csv, err := b.ClusterServiceVersion() - if err != nil { - return nil, fmt.Errorf("get csv: %v", err) - } - - skips, err := csv.GetSkips() - if err != nil { - return nil, fmt.Errorf("get csv skips: %v", err) - } - - var graphProps []property.Property - replaces, err := csv.GetReplaces() - if err != nil { - return nil, fmt.Errorf("get csv replaces: %v", err) - } - for _, ch := range b.Channels { - graphProps = append(graphProps, property.MustBuildChannel(ch, replaces)) - } - - for _, skip := range skips { - graphProps = append(graphProps, property.MustBuildSkips(skip)) - } - - skipRange := csv.GetSkipRange() - if skipRange != "" { - graphProps = append(graphProps, property.MustBuildSkipRange(skipRange)) - } - providedGVKs := map[property.GVK]struct{}{} requiredGVKs := map[property.GVKRequired]struct{}{} @@ -198,7 +170,6 @@ func PropertiesFromBundle(b *Bundle) ([]property.Property, error) { packageProvidedProperty = &p } out = append(out, *packageProvidedProperty) - out = append(out, graphProps...) for p := range providedGVKs { out = append(out, property.MustBuildGVK(p.Group, p.Version, p.Kind)) From 00cb8d491ca1d4bdfc6fab89d9d4d8b30255a5f1 Mon Sep 17 00:00:00 2001 From: Joe Lanford Date: Wed, 1 Sep 2021 14:59:52 -0400 Subject: [PATCH 3/5] remove channel-related properties from bundles Signed-off-by: Joe Lanford --- alpha/action/list.go | 22 +- alpha/action/render_test.go | 32 +-- .../foo/index.yaml | 95 -------- .../foo-index-v0.2.0-declcfg/foo/index.yaml | 48 ++-- .../index-declcfgs/exp-latest/index.yaml | 26 -- .../testdata/index-declcfgs/latest/index.yaml | 120 ++++----- .../testdata/index-declcfgs/old/index.yaml | 85 +++---- .../action/testdata/list-index/bar/index.yaml | 47 ++-- .../action/testdata/list-index/foo/index.yaml | 47 ++-- alpha/declcfg/declcfg_to_model.go | 97 ++------ alpha/declcfg/declcfg_to_model_test.go | 78 ++---- alpha/declcfg/diff_test.go | 227 ++++++++++++++---- alpha/declcfg/helpers_test.go | 159 +++++------- alpha/declcfg/model_to_declcfg.go | 8 +- alpha/declcfg/model_to_declcfg_test.go | 1 + alpha/declcfg/properties.go | 32 --- alpha/declcfg/properties_test.go | 73 ------ alpha/model/model_test.go | 26 +- alpha/property/property.go | 43 ---- alpha/property/property_test.go | 107 +-------- alpha/property/scheme.go | 6 - pkg/lib/indexer/index.Dockerfile047416381 | 0 pkg/lib/indexer/index.Dockerfile062873339 | 0 pkg/lib/indexer/index.Dockerfile622193597 | 0 pkg/registry/query_test.go | 156 ++++++------ pkg/registry/registry_to_model_test.go | 3 - 26 files changed, 560 insertions(+), 978 deletions(-) delete mode 100644 alpha/action/testdata/foo-index-v0.2.0-declcfg-with-channel/foo/index.yaml delete mode 100644 alpha/declcfg/properties.go delete mode 100644 alpha/declcfg/properties_test.go create mode 100644 pkg/lib/indexer/index.Dockerfile047416381 create mode 100644 pkg/lib/indexer/index.Dockerfile062873339 create mode 100644 pkg/lib/indexer/index.Dockerfile622193597 diff --git a/alpha/action/list.go b/alpha/action/list.go index 9560c6554..4c67dc628 100644 --- a/alpha/action/list.go +++ b/alpha/action/list.go @@ -14,7 +14,6 @@ import ( "github.com/operator-framework/operator-registry/alpha/declcfg" "github.com/operator-framework/operator-registry/alpha/model" - "github.com/operator-framework/operator-registry/alpha/property" ) type ListPackages struct { @@ -173,32 +172,13 @@ func (r *ListBundlesResult) WriteColumns(w io.Writer) error { return err } for _, b := range r.Bundles { - skipRange, err := getSkipRange(b) - if err != nil { - return fmt.Errorf("get skipRange for bundle %q: %v", b.Name, err) - } - if _, err := fmt.Fprintf(tw, "%s\t%s\t%s\t%s\t%s\t%s\t%s\n", b.Package.Name, b.Channel.Name, b.Name, b.Replaces, strings.Join(b.Skips, ","), skipRange, b.Image); err != nil { + if _, err := fmt.Fprintf(tw, "%s\t%s\t%s\t%s\t%s\t%s\t%s\n", b.Package.Name, b.Channel.Name, b.Name, b.Replaces, strings.Join(b.Skips, ","), b.SkipRange, b.Image); err != nil { return err } - } return tw.Flush() } -func getSkipRange(b model.Bundle) (string, error) { - props, err := property.Parse(b.Properties) - if err != nil { - return "", err - } - if len(props.SkipRanges) > 1 { - return "", fmt.Errorf("multiple skip ranges not supported") - } - if len(props.SkipRanges) == 0 { - return "", nil - } - return string(props.SkipRanges[0]), nil -} - func indexRefToModel(ctx context.Context, ref string) (model.Model, error) { render := Render{ Refs: []string{ref}, diff --git a/alpha/action/render_test.go b/alpha/action/render_test.go index 08de7faeb..b908b8d21 100644 --- a/alpha/action/render_test.go +++ b/alpha/action/render_test.go @@ -259,6 +259,15 @@ func TestRender(t *testing.T) { DefaultChannel: "beta", }, }, + Channels: []declcfg.Channel{ + {Schema: "olm.channel", Package: "foo", Name: "beta", Strategy: declcfg.ChannelStrategy{Legacy: &declcfg.LegacyChannelStrategy{Entries: []declcfg.LegacyChannelEntry{ + {Name: "foo.v0.1.0", SkipRange: "<0.1.0"}, + {Name: "foo.v0.2.0", Replaces: "foo.v0.1.0", SkipRange: "<0.2.0", Skips: []string{"foo.v0.1.1", "foo.v0.1.2"}}, + }}}}, + {Schema: "olm.channel", Package: "foo", Name: "stable", Strategy: declcfg.ChannelStrategy{Legacy: &declcfg.LegacyChannelStrategy{Entries: []declcfg.LegacyChannelEntry{ + {Name: "foo.v0.2.0", Replaces: "foo.v0.1.0", SkipRange: "<0.2.0", Skips: []string{"foo.v0.1.1", "foo.v0.1.2"}}, + }}}}, + }, Bundles: []declcfg.Bundle{ { Schema: "olm.bundle", @@ -266,12 +275,10 @@ func TestRender(t *testing.T) { Package: "foo", Image: "test.registry/foo-operator/foo-bundle:v0.1.0", Properties: []property.Property{ - property.MustBuildChannel("beta", ""), property.MustBuildGVK("test.foo", "v1", "Foo"), property.MustBuildGVKRequired("test.bar", "v1alpha1", "Bar"), property.MustBuildPackage("foo", "0.1.0"), property.MustBuildPackageRequired("bar", "<0.1.0"), - property.MustBuildSkipRange("<0.1.0"), property.MustBuildBundleObjectData(foov1csv), property.MustBuildBundleObjectData(foov1crd), }, @@ -293,15 +300,10 @@ func TestRender(t *testing.T) { Package: "foo", Image: "test.registry/foo-operator/foo-bundle:v0.2.0", Properties: []property.Property{ - property.MustBuildChannel("beta", "foo.v0.1.0"), - property.MustBuildChannel("stable", "foo.v0.1.0"), property.MustBuildGVK("test.foo", "v1", "Foo"), property.MustBuildGVKRequired("test.bar", "v1alpha1", "Bar"), property.MustBuildPackage("foo", "0.2.0"), property.MustBuildPackageRequired("bar", "<0.1.0"), - property.MustBuildSkipRange("<0.2.0"), - property.MustBuildSkips("foo.v0.1.1"), - property.MustBuildSkips("foo.v0.1.2"), property.MustBuildBundleObjectData(foov2csv), property.MustBuildBundleObjectData(foov2crd), }, @@ -348,6 +350,15 @@ func TestRender(t *testing.T) { DefaultChannel: "beta", }, }, + Channels: []declcfg.Channel{ + {Schema: "olm.channel", Package: "foo", Name: "beta", Strategy: declcfg.ChannelStrategy{Legacy: &declcfg.LegacyChannelStrategy{Entries: []declcfg.LegacyChannelEntry{ + {Name: "foo.v0.1.0", SkipRange: "<0.1.0"}, + {Name: "foo.v0.2.0", Replaces: "foo.v0.1.0", SkipRange: "<0.2.0", Skips: []string{"foo.v0.1.1", "foo.v0.1.2"}}, + }}}}, + {Schema: "olm.channel", Package: "foo", Name: "stable", Strategy: declcfg.ChannelStrategy{Legacy: &declcfg.LegacyChannelStrategy{Entries: []declcfg.LegacyChannelEntry{ + {Name: "foo.v0.2.0", Replaces: "foo.v0.1.0", SkipRange: "<0.2.0", Skips: []string{"foo.v0.1.1", "foo.v0.1.2"}}, + }}}}, + }, Bundles: []declcfg.Bundle{ { Schema: "olm.bundle", @@ -355,12 +366,10 @@ func TestRender(t *testing.T) { Package: "foo", Image: "test.registry/foo-operator/foo-bundle:v0.1.0", Properties: []property.Property{ - property.MustBuildChannel("beta", ""), property.MustBuildGVK("test.foo", "v1", "Foo"), property.MustBuildGVKRequired("test.bar", "v1alpha1", "Bar"), property.MustBuildPackage("foo", "0.1.0"), property.MustBuildPackageRequired("bar", "<0.1.0"), - property.MustBuildSkipRange("<0.1.0"), property.MustBuildBundleObjectData(foov1csv), property.MustBuildBundleObjectData(foov1crd), }, @@ -382,15 +391,10 @@ func TestRender(t *testing.T) { Package: "foo", Image: "test.registry/foo-operator/foo-bundle:v0.2.0", Properties: []property.Property{ - property.MustBuildChannel("beta", "foo.v0.1.0"), - property.MustBuildChannel("stable", "foo.v0.1.0"), property.MustBuildGVK("test.foo", "v1", "Foo"), property.MustBuildGVKRequired("test.bar", "v1alpha1", "Bar"), property.MustBuildPackage("foo", "0.2.0"), property.MustBuildPackageRequired("bar", "<0.1.0"), - property.MustBuildSkipRange("<0.2.0"), - property.MustBuildSkips("foo.v0.1.1"), - property.MustBuildSkips("foo.v0.1.2"), property.MustBuildBundleObjectData(foov2csv), property.MustBuildBundleObjectData(foov2crd), }, diff --git a/alpha/action/testdata/foo-index-v0.2.0-declcfg-with-channel/foo/index.yaml b/alpha/action/testdata/foo-index-v0.2.0-declcfg-with-channel/foo/index.yaml deleted file mode 100644 index fddc55bca..000000000 --- a/alpha/action/testdata/foo-index-v0.2.0-declcfg-with-channel/foo/index.yaml +++ /dev/null @@ -1,95 +0,0 @@ ---- -schema: olm.package -name: foo -defaultChannel: beta ---- -schema: olm.channel -name: beta -package: foo -strategy: - legacy: - entries: - - name: foo.v0.1.0 - skipRange: <0.1.0 - - name: foo.v0.2.0 - replaces: foo.v0.1.0 - skips: - - foo.v0.1.1 - - foo.v0.1.2 - skipRange: <0.2.0 ---- -schema: olm.channel -name: stable -package: foo -strategy: - legacy: - entries: - - name: foo.v0.2.0 ---- -schema: olm.bundle -package: foo -name: foo.v0.1.0 -image: test.registry/foo-operator/foo-bundle:v0.1.0 -properties: - - type: olm.gvk - value: - group: test.foo - kind: Foo - version: v1 - - type: olm.gvk.required - value: - group: test.bar - kind: Bar - version: v1alpha1 - - type: olm.package - value: - packageName: foo - version: 0.1.0 - - type: olm.package.required - value: - packageName: bar - versionRange: <0.1.0 - - type: olm.bundle.object - value: - data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsiYW5ub3RhdGlvbnMiOnsib2xtLnNraXBSYW5nZSI6Ilx1MDAzYzAuMS4wIn0sIm5hbWUiOiJmb28udjAuMS4wIn0sInNwZWMiOnsiY3VzdG9tcmVzb3VyY2VkZWZpbml0aW9ucyI6eyJvd25lZCI6W3siZ3JvdXAiOiJ0ZXN0LmZvbyIsImtpbmQiOiJGb28iLCJuYW1lIjoiZm9vcy50ZXN0LmZvbyIsInZlcnNpb24iOiJ2MSJ9XX0sImRpc3BsYXlOYW1lIjoiRm9vIE9wZXJhdG9yIiwicmVsYXRlZEltYWdlcyI6W3siaW1hZ2UiOiJ0ZXN0LnJlZ2lzdHJ5L2Zvby1vcGVyYXRvci9mb286djAuMS4wIiwibmFtZSI6Im9wZXJhdG9yIn1dLCJ2ZXJzaW9uIjoiMC4xLjAifX0= - - type: olm.bundle.object - value: - data: eyJhcGlWZXJzaW9uIjoiYXBpZXh0ZW5zaW9ucy5rOHMuaW8vdjEiLCJraW5kIjoiQ3VzdG9tUmVzb3VyY2VEZWZpbml0aW9uIiwibWV0YWRhdGEiOnsibmFtZSI6ImZvb3MudGVzdC5mb28ifSwic3BlYyI6eyJncm91cCI6InRlc3QuZm9vIiwibmFtZXMiOnsia2luZCI6IkZvbyIsInBsdXJhbCI6ImZvb3MifSwidmVyc2lvbnMiOlt7Im5hbWUiOiJ2MSJ9XX19 -relatedImages: - - image: test.registry/foo-operator/foo:v0.1.0 - name: operator - - image: test.registry/foo-operator/foo-bundle:v0.1.0 ---- -schema: olm.bundle -package: foo -name: foo.v0.2.0 -image: test.registry/foo-operator/foo-bundle:v0.2.0 -properties: - - type: olm.gvk - value: - group: test.foo - kind: Foo - version: v1 - - type: olm.gvk.required - value: - group: test.bar - kind: Bar - version: v1alpha1 - - type: olm.package - value: - packageName: foo - version: 0.2.0 - - type: olm.package.required - value: - packageName: bar - versionRange: <0.1.0 - - type: olm.bundle.object - value: - data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsiYW5ub3RhdGlvbnMiOnsib2xtLnNraXBSYW5nZSI6Ilx1MDAzYzAuMi4wIn0sIm5hbWUiOiJmb28udjAuMi4wIn0sInNwZWMiOnsiY3VzdG9tcmVzb3VyY2VkZWZpbml0aW9ucyI6eyJvd25lZCI6W3siZ3JvdXAiOiJ0ZXN0LmZvbyIsImtpbmQiOiJGb28iLCJuYW1lIjoiZm9vcy50ZXN0LmZvbyIsInZlcnNpb24iOiJ2MSJ9XX0sImRpc3BsYXlOYW1lIjoiRm9vIE9wZXJhdG9yIiwicmVsYXRlZEltYWdlcyI6W3siaW1hZ2UiOiJ0ZXN0LnJlZ2lzdHJ5L2Zvby1vcGVyYXRvci9mb286djAuMi4wIiwibmFtZSI6Im9wZXJhdG9yIn1dLCJyZXBsYWNlcyI6ImZvby52MC4xLjAiLCJza2lwcyI6WyJmb28udjAuMS4xIiwiZm9vLnYwLjEuMiJdLCJ2ZXJzaW9uIjoiMC4yLjAifX0= - - type: olm.bundle.object - value: - data: eyJhcGlWZXJzaW9uIjoiYXBpZXh0ZW5zaW9ucy5rOHMuaW8vdjEiLCJraW5kIjoiQ3VzdG9tUmVzb3VyY2VEZWZpbml0aW9uIiwibWV0YWRhdGEiOnsibmFtZSI6ImZvb3MudGVzdC5mb28ifSwic3BlYyI6eyJncm91cCI6InRlc3QuZm9vIiwibmFtZXMiOnsia2luZCI6IkZvbyIsInBsdXJhbCI6ImZvb3MifSwidmVyc2lvbnMiOlt7Im5hbWUiOiJ2MSJ9XX19 -relatedImages: - - image: test.registry/foo-operator/foo:v0.2.0 - name: operator - - image: test.registry/foo-operator/foo-bundle:v0.2.0 diff --git a/alpha/action/testdata/foo-index-v0.2.0-declcfg/foo/index.yaml b/alpha/action/testdata/foo-index-v0.2.0-declcfg/foo/index.yaml index 50c028e4c..75cb7a932 100644 --- a/alpha/action/testdata/foo-index-v0.2.0-declcfg/foo/index.yaml +++ b/alpha/action/testdata/foo-index-v0.2.0-declcfg/foo/index.yaml @@ -2,15 +2,41 @@ schema: olm.package name: foo defaultChannel: beta +--- +schema: olm.channel +package: foo +name: beta +strategy: + legacy: + entries: + - name: foo.v0.1.0 + skipRange: <0.1.0 + - name: foo.v0.2.0 + replaces: foo.v0.1.0 + skipRange: <0.2.0 + skips: + - foo.v0.1.1 + - foo.v0.1.2 +--- +schema: olm.channel +package: foo +name: stable +strategy: + legacy: + entries: + - name: foo.v0.2.0 + replaces: foo.v0.1.0 + skipRange: <0.2.0 + skips: + - foo.v0.1.1 + - foo.v0.1.2 + --- schema: olm.bundle package: foo name: foo.v0.1.0 image: test.registry/foo-operator/foo-bundle:v0.1.0 properties: - - type: olm.channel - value: - name: beta - type: olm.gvk value: group: test.foo @@ -29,8 +55,6 @@ properties: value: packageName: bar versionRange: <0.1.0 - - type: olm.skipRange - value: <0.1.0 - type: olm.bundle.object value: data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsiYW5ub3RhdGlvbnMiOnsib2xtLnNraXBSYW5nZSI6Ilx1MDAzYzAuMS4wIn0sIm5hbWUiOiJmb28udjAuMS4wIn0sInNwZWMiOnsiY3VzdG9tcmVzb3VyY2VkZWZpbml0aW9ucyI6eyJvd25lZCI6W3siZ3JvdXAiOiJ0ZXN0LmZvbyIsImtpbmQiOiJGb28iLCJuYW1lIjoiZm9vcy50ZXN0LmZvbyIsInZlcnNpb24iOiJ2MSJ9XX0sImRpc3BsYXlOYW1lIjoiRm9vIE9wZXJhdG9yIiwicmVsYXRlZEltYWdlcyI6W3siaW1hZ2UiOiJ0ZXN0LnJlZ2lzdHJ5L2Zvby1vcGVyYXRvci9mb286djAuMS4wIiwibmFtZSI6Im9wZXJhdG9yIn1dLCJ2ZXJzaW9uIjoiMC4xLjAifX0= @@ -47,14 +71,6 @@ package: foo name: foo.v0.2.0 image: test.registry/foo-operator/foo-bundle:v0.2.0 properties: - - type: olm.channel - value: - name: beta - replaces: foo.v0.1.0 - - type: olm.channel - value: - name: stable - replaces: foo.v0.1.0 - type: olm.gvk value: group: test.foo @@ -73,12 +89,6 @@ properties: value: packageName: bar versionRange: <0.1.0 - - type: olm.skipRange - value: <0.2.0 - - type: olm.skips - value: foo.v0.1.1 - - type: olm.skips - value: foo.v0.1.2 - type: olm.bundle.object value: data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsiYW5ub3RhdGlvbnMiOnsib2xtLnNraXBSYW5nZSI6Ilx1MDAzYzAuMi4wIn0sIm5hbWUiOiJmb28udjAuMi4wIn0sInNwZWMiOnsiY3VzdG9tcmVzb3VyY2VkZWZpbml0aW9ucyI6eyJvd25lZCI6W3siZ3JvdXAiOiJ0ZXN0LmZvbyIsImtpbmQiOiJGb28iLCJuYW1lIjoiZm9vcy50ZXN0LmZvbyIsInZlcnNpb24iOiJ2MSJ9XX0sImRpc3BsYXlOYW1lIjoiRm9vIE9wZXJhdG9yIiwiaW5zdGFsbCI6eyJzcGVjIjp7ImRlcGxveW1lbnRzIjpbeyJuYW1lIjoiZm9vLW9wZXJhdG9yIiwic3BlYyI6eyJ0ZW1wbGF0ZSI6eyJzcGVjIjp7ImNvbnRhaW5lcnMiOlt7ImltYWdlIjoidGVzdC5yZWdpc3RyeS9mb28tb3BlcmF0b3IvZm9vOnYwLjIuMCJ9XSwiaW5pdENvbnRhaW5lcnMiOlt7ImltYWdlIjoidGVzdC5yZWdpc3RyeS9mb28tb3BlcmF0b3IvZm9vLWluaXQ6djAuMi4wIn1dfX19fSx7Im5hbWUiOiJmb28tb3BlcmF0b3ItMiIsInNwZWMiOnsidGVtcGxhdGUiOnsic3BlYyI6eyJjb250YWluZXJzIjpbeyJpbWFnZSI6InRlc3QucmVnaXN0cnkvZm9vLW9wZXJhdG9yL2Zvby0yOnYwLjIuMCJ9XSwiaW5pdENvbnRhaW5lcnMiOlt7ImltYWdlIjoidGVzdC5yZWdpc3RyeS9mb28tb3BlcmF0b3IvZm9vLWluaXQtMjp2MC4yLjAifV19fX19XX0sInN0cmF0ZWd5IjoiZGVwbG95bWVudCJ9LCJyZWxhdGVkSW1hZ2VzIjpbeyJpbWFnZSI6InRlc3QucmVnaXN0cnkvZm9vLW9wZXJhdG9yL2Zvbzp2MC4yLjAiLCJuYW1lIjoib3BlcmF0b3IifSx7ImltYWdlIjoidGVzdC5yZWdpc3RyeS9mb28tb3BlcmF0b3IvZm9vLW90aGVyOnYwLjIuMCIsIm5hbWUiOiJvdGhlciJ9XSwicmVwbGFjZXMiOiJmb28udjAuMS4wIiwic2tpcHMiOlsiZm9vLnYwLjEuMSIsImZvby52MC4xLjIiXSwidmVyc2lvbiI6IjAuMi4wIn19 diff --git a/alpha/action/testdata/index-declcfgs/exp-latest/index.yaml b/alpha/action/testdata/index-declcfgs/exp-latest/index.yaml index 4b53f3688..9a92d816d 100644 --- a/alpha/action/testdata/index-declcfgs/exp-latest/index.yaml +++ b/alpha/action/testdata/index-declcfgs/exp-latest/index.yaml @@ -59,37 +59,11 @@ schema: olm.channel strategy: legacy: entries: - - name: baz.v1.0.1 - replaces: baz.v1.0.0 - name: baz.v1.1.0 replaces: baz.v1.0.0 skips: - baz.v1.0.1 --- -image: test.registry/baz-operator/baz-bundle:v1.0.1 -name: baz.v1.0.1 -package: baz -properties: -- type: olm.bundle.object - value: - data: eyJhcGlWZXJzaW9uIjoiYXBpZXh0ZW5zaW9ucy5rOHMuaW8vdjEiLCJraW5kIjoiQ3VzdG9tUmVzb3VyY2VEZWZpbml0aW9uIiwibWV0YWRhdGEiOnsibmFtZSI6ImJhenMudGVzdC5iYXoifSwic3BlYyI6eyJncm91cCI6InRlc3QuYmF6IiwibmFtZXMiOnsia2luZCI6IkJheiIsInBsdXJhbCI6ImJhenMifSwidmVyc2lvbnMiOlt7Im5hbWUiOiJ2MSJ9XX19 -- type: olm.bundle.object - value: - data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsiYW5ub3RhdGlvbnMiOnsib2xtLnNraXBSYW5nZSI6Ilx1MDAzYzEuMC4xIn0sIm5hbWUiOiJiYXoudjEuMC4xIn0sInNwZWMiOnsiY3VzdG9tcmVzb3VyY2VkZWZpbml0aW9ucyI6eyJvd25lZCI6W3siZ3JvdXAiOiJ0ZXN0LmJheiIsImtpbmQiOiJCYXoiLCJuYW1lIjoiYmF6cy50ZXN0LmJheiIsInZlcnNpb24iOiJ2MSJ9XX0sInJlbGF0ZWRJbWFnZXMiOlt7ImltYWdlIjoidGVzdC5yZWdpc3RyeS9iYXotb3BlcmF0b3IvYmF6OnYxLjAuMSIsIm5hbWUiOiJvcGVyYXRvciJ9XSwic2tpcHMiOlsiYmF6LnYxLjAuMCJdLCJ2ZXJzaW9uIjoiMS4wLjEifX0= -- type: olm.gvk - value: - group: test.baz - kind: Baz - version: v1 -- type: olm.package - value: - packageName: baz - version: 1.0.1 -relatedImages: -- image: test.registry/baz-operator/baz:v1.0.1 - name: operator -schema: olm.bundle ---- image: test.registry/baz-operator/baz-bundle:v1.1.0 name: baz.v1.1.0 package: baz diff --git a/alpha/action/testdata/index-declcfgs/latest/index.yaml b/alpha/action/testdata/index-declcfgs/latest/index.yaml index b8e4782d6..fe52f39cd 100644 --- a/alpha/action/testdata/index-declcfgs/latest/index.yaml +++ b/alpha/action/testdata/index-declcfgs/latest/index.yaml @@ -3,6 +3,28 @@ defaultChannel: stable name: bar schema: olm.package --- +name: alpha +package: bar +schema: olm.channel +strategy: + legacy: + entries: + - name: bar.v0.1.0 + - name: bar.v0.2.0 + skipRange: <0.2.0 + skips: + - bar.v0.1.0 + - name: bar.v1.0.0 + replaces: bar.v0.2.0 +--- +name: stable +package: bar +schema: olm.channel +strategy: + legacy: + entries: + - name: bar.v1.0.0 +--- image: test.registry/bar-operator/bar-bundle:v0.1.0 name: bar.v0.1.0 package: bar @@ -13,9 +35,6 @@ properties: - type: olm.bundle.object value: data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsibmFtZSI6ImJhci52MC4xLjAifSwic3BlYyI6eyJjdXN0b21yZXNvdXJjZWRlZmluaXRpb25zIjp7Im93bmVkIjpbeyJncm91cCI6InRlc3QuYmFyIiwia2luZCI6IkJhciIsIm5hbWUiOiJiYXJzLnRlc3QuYmFyIiwidmVyc2lvbiI6InYxYWxwaGExIn1dfSwicmVsYXRlZEltYWdlcyI6W3siaW1hZ2UiOiJ0ZXN0LnJlZ2lzdHJ5L2Jhci1vcGVyYXRvci9iYXI6djAuMS4wIiwibmFtZSI6Im9wZXJhdG9yIn1dLCJ2ZXJzaW9uIjoiMC4xLjAifX0= -- type: olm.channel - value: - name: alpha - type: olm.gvk value: group: test.bar @@ -40,9 +59,6 @@ properties: - type: olm.bundle.object value: data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsiYW5ub3RhdGlvbnMiOnsib2xtLnNraXBSYW5nZSI6Ilx1MDAzYzAuMi4wIn0sIm5hbWUiOiJiYXIudjAuMi4wIn0sInNwZWMiOnsiY3VzdG9tcmVzb3VyY2VkZWZpbml0aW9ucyI6eyJvd25lZCI6W3siZ3JvdXAiOiJ0ZXN0LmJhciIsImtpbmQiOiJCYXIiLCJuYW1lIjoiYmFycy50ZXN0LmJhciIsInZlcnNpb24iOiJ2MWFscGhhMSJ9XX0sInJlbGF0ZWRJbWFnZXMiOlt7ImltYWdlIjoidGVzdC5yZWdpc3RyeS9iYXItb3BlcmF0b3IvYmFyOnYwLjIuMCIsIm5hbWUiOiJvcGVyYXRvciJ9XSwic2tpcHMiOlsiYmFyLnYwLjEuMCJdLCJ2ZXJzaW9uIjoiMC4yLjAifX0= -- type: olm.channel - value: - name: alpha - type: olm.gvk value: group: test.bar @@ -52,10 +68,6 @@ properties: value: packageName: bar version: 0.2.0 -- type: olm.skipRange - value: <0.2.0 -- type: olm.skips - value: bar.v0.1.0 relatedImages: - image: test.registry/bar-operator/bar:v0.2.0 name: operator @@ -71,13 +83,6 @@ properties: - type: olm.bundle.object value: data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsibmFtZSI6ImJhci52MS4wLjAifSwic3BlYyI6eyJjdXN0b21yZXNvdXJjZWRlZmluaXRpb25zIjp7Im93bmVkIjpbeyJncm91cCI6InRlc3QuYmFyIiwia2luZCI6IkJhciIsIm5hbWUiOiJiYXJzLnRlc3QuYmFyIiwidmVyc2lvbiI6InYxYWxwaGExIn0seyJncm91cCI6InRlc3QuYmFyIiwia2luZCI6IkJhciIsIm5hbWUiOiJiYXJzLnRlc3QuYmFyIiwidmVyc2lvbiI6InYxIn1dfSwicmVsYXRlZEltYWdlcyI6W3siaW1hZ2UiOiJ0ZXN0LnJlZ2lzdHJ5L2Jhci1vcGVyYXRvci9iYXI6djEuMC4wIiwibmFtZSI6Im9wZXJhdG9yIn1dLCJyZXBsYWNlcyI6ImJhci52MC4yLjAiLCJ2ZXJzaW9uIjoiMS4wLjAifX0= -- type: olm.channel - value: - name: alpha - replaces: bar.v0.2.0 -- type: olm.channel - value: - name: stable - type: olm.gvk value: group: test.bar @@ -101,6 +106,24 @@ defaultChannel: stable name: baz schema: olm.package --- +schema: olm.channel +package: baz +name: stable +strategy: + legacy: + entries: + - name: baz.v1.0.0 + skipRange: <1.0.0 + - name: baz.v1.0.1 + replaces: baz.v1.0.0 + skipRange: <1.0.0 + skips: + - baz.v1.0.0 + - name: baz.v1.1.0 + replaces: baz.v1.0.0 + skips: + - baz.v1.0.1 +--- image: test.registry/baz-operator/baz-bundle:v1.0.0 name: baz.v1.0.0 package: baz @@ -111,9 +134,6 @@ properties: - type: olm.bundle.object value: data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsibmFtZSI6ImJhei52MS4wLjAifSwic3BlYyI6eyJjdXN0b21yZXNvdXJjZWRlZmluaXRpb25zIjp7Im93bmVkIjpbeyJncm91cCI6InRlc3QuYmF6Iiwia2luZCI6IkJheiIsIm5hbWUiOiJiYXpzLnRlc3QuYmF6IiwidmVyc2lvbiI6InYxIn1dfSwicmVsYXRlZEltYWdlcyI6W3siaW1hZ2UiOiJ0ZXN0LnJlZ2lzdHJ5L2Jhei1vcGVyYXRvci9iYXo6djEuMC4wIiwibmFtZSI6Im9wZXJhdG9yIn1dLCJ2ZXJzaW9uIjoiMS4wLjAifX0= -- type: olm.channel - value: - name: stable - type: olm.gvk value: group: test.baz @@ -123,8 +143,6 @@ properties: value: packageName: baz version: 1.0.0 -- type: olm.skipRange - value: <1.0.0 relatedImages: - image: test.registry/baz-operator/baz:v1.0.0 name: operator @@ -140,10 +158,6 @@ properties: - type: olm.bundle.object value: data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsiYW5ub3RhdGlvbnMiOnsib2xtLnNraXBSYW5nZSI6Ilx1MDAzYzEuMC4xIn0sIm5hbWUiOiJiYXoudjEuMC4xIn0sInNwZWMiOnsiY3VzdG9tcmVzb3VyY2VkZWZpbml0aW9ucyI6eyJvd25lZCI6W3siZ3JvdXAiOiJ0ZXN0LmJheiIsImtpbmQiOiJCYXoiLCJuYW1lIjoiYmF6cy50ZXN0LmJheiIsInZlcnNpb24iOiJ2MSJ9XX0sInJlbGF0ZWRJbWFnZXMiOlt7ImltYWdlIjoidGVzdC5yZWdpc3RyeS9iYXotb3BlcmF0b3IvYmF6OnYxLjAuMSIsIm5hbWUiOiJvcGVyYXRvciJ9XSwic2tpcHMiOlsiYmF6LnYxLjAuMCJdLCJ2ZXJzaW9uIjoiMS4wLjEifX0= -- type: olm.channel - value: - name: stable - replaces: baz.v1.0.0 - type: olm.gvk value: group: test.baz @@ -153,8 +167,6 @@ properties: value: packageName: baz version: 1.0.1 -- type: olm.skipRange - value: <1.0.0 relatedImages: - image: test.registry/baz-operator/baz:v1.0.1 name: operator @@ -170,10 +182,6 @@ properties: - type: olm.bundle.object value: data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsibmFtZSI6ImJhei52MS4xLjAifSwic3BlYyI6eyJjdXN0b21yZXNvdXJjZWRlZmluaXRpb25zIjp7Im93bmVkIjpbeyJncm91cCI6InRlc3QuYmF6Iiwia2luZCI6IkJheiIsIm5hbWUiOiJiYXpzLnRlc3QuYmF6IiwidmVyc2lvbiI6InYxIn1dfSwicmVsYXRlZEltYWdlcyI6W3siaW1hZ2UiOiJ0ZXN0LnJlZ2lzdHJ5L2Jhei1vcGVyYXRvci9iYXo6djEuMS4wIiwibmFtZSI6Im9wZXJhdG9yIn1dLCJyZXBsYWNlcyI6ImJhei52MS4wLjAiLCJ2ZXJzaW9uIjoiMS4xLjAifX0= -- type: olm.channel - value: - name: stable - replaces: baz.v1.0.0 - type: olm.gvk value: group: test.baz @@ -183,8 +191,6 @@ properties: value: packageName: baz version: 1.1.0 -- type: olm.skips - value: baz.v1.0.1 relatedImages: - image: test.registry/baz-operator/baz:v1.1.0 name: operator @@ -194,6 +200,27 @@ defaultChannel: beta name: foo schema: olm.package --- +schema: olm.channel +package: foo +name: beta +strategy: + legacy: + entries: + - name: foo.v0.1.0 + skipRange: <0.1.0 + - name: foo.v0.2.0 + replaces: foo.v0.1.0 + skipRange: <0.2.0 + skips: + - foo.v0.1.1 + - foo.v0.1.2 + - name: foo.v0.3.0 + replaces: foo.v0.2.0 + - name: foo.v0.3.1 + replaces: foo.v0.2.0 + skips: + - foo.v0.3.0 +--- image: test.registry/foo-operator/foo-bundle:v0.1.0 name: foo.v0.1.0 package: foo @@ -204,9 +231,6 @@ properties: - type: olm.bundle.object value: data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsiYW5ub3RhdGlvbnMiOnsib2xtLnNraXBSYW5nZSI6Ilx1MDAzYzAuMS4wIn0sIm5hbWUiOiJmb28udjAuMS4wIn0sInNwZWMiOnsiY3VzdG9tcmVzb3VyY2VkZWZpbml0aW9ucyI6eyJvd25lZCI6W3siZ3JvdXAiOiJ0ZXN0LmZvbyIsImtpbmQiOiJGb28iLCJuYW1lIjoiZm9vcy50ZXN0LmZvbyIsInZlcnNpb24iOiJ2MSJ9XX0sInJlbGF0ZWRJbWFnZXMiOlt7ImltYWdlIjoidGVzdC5yZWdpc3RyeS9mb28tb3BlcmF0b3IvZm9vOnYwLjEuMCIsIm5hbWUiOiJvcGVyYXRvciJ9XSwidmVyc2lvbiI6IjAuMS4wIn19 -- type: olm.channel - value: - name: beta - type: olm.gvk value: group: test.foo @@ -225,8 +249,6 @@ properties: value: packageName: bar versionRange: <0.1.0 -- type: olm.skipRange - value: <0.1.0 relatedImages: - image: test.registry/foo-operator/foo:v0.1.0 name: operator @@ -242,10 +264,6 @@ properties: - type: olm.bundle.object value: data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsiYW5ub3RhdGlvbnMiOnsib2xtLnNraXBSYW5nZSI6Ilx1MDAzYzAuMi4wIn0sIm5hbWUiOiJmb28udjAuMi4wIn0sInNwZWMiOnsiY3VzdG9tcmVzb3VyY2VkZWZpbml0aW9ucyI6eyJvd25lZCI6W3siZ3JvdXAiOiJ0ZXN0LmZvbyIsImtpbmQiOiJGb28iLCJuYW1lIjoiZm9vcy50ZXN0LmZvbyIsInZlcnNpb24iOiJ2MSJ9XX0sInJlbGF0ZWRJbWFnZXMiOlt7ImltYWdlIjoidGVzdC5yZWdpc3RyeS9mb28tb3BlcmF0b3IvZm9vOnYwLjIuMCIsIm5hbWUiOiJvcGVyYXRvciJ9XSwicmVwbGFjZXMiOiJmb28udjAuMS4wIiwic2tpcHMiOlsiZm9vLnYwLjEuMSIsImZvby52MC4xLjIiXSwidmVyc2lvbiI6IjAuMi4wIn19 -- type: olm.channel - value: - name: beta - replaces: foo.v0.1.0 - type: olm.gvk value: group: test.foo @@ -264,12 +282,6 @@ properties: value: packageName: bar versionRange: <0.1.0 -- type: olm.skipRange - value: <0.2.0 -- type: olm.skips - value: foo.v0.1.1 -- type: olm.skips - value: foo.v0.1.2 relatedImages: - image: test.registry/foo-operator/foo:v0.2.0 name: operator @@ -285,10 +297,6 @@ properties: - type: olm.bundle.object value: data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsibmFtZSI6ImZvby52MC4zLjAifSwic3BlYyI6eyJjdXN0b21yZXNvdXJjZWRlZmluaXRpb25zIjp7Im93bmVkIjpbeyJncm91cCI6InRlc3QuZm9vIiwia2luZCI6IkZvbyIsIm5hbWUiOiJmb29zLnRlc3QuZm9vIiwidmVyc2lvbiI6InYxIn0seyJncm91cCI6InRlc3QuZm9vIiwia2luZCI6IkZvbyIsIm5hbWUiOiJmb29zLnRlc3QuZm9vIiwidmVyc2lvbiI6InYyIn1dfSwicmVsYXRlZEltYWdlcyI6W3siaW1hZ2UiOiJ0ZXN0LnJlZ2lzdHJ5L2Zvby1vcGVyYXRvci9mb286djAuMy4wIiwibmFtZSI6Im9wZXJhdG9yIn1dLCJyZXBsYWNlcyI6ImZvby52MC4yLjAiLCJ2ZXJzaW9uIjoiMC4zLjAifX0= -- type: olm.channel - value: - name: beta - replaces: foo.v0.2.0 - type: olm.gvk value: group: test.foo @@ -327,10 +335,6 @@ properties: - type: olm.bundle.object value: data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsibmFtZSI6ImZvby52MC4zLjEifSwic3BlYyI6eyJjdXN0b21yZXNvdXJjZWRlZmluaXRpb25zIjp7Im93bmVkIjpbeyJncm91cCI6InRlc3QuZm9vIiwia2luZCI6IkZvbyIsIm5hbWUiOiJmb29zLnRlc3QuZm9vIiwidmVyc2lvbiI6InYxIn0seyJncm91cCI6InRlc3QuZm9vIiwia2luZCI6IkZvbyIsIm5hbWUiOiJmb29zLnRlc3QuZm9vIiwidmVyc2lvbiI6InYyIn1dfSwicmVsYXRlZEltYWdlcyI6W3siaW1hZ2UiOiJ0ZXN0LnJlZ2lzdHJ5L2Zvby1vcGVyYXRvci9mb286djAuMy4xIiwibmFtZSI6Im9wZXJhdG9yIn1dLCJyZXBsYWNlcyI6ImZvby52MC4yLjAiLCJza2lwcyI6WyJmb28udjAuMy4wIl0sInZlcnNpb24iOiIwLjMuMSJ9fQ== -- type: olm.channel - value: - name: beta - replaces: foo.v0.2.0 - type: olm.gvk value: group: test.foo @@ -354,8 +358,6 @@ properties: value: packageName: bar versionRange: <0.2.0 -- type: olm.skips - value: foo.v0.3.0 relatedImages: - image: test.registry/foo-operator/foo:v0.3.1 name: operator diff --git a/alpha/action/testdata/index-declcfgs/old/index.yaml b/alpha/action/testdata/index-declcfgs/old/index.yaml index b97ccacbc..e02cc4ff0 100644 --- a/alpha/action/testdata/index-declcfgs/old/index.yaml +++ b/alpha/action/testdata/index-declcfgs/old/index.yaml @@ -3,6 +3,18 @@ defaultChannel: alpha name: bar schema: olm.package --- +schema: olm.channel +package: bar +name: alpha +strategy: + legacy: + entries: + - name: bar.v0.1.0 + - name: bar.v0.2.0 + skipRange: <0.2.0 + skips: + - bar.v0.1.0 +--- image: test.registry/bar-operator/bar-bundle:v0.1.0 name: bar.v0.1.0 package: bar @@ -13,9 +25,6 @@ properties: - type: olm.bundle.object value: data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsibmFtZSI6ImJhci52MC4xLjAifSwic3BlYyI6eyJjdXN0b21yZXNvdXJjZWRlZmluaXRpb25zIjp7Im93bmVkIjpbeyJncm91cCI6InRlc3QuYmFyIiwia2luZCI6IkJhciIsIm5hbWUiOiJiYXJzLnRlc3QuYmFyIiwidmVyc2lvbiI6InYxYWxwaGExIn1dfSwicmVsYXRlZEltYWdlcyI6W3siaW1hZ2UiOiJ0ZXN0LnJlZ2lzdHJ5L2Jhci1vcGVyYXRvci9iYXI6djAuMS4wIiwibmFtZSI6Im9wZXJhdG9yIn1dLCJ2ZXJzaW9uIjoiMC4xLjAifX0= -- type: olm.channel - value: - name: alpha - type: olm.gvk value: group: test.bar @@ -40,9 +49,6 @@ properties: - type: olm.bundle.object value: data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsiYW5ub3RhdGlvbnMiOnsib2xtLnNraXBSYW5nZSI6Ilx1MDAzYzAuMi4wIn0sIm5hbWUiOiJiYXIudjAuMi4wIn0sInNwZWMiOnsiY3VzdG9tcmVzb3VyY2VkZWZpbml0aW9ucyI6eyJvd25lZCI6W3siZ3JvdXAiOiJ0ZXN0LmJhciIsImtpbmQiOiJCYXIiLCJuYW1lIjoiYmFycy50ZXN0LmJhciIsInZlcnNpb24iOiJ2MWFscGhhMSJ9XX0sInJlbGF0ZWRJbWFnZXMiOlt7ImltYWdlIjoidGVzdC5yZWdpc3RyeS9iYXItb3BlcmF0b3IvYmFyOnYwLjIuMCIsIm5hbWUiOiJvcGVyYXRvciJ9XSwic2tpcHMiOlsiYmFyLnYwLjEuMCJdLCJ2ZXJzaW9uIjoiMC4yLjAifX0= -- type: olm.channel - value: - name: alpha - type: olm.gvk value: group: test.bar @@ -52,10 +58,6 @@ properties: value: packageName: bar version: 0.2.0 -- type: olm.skipRange - value: <0.2.0 -- type: olm.skips - value: bar.v0.1.0 relatedImages: - image: test.registry/bar-operator/bar:v0.2.0 name: operator @@ -65,6 +67,20 @@ defaultChannel: stable name: baz schema: olm.package --- +schema: olm.channel +package: baz +name: stable +strategy: + legacy: + entries: + - name: baz.v1.0.0 + skipRange: <1.0.0 + - name: baz.v1.0.1 + replaces: baz.v1.0.0 + skipRange: <1.0.0 + skips: + - baz.v1.0.0 +--- image: test.registry/baz-operator/baz-bundle:v1.0.0 name: baz.v1.0.0 package: baz @@ -75,9 +91,6 @@ properties: - type: olm.bundle.object value: data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsibmFtZSI6ImJhei52MS4wLjAifSwic3BlYyI6eyJjdXN0b21yZXNvdXJjZWRlZmluaXRpb25zIjp7Im93bmVkIjpbeyJncm91cCI6InRlc3QuYmF6Iiwia2luZCI6IkJheiIsIm5hbWUiOiJiYXpzLnRlc3QuYmF6IiwidmVyc2lvbiI6InYxIn1dfSwicmVsYXRlZEltYWdlcyI6W3siaW1hZ2UiOiJ0ZXN0LnJlZ2lzdHJ5L2Jhei1vcGVyYXRvci9iYXo6djEuMC4wIiwibmFtZSI6Im9wZXJhdG9yIn1dLCJ2ZXJzaW9uIjoiMS4wLjAifX0= -- type: olm.channel - value: - name: stable - type: olm.gvk value: group: test.baz @@ -87,8 +100,6 @@ properties: value: packageName: baz version: 1.0.0 -- type: olm.skipRange - value: <1.0.0 relatedImages: - image: test.registry/baz-operator/baz:v1.0.0 name: operator @@ -104,10 +115,6 @@ properties: - type: olm.bundle.object value: data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsiYW5ub3RhdGlvbnMiOnsib2xtLnNraXBSYW5nZSI6Ilx1MDAzYzEuMC4xIn0sIm5hbWUiOiJiYXoudjEuMC4xIn0sInNwZWMiOnsiY3VzdG9tcmVzb3VyY2VkZWZpbml0aW9ucyI6eyJvd25lZCI6W3siZ3JvdXAiOiJ0ZXN0LmJheiIsImtpbmQiOiJCYXoiLCJuYW1lIjoiYmF6cy50ZXN0LmJheiIsInZlcnNpb24iOiJ2MSJ9XX0sInJlbGF0ZWRJbWFnZXMiOlt7ImltYWdlIjoidGVzdC5yZWdpc3RyeS9iYXotb3BlcmF0b3IvYmF6OnYxLjAuMSIsIm5hbWUiOiJvcGVyYXRvciJ9XSwic2tpcHMiOlsiYmF6LnYxLjAuMCJdLCJ2ZXJzaW9uIjoiMS4wLjEifX0= -- type: olm.channel - value: - name: stable - replaces: baz.v1.0.0 - type: olm.gvk value: group: test.baz @@ -117,10 +124,6 @@ properties: value: packageName: baz version: 1.0.1 -- type: olm.skipRange - value: <1.0.0 -- type: olm.skips - value: baz.v1.0.0 relatedImages: - image: test.registry/baz-operator/baz:v1.0.1 name: operator @@ -130,6 +133,23 @@ defaultChannel: beta name: foo schema: olm.package --- +schema: olm.channel +package: foo +name: beta +strategy: + legacy: + entries: + - name: foo.v0.1.0 + skipRange: <0.1.0 + - name: foo.v0.2.0 + replaces: foo.v0.1.0 + skipRange: <0.2.0 + skips: + - foo.v0.1.1 + - foo.v0.1.2 + - name: foo.v0.3.0 + replaces: foo.v0.2.0 +--- image: test.registry/foo-operator/foo-bundle:v0.1.0 name: foo.v0.1.0 package: foo @@ -140,9 +160,6 @@ properties: - type: olm.bundle.object value: data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsiYW5ub3RhdGlvbnMiOnsib2xtLnNraXBSYW5nZSI6Ilx1MDAzYzAuMS4wIn0sIm5hbWUiOiJmb28udjAuMS4wIn0sInNwZWMiOnsiY3VzdG9tcmVzb3VyY2VkZWZpbml0aW9ucyI6eyJvd25lZCI6W3siZ3JvdXAiOiJ0ZXN0LmZvbyIsImtpbmQiOiJGb28iLCJuYW1lIjoiZm9vcy50ZXN0LmZvbyIsInZlcnNpb24iOiJ2MSJ9XX0sInJlbGF0ZWRJbWFnZXMiOlt7ImltYWdlIjoidGVzdC5yZWdpc3RyeS9mb28tb3BlcmF0b3IvZm9vOnYwLjEuMCIsIm5hbWUiOiJvcGVyYXRvciJ9XSwidmVyc2lvbiI6IjAuMS4wIn19 -- type: olm.channel - value: - name: beta - type: olm.gvk value: group: test.foo @@ -161,8 +178,6 @@ properties: value: packageName: bar versionRange: <0.1.0 -- type: olm.skipRange - value: <0.1.0 relatedImages: - image: test.registry/foo-operator/foo:v0.1.0 name: operator @@ -178,10 +193,6 @@ properties: - type: olm.bundle.object value: data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsiYW5ub3RhdGlvbnMiOnsib2xtLnNraXBSYW5nZSI6Ilx1MDAzYzAuMi4wIn0sIm5hbWUiOiJmb28udjAuMi4wIn0sInNwZWMiOnsiY3VzdG9tcmVzb3VyY2VkZWZpbml0aW9ucyI6eyJvd25lZCI6W3siZ3JvdXAiOiJ0ZXN0LmZvbyIsImtpbmQiOiJGb28iLCJuYW1lIjoiZm9vcy50ZXN0LmZvbyIsInZlcnNpb24iOiJ2MSJ9XX0sInJlbGF0ZWRJbWFnZXMiOlt7ImltYWdlIjoidGVzdC5yZWdpc3RyeS9mb28tb3BlcmF0b3IvZm9vOnYwLjIuMCIsIm5hbWUiOiJvcGVyYXRvciJ9XSwicmVwbGFjZXMiOiJmb28udjAuMS4wIiwic2tpcHMiOlsiZm9vLnYwLjEuMSIsImZvby52MC4xLjIiXSwidmVyc2lvbiI6IjAuMi4wIn19 -- type: olm.channel - value: - name: beta - replaces: foo.v0.1.0 - type: olm.gvk value: group: test.foo @@ -200,12 +211,6 @@ properties: value: packageName: bar versionRange: <0.1.0 -- type: olm.skipRange - value: <0.2.0 -- type: olm.skips - value: foo.v0.1.1 -- type: olm.skips - value: foo.v0.1.2 relatedImages: - image: test.registry/foo-operator/foo:v0.2.0 name: operator @@ -221,10 +226,6 @@ properties: - type: olm.bundle.object value: data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsibmFtZSI6ImZvby52MC4zLjAifSwic3BlYyI6eyJjdXN0b21yZXNvdXJjZWRlZmluaXRpb25zIjp7Im93bmVkIjpbeyJncm91cCI6InRlc3QuZm9vIiwia2luZCI6IkZvbyIsIm5hbWUiOiJmb29zLnRlc3QuZm9vIiwidmVyc2lvbiI6InYxIn0seyJncm91cCI6InRlc3QuZm9vIiwia2luZCI6IkZvbyIsIm5hbWUiOiJmb29zLnRlc3QuZm9vIiwidmVyc2lvbiI6InYyIn1dfSwicmVsYXRlZEltYWdlcyI6W3siaW1hZ2UiOiJ0ZXN0LnJlZ2lzdHJ5L2Zvby1vcGVyYXRvci9mb286djAuMy4wIiwibmFtZSI6Im9wZXJhdG9yIn1dLCJyZXBsYWNlcyI6ImZvby52MC4yLjAiLCJ2ZXJzaW9uIjoiMC4zLjAifX0= -- type: olm.channel - value: - name: beta - replaces: foo.v0.2.0 - type: olm.gvk value: group: test.foo diff --git a/alpha/action/testdata/list-index/bar/index.yaml b/alpha/action/testdata/list-index/bar/index.yaml index 0d2a3610d..95766aae8 100644 --- a/alpha/action/testdata/list-index/bar/index.yaml +++ b/alpha/action/testdata/list-index/bar/index.yaml @@ -3,14 +3,39 @@ schema: olm.package name: bar defaultChannel: beta --- +schema: olm.channel +package: bar +name: beta +strategy: + legacy: + entries: + - name: bar.v0.1.0 + skipRange: <0.1.0 + - name: bar.v0.2.0 + replaces: bar.v0.1.0 + skipRange: <0.2.0 + skips: + - bar.v0.1.1 + - bar.v0.1.2 +--- +schema: olm.channel +package: bar +name: stable +strategy: + legacy: + entries: + - name: bar.v0.2.0 + replaces: bar.v0.1.0 + skipRange: <0.2.0 + skips: + - bar.v0.1.1 + - bar.v0.1.2 +--- schema: olm.bundle package: bar name: bar.v0.1.0 image: test.registry/bar-operator/bar-bundle:v0.1.0 properties: - - type: olm.channel - value: - name: beta - type: olm.gvk value: group: test.bar @@ -29,8 +54,6 @@ properties: value: packageName: baz versionRange: v0.1.0 - - type: olm.skipRange - value: <0.1.0 - type: olm.bundle.object value: data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsiYW5ub3RhdGlvbnMiOnsib2xtLnNraXBSYW5nZSI6Ilx1MDAzYzAuMS4wIn0sIm5hbWUiOiJiYXIudjAuMS4wIn0sInNwZWMiOnsiY3VzdG9tcmVzb3VyY2VkZWZpbml0aW9ucyI6eyJvd25lZCI6W3siZ3JvdXAiOiJ0ZXN0LmJhciIsImtpbmQiOiJCYXIiLCJuYW1lIjoiYmFycy50ZXN0LmJhciIsInZlcnNpb24iOiJ2MSJ9XX0sImRpc3BsYXlOYW1lIjoiQmFyIE9wZXJhdG9yIiwicmVsYXRlZEltYWdlcyI6W3siaW1hZ2UiOiJ0ZXN0LnJlZ2lzdHJ5L2Jhci1vcGVyYXRvci9iYXI6djAuMS4wIiwibmFtZSI6Im9wZXJhdG9yIn1dLCJ2ZXJzaW9uIjoiMC4xLjAifX0= @@ -47,14 +70,6 @@ package: bar name: bar.v0.2.0 image: test.registry/bar-operator/bar-bundle:v0.2.0 properties: - - type: olm.channel - value: - name: beta - replaces: bar.v0.1.0 - - type: olm.channel - value: - name: stable - replaces: bar.v0.1.0 - type: olm.gvk value: group: test.bar @@ -73,12 +88,6 @@ properties: value: packageName: baz versionRange: v0.1.0 - - type: olm.skipRange - value: <0.2.0 - - type: olm.skips - value: bar.v0.1.1 - - type: olm.skips - value: bar.v0.1.2 - type: olm.bundle.object value: data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsiYW5ub3RhdGlvbnMiOnsib2xtLnNraXBSYW5nZSI6Ilx1MDAzYzAuMi4wIn0sIm5hbWUiOiJiYXIudjAuMi4wIn0sInNwZWMiOnsiY3VzdG9tcmVzb3VyY2VkZWZpbml0aW9ucyI6eyJvd25lZCI6W3siZ3JvdXAiOiJ0ZXN0LmJhciIsImtpbmQiOiJCYXIiLCJuYW1lIjoiYmFycy50ZXN0LmJhciIsInZlcnNpb24iOiJ2MSJ9XX0sImRpc3BsYXlOYW1lIjoiQmFyIE9wZXJhdG9yIiwicmVsYXRlZEltYWdlcyI6W3siaW1hZ2UiOiJ0ZXN0LnJlZ2lzdHJ5L2Jhci1vcGVyYXRvci9iYXI6djAuMi4wIiwibmFtZSI6Im9wZXJhdG9yIn1dLCJyZXBsYWNlcyI6ImJhci52MC4xLjAiLCJza2lwcyI6WyJiYXIudjAuMS4xIiwiYmFyLnYwLjEuMiJdLCJ2ZXJzaW9uIjoiMC4yLjAifX0= diff --git a/alpha/action/testdata/list-index/foo/index.yaml b/alpha/action/testdata/list-index/foo/index.yaml index 2e108e380..6a397cef1 100644 --- a/alpha/action/testdata/list-index/foo/index.yaml +++ b/alpha/action/testdata/list-index/foo/index.yaml @@ -3,14 +3,39 @@ schema: olm.package name: foo defaultChannel: beta --- +schema: olm.channel +package: foo +name: beta +strategy: + legacy: + entries: + - name: foo.v0.1.0 + skipRange: <0.1.0 + - name: foo.v0.2.0 + replaces: foo.v0.1.0 + skipRange: <0.2.0 + skips: + - foo.v0.1.1 + - foo.v0.1.2 +--- +schema: olm.channel +package: foo +name: stable +strategy: + legacy: + entries: + - name: foo.v0.2.0 + replaces: foo.v0.1.0 + skipRange: <0.2.0 + skips: + - foo.v0.1.1 + - foo.v0.1.2 +--- schema: olm.bundle package: foo name: foo.v0.1.0 image: test.registry/foo-operator/foo-bundle:v0.1.0 properties: - - type: olm.channel - value: - name: beta - type: olm.gvk value: group: test.foo @@ -29,8 +54,6 @@ properties: value: packageName: bar versionRange: v0.1.0 - - type: olm.skipRange - value: <0.1.0 - type: olm.bundle.object value: data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsiYW5ub3RhdGlvbnMiOnsib2xtLnNraXBSYW5nZSI6Ilx1MDAzYzAuMS4wIn0sIm5hbWUiOiJmb28udjAuMS4wIn0sInNwZWMiOnsiY3VzdG9tcmVzb3VyY2VkZWZpbml0aW9ucyI6eyJvd25lZCI6W3siZ3JvdXAiOiJ0ZXN0LmZvbyIsImtpbmQiOiJGb28iLCJuYW1lIjoiZm9vcy50ZXN0LmZvbyIsInZlcnNpb24iOiJ2MSJ9XX0sImRpc3BsYXlOYW1lIjoiRm9vIE9wZXJhdG9yIiwicmVsYXRlZEltYWdlcyI6W3siaW1hZ2UiOiJ0ZXN0LnJlZ2lzdHJ5L2Zvby1vcGVyYXRvci9mb286djAuMS4wIiwibmFtZSI6Im9wZXJhdG9yIn1dLCJ2ZXJzaW9uIjoiMC4xLjAifX0= @@ -47,14 +70,6 @@ package: foo name: foo.v0.2.0 image: test.registry/foo-operator/foo-bundle:v0.2.0 properties: - - type: olm.channel - value: - name: beta - replaces: foo.v0.1.0 - - type: olm.channel - value: - name: stable - replaces: foo.v0.1.0 - type: olm.gvk value: group: test.foo @@ -73,12 +88,6 @@ properties: value: packageName: bar versionRange: v0.1.0 - - type: olm.skipRange - value: <0.2.0 - - type: olm.skips - value: foo.v0.1.1 - - type: olm.skips - value: foo.v0.1.2 - type: olm.bundle.object value: data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsiYW5ub3RhdGlvbnMiOnsib2xtLnNraXBSYW5nZSI6Ilx1MDAzYzAuMi4wIn0sIm5hbWUiOiJmb28udjAuMi4wIn0sInNwZWMiOnsiY3VzdG9tcmVzb3VyY2VkZWZpbml0aW9ucyI6eyJvd25lZCI6W3siZ3JvdXAiOiJ0ZXN0LmZvbyIsImtpbmQiOiJGb28iLCJuYW1lIjoiZm9vcy50ZXN0LmZvbyIsInZlcnNpb24iOiJ2MSJ9XX0sImRpc3BsYXlOYW1lIjoiRm9vIE9wZXJhdG9yIiwicmVsYXRlZEltYWdlcyI6W3siaW1hZ2UiOiJ0ZXN0LnJlZ2lzdHJ5L2Zvby1vcGVyYXRvci9mb286djAuMi4wIiwibmFtZSI6Im9wZXJhdG9yIn1dLCJyZXBsYWNlcyI6ImZvby52MC4xLjAiLCJza2lwcyI6WyJmb28udjAuMS4xIiwiZm9vLnYwLjEuMiJdLCJ2ZXJzaW9uIjoiMC4yLjAifX0= diff --git a/alpha/declcfg/declcfg_to_model.go b/alpha/declcfg/declcfg_to_model.go index ac4770416..b02ebfc92 100644 --- a/alpha/declcfg/declcfg_to_model.go +++ b/alpha/declcfg/declcfg_to_model.go @@ -81,7 +81,6 @@ func ConvertToModel(cfg DeclarativeConfig) (model.Model, error) { } for _, b := range cfg.Bundles { - defaultChannelName := defaultChannels[b.Package] if b.Package == "" { return nil, fmt.Errorf("package name must be set for bundle %q", b.Name) } @@ -90,7 +89,7 @@ func ConvertToModel(cfg DeclarativeConfig) (model.Model, error) { return nil, fmt.Errorf("unknown package %q for bundle %q", b.Package, b.Name) } - props, err := parseProperties(b.Properties) + props, err := property.Parse(b.Properties) if err != nil { return nil, fmt.Errorf("parse properties for bundle %q: %v", b.Name, err) } @@ -109,79 +108,23 @@ func ConvertToModel(cfg DeclarativeConfig) (model.Model, error) { return nil, fmt.Errorf("error parsing bundle version: %v", err) } - if channelDefinedEdges.Has(b.Package) { - if len(props.Channels) > 0 { - return nil, fmt.Errorf("invalid package %q, bundle %q: cannot use %q properties with %q blobs", b.Package, b.Name, property.TypeChannel, schemaChannel) - } - if len(props.Skips) > 0 { - return nil, fmt.Errorf("invalid package %q, bundle %q: cannot use %q properties with %q blobs", b.Package, b.Name, property.TypeSkips, schemaChannel) - } - if len(props.SkipRanges) > 0 { - return nil, fmt.Errorf("invalid package %q, bundle %q: cannot use %q properties with %q blobs", b.Package, b.Name, property.TypeSkipRange, schemaChannel) - } - - channelDefinedEntries[b.Package] = channelDefinedEntries[b.Package].Delete(b.Name) - found := false - for _, mch := range mpkg.Channels { - if mb, ok := mch.Bundles[b.Name]; ok { - found = true - mb.Image = b.Image - mb.Properties = b.Properties - mb.RelatedImages = relatedImagesToModelRelatedImages(b.RelatedImages) - mb.CsvJSON = b.CsvJSON - mb.Objects = b.Objects - mb.PropertiesP = props - mb.Version = ver - } - } - if !found { - return nil, fmt.Errorf("package %q, bundle %q not found in any channel entries", b.Package, b.Name) - } - } else { - if len(props.Channels) == 0 { - return nil, fmt.Errorf("package %q bundle %q is missing channel information", b.Package, b.Name) - } - - if len(props.SkipRanges) > 1 { - return nil, fmt.Errorf("package %q bundle %q is invalid: multiple properties of type %q not allowed", b.Package, b.Name, property.TypeSkipRange) - } - - skipRange := "" - if len(props.SkipRanges) > 0 { - skipRange = string(props.SkipRanges[0]) - } - - for _, bundleChannel := range props.Channels { - pkgChannel, ok := mpkg.Channels[bundleChannel.Name] - if !ok { - pkgChannel = &model.Channel{ - Package: mpkg, - Name: bundleChannel.Name, - Bundles: map[string]*model.Bundle{}, - } - if bundleChannel.Name == defaultChannelName { - mpkg.DefaultChannel = pkgChannel - } - mpkg.Channels[bundleChannel.Name] = pkgChannel - } - - pkgChannel.Bundles[b.Name] = &model.Bundle{ - Package: mpkg, - Channel: pkgChannel, - Name: b.Name, - Image: b.Image, - Replaces: bundleChannel.Replaces, - Skips: skipsToStrings(props.Skips), - SkipRange: skipRange, - Properties: b.Properties, - RelatedImages: relatedImagesToModelRelatedImages(b.RelatedImages), - CsvJSON: b.CsvJSON, - Objects: b.Objects, - PropertiesP: props, - Version: ver, - } + channelDefinedEntries[b.Package] = channelDefinedEntries[b.Package].Delete(b.Name) + found := false + for _, mch := range mpkg.Channels { + if mb, ok := mch.Bundles[b.Name]; ok { + found = true + mb.Image = b.Image + mb.Properties = b.Properties + mb.RelatedImages = relatedImagesToModelRelatedImages(b.RelatedImages) + mb.CsvJSON = b.CsvJSON + mb.Objects = b.Objects + mb.PropertiesP = props + mb.Version = ver } } + if !found { + return nil, fmt.Errorf("package %q, bundle %q not found in any channel entries", b.Package, b.Name) + } } for pkg, entries := range channelDefinedEntries { @@ -210,14 +153,6 @@ func ConvertToModel(cfg DeclarativeConfig) (model.Model, error) { return mpkgs, nil } -func skipsToStrings(in []property.Skips) []string { - var out []string - for _, s := range in { - out = append(out, string(s)) - } - return out -} - func relatedImagesToModelRelatedImages(in []RelatedImage) []model.RelatedImage { var out []model.RelatedImage for _, p := range in { diff --git a/alpha/declcfg/declcfg_to_model_test.go b/alpha/declcfg/declcfg_to_model_test.go index 7d389fe28..06b2754d0 100644 --- a/alpha/declcfg/declcfg_to_model_test.go +++ b/alpha/declcfg/declcfg_to_model_test.go @@ -1,6 +1,7 @@ package declcfg import ( + "encoding/json" "testing" "github.com/stretchr/testify/assert" @@ -38,12 +39,12 @@ func TestConvertToModel(t *testing.T) { assertion: hasError(`unknown package "bar" for bundle "bar.v0.1.0"`), cfg: DeclarativeConfig{ Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, - Bundles: []Bundle{newTestBundle("bar", "0.1.0", withChannel("alpha", ""))}, + Bundles: []Bundle{newTestBundle("bar", "0.1.0")}, }, }, { name: "Error/BundleMissingChannel", - assertion: hasError(`package "foo" bundle "foo.v0.1.0" is missing channel information`), + assertion: hasError(`package "foo", bundle "foo.v0.1.0" not found in any channel entries`), cfg: DeclarativeConfig{ Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, Bundles: []Bundle{newTestBundle("foo", "0.1.0")}, @@ -51,22 +52,14 @@ func TestConvertToModel(t *testing.T) { }, { name: "Error/BundleInvalidProperties", - assertion: hasError(`parse properties for bundle "foo.v0.1.0": duplicate property of type "olm.channel" found with key "alpha"`), + assertion: hasError(`parse properties for bundle "foo.v0.1.0": parse property[2] of type "olm.foo": unexpected end of JSON input`), cfg: DeclarativeConfig{ Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, - Bundles: []Bundle{newTestBundle("foo", "0.1.0", withChannel("alpha", "1"), withChannel("alpha", "2"))}, - }, - }, - { - name: "Error/BundleMultipleSkipRanges", - assertion: hasError(`package "foo" bundle "foo.v0.1.0" is invalid: multiple properties of type "olm.skipRange" not allowed`), - cfg: DeclarativeConfig{ - Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, - Bundles: []Bundle{newTestBundle("foo", "0.1.0", withChannel("alpha", ""), func(b *Bundle) { - b.Properties = append(b.Properties, - property.MustBuildSkipRange("<0.1.0"), - property.MustBuildSkipRange("<=0.1.0"), - ) + Bundles: []Bundle{newTestBundle("foo", "0.1.0", func(b *Bundle) { + b.Properties = append(b.Properties, property.Property{ + Type: "olm.foo", + Value: json.RawMessage("{"), + }) })}, }, }, @@ -101,7 +94,8 @@ func TestConvertToModel(t *testing.T) { └── default channel must be set`), cfg: DeclarativeConfig{ Packages: []Package{newTestPackage("foo", "", svgSmallCircle)}, - Bundles: []Bundle{newTestBundle("foo", "0.1.0", withChannel("alpha", ""))}, + Channels: []Channel{newTestChannel("foo", "bar", LegacyChannelEntry{Name: testBundleName("foo", "0.1.0")})}, + Bundles: []Bundle{newTestBundle("foo", "0.1.0")}, }, }, { @@ -112,7 +106,7 @@ func TestConvertToModel(t *testing.T) { └── channel must contain at least one bundle`), cfg: DeclarativeConfig{ Packages: []Package{newTestPackage("foo", "bar", svgSmallCircle)}, - Bundles: []Bundle{newTestBundle("foo", "0.1.0", withChannel("alpha", ""))}, + Channels: []Channel{newTestChannel("foo", "bar")}, }, }, { @@ -141,38 +135,8 @@ func TestConvertToModel(t *testing.T) { assertion: require.NoError, cfg: DeclarativeConfig{ Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, - Bundles: []Bundle{newTestBundle("foo", "0.1.0", withChannel("alpha", ""), withNoBundleImage())}, - }, - }, - { - name: "Error/ChannelAndBundleChannel", - assertion: hasError(`invalid package "foo", bundle "foo.v0.1.0": cannot use "olm.channel" properties with "olm.channel" blobs`), - cfg: DeclarativeConfig{ - Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, - Channels: []Channel{newTestChannel("foo", "alpha", LegacyChannelEntry{Name: "foo.v0.1.0"})}, - Bundles: []Bundle{newTestBundle("foo", "0.1.0", withChannel("alpha", ""))}, - }, - }, - { - name: "Error/ChannelAndBundleSkips", - assertion: hasError(`invalid package "foo", bundle "foo.v0.1.0": cannot use "olm.skips" properties with "olm.channel" blobs`), - cfg: DeclarativeConfig{ - Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, - Channels: []Channel{newTestChannel("foo", "alpha", LegacyChannelEntry{Name: "foo.v0.1.0"})}, - Bundles: []Bundle{newTestBundle("foo", "0.1.0", func(b *Bundle) { - b.Properties = append(b.Properties, property.MustBuildSkips("foo.v0.0.1")) - })}, - }, - }, - { - name: "Error/ChannelAndBundleSkipRange", - assertion: hasError(`invalid package "foo", bundle "foo.v0.1.0": cannot use "olm.skipRange" properties with "olm.channel" blobs`), - cfg: DeclarativeConfig{ - Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, - Channels: []Channel{newTestChannel("foo", "alpha", LegacyChannelEntry{Name: "foo.v0.1.0"})}, - Bundles: []Bundle{newTestBundle("foo", "0.1.0", func(b *Bundle) { - b.Properties = append(b.Properties, property.MustBuildSkipRange("<0.1.0")) - })}, + Channels: []Channel{newTestChannel("foo", "alpha", LegacyChannelEntry{Name: testBundleName("foo", "0.1.0")})}, + Bundles: []Bundle{newTestBundle("foo", "0.1.0", withNoBundleImage())}, }, }, { @@ -241,7 +205,7 @@ func TestConvertToModel(t *testing.T) { }, }, { - name: "Success/WithChannel/ValidModel", + name: "Success/ValidModel", assertion: require.NoError, cfg: DeclarativeConfig{ Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, @@ -249,18 +213,6 @@ func TestConvertToModel(t *testing.T) { Bundles: []Bundle{newTestBundle("foo", "0.1.0")}, }, }, - { - name: "Success/WithoutChannel/ValidModel", - assertion: require.NoError, - cfg: DeclarativeConfig{ - Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, - Bundles: []Bundle{newTestBundle("foo", "0.1.0", withChannel("alpha", ""), func(b *Bundle) { - b.Properties = append(b.Properties, - property.MustBuildSkipRange("<0.1.0"), - ) - })}, - }, - }, } for _, s := range specs { diff --git a/alpha/declcfg/diff_test.go b/alpha/declcfg/diff_test.go index 8da56b500..581bfcbd8 100644 --- a/alpha/declcfg/diff_test.go +++ b/alpha/declcfg/diff_test.go @@ -41,6 +41,11 @@ func TestDiffLatest(t *testing.T) { Packages: []Package{ {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, + Channels: []Channel{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.1.0"}, + }}}}, + }, Bundles: []Bundle{ { Schema: schemaBundle, @@ -48,7 +53,6 @@ func TestDiffLatest(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("foo", "0.1.0"), }, }, @@ -58,6 +62,11 @@ func TestDiffLatest(t *testing.T) { Packages: []Package{ {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, + Channels: []Channel{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.1.0"}, + }}}}, + }, Bundles: []Bundle{ { Schema: schemaBundle, @@ -65,7 +74,6 @@ func TestDiffLatest(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("foo", "0.1.0"), }, }, @@ -80,6 +88,11 @@ func TestDiffLatest(t *testing.T) { Packages: []Package{ {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, + Channels: []Channel{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.1.0"}, + }}}}, + }, Bundles: []Bundle{ { Schema: schemaBundle, @@ -87,7 +100,6 @@ func TestDiffLatest(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("foo", "0.1.0"), }, }, @@ -97,6 +109,11 @@ func TestDiffLatest(t *testing.T) { Packages: []Package{ {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, + Channels: []Channel{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.1.0"}, + }}}}, + }, Bundles: []Bundle{ { Schema: schemaBundle, @@ -104,7 +121,6 @@ func TestDiffLatest(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("foo", "0.1.0"), }, }, @@ -119,6 +135,11 @@ func TestDiffLatest(t *testing.T) { Packages: []Package{ {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, + Channels: []Channel{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.1.0"}, + }}}}, + }, Bundles: []Bundle{ { Schema: schemaBundle, @@ -126,7 +147,6 @@ func TestDiffLatest(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("foo", "0.1.0"), }, }, @@ -136,6 +156,11 @@ func TestDiffLatest(t *testing.T) { Packages: []Package{ {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, + Channels: []Channel{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.1.0"}, + }}}}, + }, Bundles: []Bundle{ { Schema: schemaBundle, @@ -143,7 +168,6 @@ func TestDiffLatest(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("foo", "0.1.0"), property.MustBuildPackageRequired("bar", ">=1.0.0"), }, @@ -180,6 +204,15 @@ func TestDiffLatest(t *testing.T) { Packages: []Package{ {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, + Channels: []Channel{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.1.0"}, + }}}}, + {Schema: schemaChannel, Name: "fast", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.2.0-alpha.0"}, + {Name: "foo.v0.2.0-alpha.1", Replaces: "foo.v0.2.0-alpha.0"}, + }}}}, + }, Bundles: []Bundle{ { Schema: schemaBundle, @@ -187,7 +220,6 @@ func TestDiffLatest(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("foo", "0.1.0"), }, }, @@ -197,7 +229,6 @@ func TestDiffLatest(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("fast", ""), property.MustBuildPackage("foo", "0.2.0-alpha.0"), }, }, @@ -207,7 +238,6 @@ func TestDiffLatest(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("fast", "foo.v0.2.0-alpha.0"), property.MustBuildPackage("foo", "0.2.0-alpha.1"), }, }, @@ -217,6 +247,19 @@ func TestDiffLatest(t *testing.T) { Packages: []Package{ {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, + Channels: []Channel{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.1.0"}, + {Name: "foo.v0.2.0", Skips: []string{"foo.v0.1.0"}}, + }}}}, + {Schema: schemaChannel, Name: "fast", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.2.0-alpha.0"}, + {Name: "foo.v0.2.0-alpha.1", Replaces: "foo.v0.2.0-alpha.0"}, + }}}}, + {Schema: schemaChannel, Name: "clusterwide", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.1.0-clusterwide"}, + }}}}, + }, Bundles: []Bundle{ { Schema: schemaBundle, @@ -224,7 +267,6 @@ func TestDiffLatest(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuild(&deprecated{}), property.MustBuildPackage("foo", "0.1.0"), }, @@ -235,9 +277,7 @@ func TestDiffLatest(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("foo", "0.2.0"), - property.MustBuildSkips("foo.v0.1.0"), }, }, { @@ -246,7 +286,6 @@ func TestDiffLatest(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("fast", ""), property.MustBuildPackage("foo", "0.2.0-alpha.0"), }, }, @@ -256,7 +295,6 @@ func TestDiffLatest(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("fast", "foo.v0.2.0-alpha.0"), property.MustBuildPackage("foo", "0.2.0-alpha.1"), }, }, @@ -266,7 +304,6 @@ func TestDiffLatest(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("clusterwide", ""), property.MustBuildPackage("foo", "0.1.0-clusterwide"), }, }, @@ -325,6 +362,14 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "etcd", DefaultChannel: "stable"}, {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, + Channels: []Channel{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.1.0"}, + }}}}, + {Schema: schemaChannel, Name: "stable", Package: "etcd", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "etcd.v0.9.1"}, + }}}}, + }, Bundles: []Bundle{ { Schema: schemaBundle, @@ -332,7 +377,6 @@ func TestDiffLatest(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("foo", "0.1.0"), }, }, @@ -342,7 +386,6 @@ func TestDiffLatest(t *testing.T) { Package: "etcd", Image: "reg/etcd:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("etcd", "0.9.1"), }, }, @@ -353,6 +396,14 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "etcd", DefaultChannel: "stable"}, {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, + Channels: []Channel{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.1.0"}, + }}}}, + {Schema: schemaChannel, Name: "stable", Package: "etcd", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "etcd.v0.9.1"}, + }}}}, + }, Bundles: []Bundle{ { Schema: schemaBundle, @@ -360,7 +411,6 @@ func TestDiffLatest(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("foo", "0.1.0"), property.MustBuildPackageRequired("etcd", ">=0.9.0"), }, @@ -371,7 +421,6 @@ func TestDiffLatest(t *testing.T) { Package: "etcd", Image: "reg/etcd:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("etcd", "0.9.1"), }, }, @@ -407,6 +456,11 @@ func TestDiffLatest(t *testing.T) { Packages: []Package{ {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, + Channels: []Channel{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.1.0"}, + }}}}, + }, Bundles: []Bundle{ { Schema: schemaBundle, @@ -414,7 +468,6 @@ func TestDiffLatest(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("foo", "0.1.0"), }, }, @@ -425,6 +478,14 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "etcd", DefaultChannel: "stable"}, {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, + Channels: []Channel{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.1.0"}, + }}}}, + {Schema: schemaChannel, Name: "stable", Package: "etcd", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "etcd.v0.9.1"}, + }}}}, + }, Bundles: []Bundle{ { Schema: schemaBundle, @@ -432,7 +493,6 @@ func TestDiffLatest(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("foo", "0.1.0"), property.MustBuildPackageRequired("etcd", ">=0.9.0"), }, @@ -443,7 +503,6 @@ func TestDiffLatest(t *testing.T) { Package: "etcd", Image: "reg/etcd:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("etcd", "0.9.1"), }, }, @@ -492,6 +551,11 @@ func TestDiffLatest(t *testing.T) { Packages: []Package{ {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, + Channels: []Channel{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.1.0"}, + }}}}, + }, Bundles: []Bundle{ { Schema: schemaBundle, @@ -499,7 +563,6 @@ func TestDiffLatest(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("foo", "0.1.0"), }, }, @@ -510,6 +573,17 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "etcd", DefaultChannel: "stable"}, {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, + Channels: []Channel{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.1.0"}, + }}}}, + {Schema: schemaChannel, Name: "clusterwide", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.1.0-clusterwide"}, + }}}}, + {Schema: schemaChannel, Name: "stable", Package: "etcd", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "etcd.v0.9.1"}, + }}}}, + }, Bundles: []Bundle{ { Schema: schemaBundle, @@ -517,7 +591,6 @@ func TestDiffLatest(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("foo", "0.1.0"), }, }, @@ -527,7 +600,6 @@ func TestDiffLatest(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("clusterwide", ""), property.MustBuildPackage("foo", "0.1.0-clusterwide"), property.MustBuildPackageRequired("etcd", ">=0.9.0"), }, @@ -538,7 +610,6 @@ func TestDiffLatest(t *testing.T) { Package: "etcd", Image: "reg/etcd:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("etcd", "0.9.1"), }, }, @@ -588,6 +659,14 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "etcd", DefaultChannel: "stable"}, {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, + Channels: []Channel{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.1.0"}, + }}}}, + {Schema: schemaChannel, Name: "stable", Package: "etcd", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "etcd.v0.9.1"}, + }}}}, + }, Bundles: []Bundle{ { Schema: schemaBundle, @@ -595,7 +674,6 @@ func TestDiffLatest(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("foo", "0.1.0"), property.MustBuildPackageRequired("etcd", ">=0.9.1"), }, @@ -606,7 +684,6 @@ func TestDiffLatest(t *testing.T) { Package: "etcd", Image: "reg/etcd:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("etcd", "0.9.1"), }, }, @@ -617,6 +694,15 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "etcd", DefaultChannel: "stable"}, {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, + Channels: []Channel{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.1.0"}, + }}}}, + {Schema: schemaChannel, Name: "stable", Package: "etcd", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "etcd.v0.9.1"}, + {Name: "etcd.v0.9.2", Replaces: "etcd.v0.9.1"}, + }}}}, + }, Bundles: []Bundle{ { Schema: schemaBundle, @@ -624,7 +710,6 @@ func TestDiffLatest(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("foo", "0.1.0"), property.MustBuildPackageRequired("etcd", ">=0.9.1"), }, @@ -635,7 +720,6 @@ func TestDiffLatest(t *testing.T) { Package: "etcd", Image: "reg/etcd:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("etcd", "0.9.1"), }, }, @@ -645,7 +729,6 @@ func TestDiffLatest(t *testing.T) { Package: "etcd", Image: "reg/etcd:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", "etcd.v0.9.1"), property.MustBuildPackage("etcd", "0.9.2"), }, }, @@ -680,6 +763,11 @@ func TestDiffLatest(t *testing.T) { Packages: []Package{ {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, + Channels: []Channel{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.1.0"}, + }}}}, + }, Bundles: []Bundle{ { Schema: schemaBundle, @@ -687,7 +775,6 @@ func TestDiffLatest(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("foo", "0.1.0"), }, }, @@ -698,6 +785,16 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "etcd", DefaultChannel: "stable"}, {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, + Channels: []Channel{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.1.0"}, + {Name: "foo.v0.2.0", Replaces: "foo.v0.1.0"}, + }}}}, + {Schema: schemaChannel, Name: "stable", Package: "etcd", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "etcd.v0.9.1"}, + {Name: "etcd.v0.9.2", Replaces: "etcd.v0.9.1"}, + }}}}, + }, Bundles: []Bundle{ { Schema: schemaBundle, @@ -705,7 +802,6 @@ func TestDiffLatest(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("foo", "0.1.0"), property.MustBuildPackageRequired("etcd", ">=0.9.0 <0.9.2"), }, @@ -716,7 +812,6 @@ func TestDiffLatest(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", "foo.v0.1.0"), property.MustBuildPackage("foo", "0.2.0"), property.MustBuildPackageRequired("etcd", ">=0.9.2"), }, @@ -727,7 +822,6 @@ func TestDiffLatest(t *testing.T) { Package: "etcd", Image: "reg/etcd:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("etcd", "0.9.1"), }, }, @@ -737,7 +831,6 @@ func TestDiffLatest(t *testing.T) { Package: "etcd", Image: "reg/etcd:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", "etcd.v0.9.1"), property.MustBuildPackage("etcd", "0.9.2"), }, }, @@ -807,6 +900,11 @@ func TestDiffLatest(t *testing.T) { Packages: []Package{ {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, + Channels: []Channel{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.1.0"}, + }}}}, + }, Bundles: []Bundle{ { Schema: schemaBundle, @@ -814,7 +912,6 @@ func TestDiffLatest(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("foo", "0.1.0"), }, }, @@ -825,6 +922,14 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "etcd", DefaultChannel: "stable"}, {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, + Channels: []Channel{ + {Schema: schemaChannel, Name: "stable", Package: "etcd", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "etcd.v0.9.1"}, + }}}}, + {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.1.0"}, + }}}}, + }, Bundles: []Bundle{ { Schema: schemaBundle, @@ -832,7 +937,6 @@ func TestDiffLatest(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildGVKRequired("etcd.database.coreos.com", "v1beta2", "EtcdBackup"), property.MustBuildPackage("foo", "0.1.0"), }, @@ -843,7 +947,6 @@ func TestDiffLatest(t *testing.T) { Package: "etcd", Image: "reg/etcd:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildGVK("etcd.database.coreos.com", "v1beta2", "EtcdBackup"), property.MustBuildPackage("etcd", "0.9.1"), }, @@ -933,6 +1036,11 @@ func TestDiffHeadsOnly(t *testing.T) { Packages: []Package{ {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, + Channels: []Channel{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.1.0"}, + }}}}, + }, Bundles: []Bundle{ { Schema: schemaBundle, @@ -940,7 +1048,6 @@ func TestDiffHeadsOnly(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("foo", "0.1.0"), }, }, @@ -976,6 +1083,24 @@ func TestDiffHeadsOnly(t *testing.T) { {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, {Schema: schemaPackage, Name: "etcd", DefaultChannel: "stable"}, }, + Channels: []Channel{ + {Schema: schemaChannel, Name: "stable", Package: "etcd", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "etcd.v0.9.0"}, + {Name: "etcd.v0.9.1", Replaces: "etcd.v0.9.0"}, + }}}}, + {Schema: schemaChannel, Name: "clusterwide", Package: "etcd", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "etcd.v0.9.1-clusterwide"}, + }}}}, + {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.1.0"}, + {Name: "foo.v0.2.0", Replaces: "foo.v0.1.0"}, + }}}}, + {Schema: schemaChannel, Name: "alpha", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.2.0-alpha.0"}, + {Name: "foo.v0.2.0-alpha.1", Replaces: "foo.v0.2.0-alpha.0"}, + {Name: "foo.v0.2.0", Replaces: "foo.v0.2.0-alpha.1"}, + }}}}, + }, Bundles: []Bundle{ { Schema: schemaBundle, @@ -983,7 +1108,6 @@ func TestDiffHeadsOnly(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("foo", "0.1.0"), }, }, @@ -993,8 +1117,6 @@ func TestDiffHeadsOnly(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("alpha", "foo.v0.2.0-alpha.1"), - property.MustBuildChannel("stable", "foo.v0.1.0"), property.MustBuildPackage("foo", "0.2.0"), }, }, @@ -1004,7 +1126,6 @@ func TestDiffHeadsOnly(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("alpha", ""), property.MustBuildPackage("foo", "0.2.0-alpha.0"), }, }, @@ -1014,17 +1135,15 @@ func TestDiffHeadsOnly(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("alpha", "foo.v0.2.0-alpha.0"), property.MustBuildPackage("foo", "0.2.0-alpha.1"), }, }, { Schema: schemaBundle, - Name: "etcd.v0.9.1", + Name: "etcd.v0.9.0", Package: "etcd", Image: "reg/etcd:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackage("etcd", "0.9.1"), }, }, @@ -1034,7 +1153,6 @@ func TestDiffHeadsOnly(t *testing.T) { Package: "etcd", Image: "reg/etcd:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", "etcd.v0.9.0"), property.MustBuildPackage("etcd", "0.9.1"), }, }, @@ -1044,7 +1162,6 @@ func TestDiffHeadsOnly(t *testing.T) { Package: "etcd", Image: "reg/etcd:latest", Properties: []property.Property{ - property.MustBuildChannel("clusterwide", ""), property.MustBuildPackage("etcd", "0.9.1-clusterwide"), }, }, @@ -1110,6 +1227,15 @@ func TestDiffHeadsOnly(t *testing.T) { {Schema: schemaPackage, Name: "etcd", DefaultChannel: "stable"}, {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, + Channels: []Channel{ + {Schema: schemaChannel, Name: "stable", Package: "etcd", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "etcd.v0.9.1"}, + {Name: "etcd.v0.9.2", Replaces: "etcd.v0.9.1"}, + }}}}, + {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Name: "foo.v0.1.0"}, + }}}}, + }, Bundles: []Bundle{ { Schema: schemaBundle, @@ -1117,7 +1243,6 @@ func TestDiffHeadsOnly(t *testing.T) { Package: "foo", Image: "reg/foo:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildPackageRequired("etcd", "<=0.9.1"), property.MustBuildPackage("foo", "0.1.0"), }, @@ -1128,7 +1253,6 @@ func TestDiffHeadsOnly(t *testing.T) { Package: "etcd", Image: "reg/etcd:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", ""), property.MustBuildGVK("etcd.database.coreos.com", "v1beta2", "EtcdBackup"), property.MustBuildPackage("etcd", "0.9.1"), }, @@ -1139,7 +1263,6 @@ func TestDiffHeadsOnly(t *testing.T) { Package: "etcd", Image: "reg/etcd:latest", Properties: []property.Property{ - property.MustBuildChannel("stable", "etcd.v0.9.1"), property.MustBuildGVK("etcd.database.coreos.com", "v1beta2", "EtcdBackup"), property.MustBuildPackage("etcd", "0.9.2"), }, diff --git a/alpha/declcfg/helpers_test.go b/alpha/declcfg/helpers_test.go index a4d1bdde0..f92504154 100644 --- a/alpha/declcfg/helpers_test.go +++ b/alpha/declcfg/helpers_test.go @@ -88,12 +88,6 @@ func buildValidDeclarativeConfig(includeUnrecognized bool) DeclarativeConfig { type bundleOpt func(*Bundle) -func withChannel(name, replaces string) func(*Bundle) { - return func(b *Bundle) { - b.Properties = append(b.Properties, property.MustBuildChannel(name, replaces)) - } -} - func withNoProperties() func(*Bundle) { return func(b *Bundle) { b.Properties = []property.Property{} @@ -181,8 +175,42 @@ func buildTestModel() model.Model { } } +func getBundle(pkg *model.Package, ch *model.Channel, version, replaces string, skips ...string) *model.Bundle { + return &model.Bundle{ + Package: pkg, + Channel: ch, + Name: testBundleName(pkg.Name, version), + Image: testBundleImage(pkg.Name, version), + Properties: []property.Property{ + property.MustBuildPackage(pkg.Name, version), + property.MustBuildBundleObjectRef(filepath.Join("objects", testBundleName(pkg.Name, version)+".csv.yaml")), + property.MustBuildBundleObjectData([]byte(getCRDJSON())), + }, + Replaces: replaces, + Skips: skips, + RelatedImages: []model.RelatedImage{{ + Name: "bundle", + Image: testBundleImage(pkg.Name, version), + }}, + CsvJSON: getCSVJson(pkg.Name, version), + Objects: []string{ + getCSVJson(pkg.Name, version), + getCRDJSON(), + }, + } +} + +func getCSVJson(pkgName, version string) string { + return fmt.Sprintf(`{"kind": "ClusterServiceVersion", "apiVersion": "operators.coreos.com/v1alpha1", "metadata":{"name":%q}}`, testBundleName(pkgName, version)) +} + +func getCRDJSON() string { + return `{"kind": "CustomResourceDefinition", "apiVersion": "apiextensions.k8s.io/v1"}` +} + func buildAnakinPkgModel() *model.Package { pkgName := "anakin" + pkg := &model.Package{ Name: pkgName, Description: testPackageDescription(pkgName), @@ -193,65 +221,27 @@ func buildAnakinPkgModel() *model.Package { Channels: map[string]*model.Channel{}, } - for _, chName := range []string{"light", "dark"} { - ch := &model.Channel{ - Package: pkg, - Name: chName, - Bundles: map[string]*model.Bundle{}, - } - pkg.Channels[ch.Name] = ch + light := &model.Channel{ + Package: pkg, + Name: "light", + Bundles: map[string]*model.Bundle{}, } - pkg.DefaultChannel = pkg.Channels["dark"] - versions := map[string][]property.Channel{ - "0.0.1": {{Name: "light"}, {Name: "dark"}}, - "0.1.0": { - {Name: "light", Replaces: testBundleName(pkgName, "0.0.1")}, - {Name: "dark", Replaces: testBundleName(pkgName, "0.0.1")}, - }, - "0.1.1": {{Name: "dark", Replaces: testBundleName(pkgName, "0.0.1")}}, - } - for version, channels := range versions { - csvJson := fmt.Sprintf(`{"kind": "ClusterServiceVersion", "apiVersion": "operators.coreos.com/v1alpha1", "metadata":{"name":%q}}`, testBundleName(pkgName, version)) - crdJson := `{"kind": "CustomResourceDefinition", "apiVersion": "apiextensions.k8s.io/v1"}` - props := []property.Property{ - property.MustBuildPackage(pkgName, version), - property.MustBuildBundleObjectRef(filepath.Join("objects", testBundleName(pkgName, version)+".csv.yaml")), - property.MustBuildBundleObjectData([]byte(crdJson)), - } - for _, channel := range channels { - ch := pkg.Channels[channel.Name] - bName := testBundleName(pkgName, version) - bImage := testBundleImage(pkgName, version) - var skips []string - if version == "0.1.1" { - skip := testBundleName(pkgName, "0.1.0") - skips = append(skips, skip) - } - - props = append(props) - - bundle := &model.Bundle{ - Package: pkg, - Channel: ch, - Name: bName, - Image: bImage, - Replaces: channel.Replaces, - Skips: skips, - Properties: props, - RelatedImages: []model.RelatedImage{{ - Name: "bundle", - Image: testBundleImage(pkgName, version), - }}, - CsvJSON: csvJson, - Objects: []string{ - csvJson, - crdJson, - }, - } - ch.Bundles[bName] = bundle - } + dark := &model.Channel{ + Package: pkg, + Name: "dark", + Bundles: map[string]*model.Bundle{}, } + light.Bundles[testBundleName(pkgName, "0.0.1")] = getBundle(pkg, light, "0.0.1", "") + light.Bundles[testBundleName(pkgName, "0.1.0")] = getBundle(pkg, light, "0.1.0", testBundleName(pkgName, "0.0.1")) + + dark.Bundles[testBundleName(pkgName, "0.0.1")] = getBundle(pkg, dark, "0.0.1", "") + dark.Bundles[testBundleName(pkgName, "0.1.0")] = getBundle(pkg, dark, "0.1.0", testBundleName(pkgName, "0.0.1")) + dark.Bundles[testBundleName(pkgName, "0.1.1")] = getBundle(pkg, dark, "0.1.1", testBundleName(pkgName, "0.0.1"), testBundleName(pkgName, "0.1.0")) + + pkg.Channels["light"] = light + pkg.Channels["dark"] = dark + pkg.DefaultChannel = pkg.Channels["dark"] return pkg } @@ -266,50 +256,15 @@ func buildBobaFettPkgModel() *model.Package { }, Channels: map[string]*model.Channel{}, } - ch := &model.Channel{ + mando := &model.Channel{ Package: pkg, Name: "mando", Bundles: map[string]*model.Bundle{}, } - pkg.Channels[ch.Name] = ch - pkg.DefaultChannel = ch - - versions := map[string][]property.Channel{ - "1.0.0": {{Name: "mando"}}, - "2.0.0": {{Name: "mando", Replaces: testBundleName(pkgName, "1.0.0")}}, - } - for version, channels := range versions { - csvJson := fmt.Sprintf(`{"kind": "ClusterServiceVersion", "apiVersion": "operators.coreos.com/v1alpha1", "metadata":{"name":%q}}`, testBundleName(pkgName, version)) - crdJson := `{"kind": "CustomResourceDefinition", "apiVersion": "apiextensions.k8s.io/v1"}` - props := []property.Property{ - property.MustBuildPackage(pkgName, version), - property.MustBuildBundleObjectRef(filepath.Join("objects", testBundleName(pkgName, version)+".csv.yaml")), - property.MustBuildBundleObjectData([]byte(crdJson)), - } - for _, channel := range channels { - ch := pkg.Channels[channel.Name] - bName := testBundleName(pkgName, version) - bImage := testBundleImage(pkgName, version) - bundle := &model.Bundle{ - Package: pkg, - Channel: ch, - Name: bName, - Image: bImage, - Replaces: channel.Replaces, - Properties: props, - RelatedImages: []model.RelatedImage{{ - Name: "bundle", - Image: testBundleImage(pkgName, version), - }}, - CsvJSON: csvJson, - Objects: []string{ - csvJson, - crdJson, - }, - } - ch.Bundles[bName] = bundle - } - } + mando.Bundles[testBundleName(pkgName, "1.0.0")] = getBundle(pkg, mando, "1.0.0", "") + mando.Bundles[testBundleName(pkgName, "2.0.0")] = getBundle(pkg, mando, "2.0.0", testBundleName(pkgName, "1.0.0")) + pkg.Channels["mando"] = mando + pkg.DefaultChannel = mando return pkg } diff --git a/alpha/declcfg/model_to_declcfg.go b/alpha/declcfg/model_to_declcfg.go index f34fed36a..d7c306a46 100644 --- a/alpha/declcfg/model_to_declcfg.go +++ b/alpha/declcfg/model_to_declcfg.go @@ -90,16 +90,10 @@ func traverseModelChannels(mpkg model.Package) ([]Channel, []Bundle) { RelatedImages: modelRelatedImagesToRelatedImages(chb.RelatedImages), CsvJSON: chb.CsvJSON, Objects: chb.Objects, + Properties: chb.Properties, } bundleMap[b.Name] = b } - for _, p := range chb.Properties { - // drop olm.channel, olm.skips, and olm.skipRange properties from the declarative config - // representation because we've already created an `olm.channel` blob containing this information. - if p.Type != property.TypeChannel && p.Type != property.TypeSkips && p.Type != property.TypeSkipRange { - b.Properties = append(b.Properties, p) - } - } } // sort channel entries by name diff --git a/alpha/declcfg/model_to_declcfg_test.go b/alpha/declcfg/model_to_declcfg_test.go index d443c062f..a24a70661 100644 --- a/alpha/declcfg/model_to_declcfg_test.go +++ b/alpha/declcfg/model_to_declcfg_test.go @@ -26,6 +26,7 @@ func TestConvertFromModel(t *testing.T) { for _, s := range specs { t.Run(s.name, func(t *testing.T) { s.m.Normalize() + assert.NoError(t, s.m.Validate()) actual := ConvertFromModel(s.m) removeJSONWhitespace(&s.expectCfg) diff --git a/alpha/declcfg/properties.go b/alpha/declcfg/properties.go deleted file mode 100644 index 7688ff8ab..000000000 --- a/alpha/declcfg/properties.go +++ /dev/null @@ -1,32 +0,0 @@ -package declcfg - -import ( - "fmt" - - "github.com/operator-framework/operator-registry/alpha/property" -) - -func parseProperties(props []property.Property) (*property.Properties, error) { - out, err := property.Parse(props) - if err != nil { - return nil, err - } - - channels := map[string]struct{}{} - for _, ch := range out.Channels { - if _, ok := channels[ch.Name]; ok { - return nil, propertyDuplicateError{typ: property.TypeChannel, key: ch.Name} - } - channels[ch.Name] = struct{}{} - } - return out, nil -} - -type propertyDuplicateError struct { - typ string - key string -} - -func (e propertyDuplicateError) Error() string { - return fmt.Sprintf("duplicate property of type %q found with key %q", e.typ, e.key) -} diff --git a/alpha/declcfg/properties_test.go b/alpha/declcfg/properties_test.go deleted file mode 100644 index 6cfea67fc..000000000 --- a/alpha/declcfg/properties_test.go +++ /dev/null @@ -1,73 +0,0 @@ -package declcfg - -import ( - "encoding/json" - "testing" - - "github.com/stretchr/testify/assert" - - "github.com/operator-framework/operator-registry/alpha/property" -) - -func TestParseProperties(t *testing.T) { - type spec struct { - name string - properties []property.Property - expectErrType error - expectProps *property.Properties - } - - specs := []spec{ - { - name: "Error/InvalidChannel", - properties: []property.Property{ - {Type: property.TypeChannel, Value: json.RawMessage(`""`)}, - }, - expectErrType: property.ParseError{}, - }, - { - name: "Error/InvalidSkips", - properties: []property.Property{ - {Type: property.TypeSkips, Value: json.RawMessage(`{}`)}, - }, - expectErrType: property.ParseError{}, - }, - { - name: "Error/DuplicateChannels", - properties: []property.Property{ - property.MustBuildChannel("alpha", "foo.v0.0.3"), - property.MustBuildChannel("beta", "foo.v0.0.3"), - property.MustBuildChannel("alpha", "foo.v0.0.4"), - }, - expectErrType: propertyDuplicateError{}, - }, - { - name: "Success/Valid", - properties: []property.Property{ - property.MustBuildChannel("alpha", "foo.v0.0.3"), - property.MustBuildChannel("beta", "foo.v0.0.4"), - property.MustBuildSkips("foo.v0.0.1"), - property.MustBuildSkips("foo.v0.0.2"), - }, - expectProps: &property.Properties{ - Channels: []property.Channel{ - {Name: "alpha", Replaces: "foo.v0.0.3"}, - {Name: "beta", Replaces: "foo.v0.0.4"}, - }, - Skips: []property.Skips{"foo.v0.0.1", "foo.v0.0.2"}, - }, - }, - } - - for _, s := range specs { - t.Run(s.name, func(t *testing.T) { - props, err := parseProperties(s.properties) - if s.expectErrType != nil { - assert.IsType(t, s.expectErrType, err) - } else { - assert.NoError(t, err) - assert.Equal(t, s.expectProps, props) - } - }) - } -} diff --git a/alpha/model/model_test.go b/alpha/model/model_test.go index e9da20821..c286dcdb4 100644 --- a/alpha/model/model_test.go +++ b/alpha/model/model_test.go @@ -450,9 +450,6 @@ func TestValidators(t *testing.T) { Properties: []property.Property{ property.MustBuildPackage("anakin", "0.1.0"), property.MustBuildGVK("skywalker.me", "v1alpha1", "PodRacer"), - property.MustBuildSkips("anakin.v0.0.2"), - property.MustBuildChannel("light", "anakin.v0.0.1"), - property.MustBuildChannel("dark", "anakin.v0.0.1"), }, }, assertion: require.NoError, @@ -481,7 +478,6 @@ func TestValidators(t *testing.T) { Properties: []property.Property{ property.MustBuildPackage("anakin", "0.1.0"), property.MustBuildGVK("skywalker.me", "v1alpha1", "PodRacer"), - property.MustBuildChannel("light", "anakin.v0.0.1"), property.MustBuildBundleObjectRef("path/to/data"), }, Objects: []string{"testdata"}, @@ -499,7 +495,6 @@ func TestValidators(t *testing.T) { Properties: []property.Property{ property.MustBuildPackage("anakin", "0.1.0"), property.MustBuildGVK("skywalker.me", "v1alpha1", "PodRacer"), - property.MustBuildChannel("light", "anakin.v0.0.1"), }, }, assertion: hasError(`bundle image must be set`), @@ -559,17 +554,13 @@ func TestValidators(t *testing.T) { { name: "Bundle/Error/MissingPackage", v: &Bundle{ - Package: pkg, - Channel: ch, - Name: "anakin.v0.1.0", - Image: "", - Replaces: "anakin.v0.0.1", - Skips: []string{"anakin.v0.0.2"}, - Properties: []property.Property{ - property.MustBuildSkips("anakin.v0.0.2"), - property.MustBuildChannel("light", "anakin.v0.0.1"), - property.MustBuildChannel("dark", "anakin.v0.0.1"), - }, + Package: pkg, + Channel: ch, + Name: "anakin.v0.1.0", + Image: "", + Replaces: "anakin.v0.0.1", + Skips: []string{"anakin.v0.0.2"}, + Properties: []property.Property{}, }, assertion: hasError(`must be exactly one property with type "olm.package"`), }, @@ -585,9 +576,6 @@ func TestValidators(t *testing.T) { Properties: []property.Property{ property.MustBuildPackage("anakin", "0.1.0"), property.MustBuildPackage("anakin", "0.2.0"), - property.MustBuildSkips("anakin.v0.0.2"), - property.MustBuildChannel("light", "anakin.v0.0.1"), - property.MustBuildChannel("dark", "anakin.v0.0.1"), }, }, assertion: hasError(`must be exactly one property with type "olm.package"`), diff --git a/alpha/property/property.go b/alpha/property/property.go index 5806a6475..c8bc6ad78 100644 --- a/alpha/property/property.go +++ b/alpha/property/property.go @@ -44,11 +44,6 @@ type PackageRequired struct { VersionRange string `json:"versionRange"` } -type Channel struct { - Name string `json:"name"` - Replaces string `json:"replaces,omitempty"` -} - type GVK struct { Group string `json:"group"` Kind string `json:"kind"` @@ -61,9 +56,6 @@ type GVKRequired struct { Version string `json:"version"` } -type Skips string -type SkipRange string - type BundleObject struct { File `json:",inline"` } @@ -123,11 +115,8 @@ func (f File) GetData(root fs.FS, cwd string) ([]byte, error) { type Properties struct { Packages []Package `hash:"set"` PackagesRequired []PackageRequired `hash:"set"` - Channels []Channel `hash:"set"` GVKs []GVK `hash:"set"` GVKsRequired []GVKRequired `hash:"set"` - Skips []Skips `hash:"set"` - SkipRanges []SkipRange `hash:"set"` BundleObjects []BundleObject `hash:"set"` Others []Property `hash:"set"` @@ -136,11 +125,8 @@ type Properties struct { const ( TypePackage = "olm.package" TypePackageRequired = "olm.package.required" - TypeChannel = "olm.channel" TypeGVK = "olm.gvk" TypeGVKRequired = "olm.gvk.required" - TypeSkips = "olm.skips" - TypeSkipRange = "olm.skipRange" TypeBundleObject = "olm.bundle.object" ) @@ -160,12 +146,6 @@ func Parse(in []Property) (*Properties, error) { return nil, ParseError{Idx: i, Typ: prop.Type, Err: err} } out.PackagesRequired = append(out.PackagesRequired, p) - case TypeChannel: - var p Channel - if err := json.Unmarshal(prop.Value, &p); err != nil { - return nil, ParseError{Idx: i, Typ: prop.Type, Err: err} - } - out.Channels = append(out.Channels, p) case TypeGVK: var p GVK if err := json.Unmarshal(prop.Value, &p); err != nil { @@ -178,18 +158,6 @@ func Parse(in []Property) (*Properties, error) { return nil, ParseError{Idx: i, Typ: prop.Type, Err: err} } out.GVKsRequired = append(out.GVKsRequired, p) - case TypeSkips: - var p Skips - if err := json.Unmarshal(prop.Value, &p); err != nil { - return nil, ParseError{Idx: i, Typ: prop.Type, Err: err} - } - out.Skips = append(out.Skips, p) - case TypeSkipRange: - var p SkipRange - if err := json.Unmarshal(prop.Value, &p); err != nil { - return nil, ParseError{Idx: i, Typ: prop.Type, Err: err} - } - out.SkipRanges = append(out.SkipRanges, p) case TypeBundleObject: var p BundleObject if err := json.Unmarshal(prop.Value, &p); err != nil { @@ -285,23 +253,12 @@ func MustBuildPackage(name, version string) Property { func MustBuildPackageRequired(name, versionRange string) Property { return MustBuild(&PackageRequired{name, versionRange}) } -func MustBuildChannel(name, replaces string) Property { - return MustBuild(&Channel{name, replaces}) -} func MustBuildGVK(group, version, kind string) Property { return MustBuild(&GVK{group, kind, version}) } func MustBuildGVKRequired(group, version, kind string) Property { return MustBuild(&GVKRequired{group, kind, version}) } -func MustBuildSkips(skips string) Property { - s := Skips(skips) - return MustBuild(&s) -} -func MustBuildSkipRange(skipRange string) Property { - s := SkipRange(skipRange) - return MustBuild(&s) -} func MustBuildBundleObjectRef(ref string) Property { return MustBuild(&BundleObject{File: File{ref: ref}}) } diff --git a/alpha/property/property_test.go b/alpha/property/property_test.go index ab3d1fdc2..8c24f8016 100644 --- a/alpha/property/property_test.go +++ b/alpha/property/property_test.go @@ -246,13 +246,6 @@ func TestParse(t *testing.T) { }, assertion: assert.Error, }, - { - name: "Error/InvalidChannel", - input: []Property{ - {Type: TypeChannel, Value: json.RawMessage(`{`)}, - }, - assertion: assert.Error, - }, { name: "Error/InvalidGVK", input: []Property{ @@ -267,20 +260,6 @@ func TestParse(t *testing.T) { }, assertion: assert.Error, }, - { - name: "Error/InvalidSkips", - input: []Property{ - {Type: TypeSkips, Value: json.RawMessage(`{`)}, - }, - assertion: assert.Error, - }, - { - name: "Error/InvalidSkipRange", - input: []Property{ - {Type: TypeSkipRange, Value: json.RawMessage(`{`)}, - }, - assertion: assert.Error, - }, { name: "Error/InvalidBundleObject", input: []Property{ @@ -302,16 +281,10 @@ func TestParse(t *testing.T) { MustBuildPackage("package2", "0.2.0"), MustBuildPackageRequired("package3", ">=1.0.0 <2.0.0-0"), MustBuildPackageRequired("package4", ">=2.0.0 <3.0.0-0"), - MustBuildChannel("testChannel1", ""), - MustBuildChannel("testChannel2", "replaces2"), MustBuildGVK("group", "v1", "Kind1"), MustBuildGVK("group", "v1", "Kind2"), MustBuildGVKRequired("other", "v2", "Kind3"), MustBuildGVKRequired("other", "v2", "Kind4"), - MustBuildSkips("package1.v0.0.1"), - MustBuildSkips("package2.v0.1.1"), - MustBuildSkipRange("<0.1.0-0"), - MustBuildSkipRange("<0.2.0-0"), MustBuildBundleObjectRef("testref1"), MustBuildBundleObjectData([]byte("testdata2")), {Type: "otherType1", Value: json.RawMessage(`{"v":"otherValue1"}`)}, @@ -326,10 +299,6 @@ func TestParse(t *testing.T) { {"package3", ">=1.0.0 <2.0.0-0"}, {"package4", ">=2.0.0 <3.0.0-0"}, }, - Channels: []Channel{ - {"testChannel1", ""}, - {"testChannel2", "replaces2"}, - }, GVKs: []GVK{ {"group", "Kind1", "v1"}, {"group", "Kind2", "v1"}, @@ -338,14 +307,6 @@ func TestParse(t *testing.T) { {"other", "Kind3", "v2"}, {"other", "Kind4", "v2"}, }, - Skips: []Skips{ - "package1.v0.0.1", - "package2.v0.1.1", - }, - SkipRanges: []SkipRange{ - "<0.1.0-0", - "<0.2.0-0", - }, BundleObjects: []BundleObject{ {File: File{ref: "testref1"}}, {File: File{data: []byte("testdata2")}}, @@ -378,55 +339,15 @@ func TestDeduplicate(t *testing.T) { name: "Identical", input: []Property{ MustBuildPackage("package1", "0.1.0"), - MustBuildChannel("channel", "replaces"), - MustBuildChannel("channel", "replaces"), MustBuildGVK("group", "v1", "Kind"), MustBuildGVK("group", "v1", "Kind"), MustBuildGVK("group", "v1", "Kind"), }, expectProps: []Property{ MustBuildPackage("package1", "0.1.0"), - MustBuildChannel("channel", "replaces"), MustBuildGVK("group", "v1", "Kind"), }, }, - { - name: "SameTypeDifferentValue", - input: []Property{ - MustBuildPackage("package1", "0.1.0"), - MustBuildChannel("channel", "replaces"), - MustBuildChannel("channel", "replacesDifferent"), - MustBuildGVK("group", "v1", "Kind"), - MustBuildGVK("group", "v1", "Kind"), - MustBuildGVK("group", "v1", "Kind"), - }, - expectProps: []Property{ - MustBuildPackage("package1", "0.1.0"), - MustBuildChannel("channel", "replaces"), - MustBuildChannel("channel", "replacesDifferent"), - MustBuildGVK("group", "v1", "Kind"), - }, - }, - { - name: "SameValueDifferentType", - input: []Property{ - MustBuildPackage("package1", "0.1.0"), - MustBuildChannel("channel", "replaces"), - MustBuildChannel("channel", "replaces"), - MustBuildGVK("group", "v1", "Kind"), - MustBuildGVK("group", "v1", "Kind"), - MustBuildGVK("group", "v1", "Kind"), - MustBuildSkips("sameValue"), - MustBuildSkipRange("sameValue"), - }, - expectProps: []Property{ - MustBuildPackage("package1", "0.1.0"), - MustBuildChannel("channel", "replaces"), - MustBuildGVK("group", "v1", "Kind"), - MustBuildSkips("sameValue"), - MustBuildSkipRange("sameValue"), - }, - }, } for _, s := range specs { t.Run(s.name, func(t *testing.T) { @@ -456,12 +377,6 @@ func TestBuild(t *testing.T) { assertion: require.NoError, expectedProperty: propPtr(MustBuildPackageRequired("name", ">=0.1.0")), }, - { - name: "Success/Channel", - input: &Channel{"name", "replaces"}, - assertion: require.NoError, - expectedProperty: propPtr(MustBuildChannel("name", "replaces")), - }, { name: "Success/GVK", input: &GVK{"group", "Kind", "v1"}, @@ -474,18 +389,6 @@ func TestBuild(t *testing.T) { assertion: require.NoError, expectedProperty: propPtr(MustBuildGVKRequired("group", "v1", "Kind")), }, - { - name: "Success/Skips", - input: skipsPtr("test"), - assertion: require.NoError, - expectedProperty: propPtr(MustBuildSkips("test")), - }, - { - name: "Success/SkipRange", - input: skipRangePtr("test"), - assertion: require.NoError, - expectedProperty: propPtr(MustBuildSkipRange("test")), - }, { name: "Success/BundleObject", input: &BundleObject{File: File{ref: "test"}}, @@ -524,16 +427,10 @@ func TestBuild(t *testing.T) { } func TestMustBuild(t *testing.T) { - assert.NotPanics(t, func() { MustBuild(&Channel{}) }) - assert.Panics(t, func() { MustBuild(Channel{}) }) + assert.NotPanics(t, func() { MustBuild(&Package{}) }) + assert.Panics(t, func() { MustBuild(Package{}) }) } func propPtr(in Property) *Property { return &in } -func skipsPtr(in Skips) *Skips { - return &in -} -func skipRangePtr(in SkipRange) *SkipRange { - return &in -} diff --git a/alpha/property/scheme.go b/alpha/property/scheme.go index c2fc7d3b9..b2d893660 100644 --- a/alpha/property/scheme.go +++ b/alpha/property/scheme.go @@ -6,17 +6,11 @@ import ( ) func init() { - skips := Skips("") - skipRange := SkipRange("") - scheme = map[reflect.Type]string{ reflect.TypeOf(&Package{}): TypePackage, reflect.TypeOf(&PackageRequired{}): TypePackageRequired, - reflect.TypeOf(&Channel{}): TypeChannel, reflect.TypeOf(&GVK{}): TypeGVK, reflect.TypeOf(&GVKRequired{}): TypeGVKRequired, - reflect.TypeOf(&skips): TypeSkips, - reflect.TypeOf(&skipRange): TypeSkipRange, reflect.TypeOf(&BundleObject{}): TypeBundleObject, } } diff --git a/pkg/lib/indexer/index.Dockerfile047416381 b/pkg/lib/indexer/index.Dockerfile047416381 new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/lib/indexer/index.Dockerfile062873339 b/pkg/lib/indexer/index.Dockerfile062873339 new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/lib/indexer/index.Dockerfile622193597 b/pkg/lib/indexer/index.Dockerfile622193597 new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/registry/query_test.go b/pkg/registry/query_test.go index 4d487aa5d..be153aa21 100644 --- a/pkg/registry/query_test.go +++ b/pkg/registry/query_test.go @@ -201,18 +201,50 @@ var validFS = fstest.MapFS{ "mediatype": "image/svg+xml" } } +{ + "schema": "olm.channel", + "package": "cockroachdb", + "name": "stable", + "strategy": { + "legacy": { + "entries": [ + {"name": "cockroachdb.v2.0.9"}, + {"name": "cockroachdb.v2.1.1", "replaces": "cockroachdb.v2.0.9"}, + {"name": "cockroachdb.v2.1.11", "replaces": "cockroachdb.v2.1.1"} + ] + } + } +} +{ + "schema": "olm.channel", + "package": "cockroachdb", + "name": "stable-3.x", + "strategy": { + "legacy": { + "entries": [ + {"name": "cockroachdb.v3.0.7"} + ] + } + } +} +{ + "schema": "olm.channel", + "package": "cockroachdb", + "name": "stable-5.x", + "strategy": { + "legacy": { + "entries": [ + {"name": "cockroachdb.v5.0.3"} + ] + } + } +} { "schema": "olm.bundle", "name": "cockroachdb.v2.0.9", "package": "cockroachdb", "image": "quay.io/openshift-community-operators/cockroachdb:v2.0.9", "properties": [ - { - "type": "olm.channel", - "value": { - "name": "stable" - } - }, { "type": "olm.package", "value": { @@ -228,13 +260,6 @@ var validFS = fstest.MapFS{ "package": "cockroachdb", "image": "quay.io/openshift-community-operators/cockroachdb:v2.1.11", "properties": [ - { - "type": "olm.channel", - "value": { - "name": "stable", - "replaces": "cockroachdb.v2.1.1" - } - }, { "type": "olm.package", "value": { @@ -250,13 +275,6 @@ var validFS = fstest.MapFS{ "package": "cockroachdb", "image": "quay.io/openshift-community-operators/cockroachdb:v2.1.1", "properties": [ - { - "type": "olm.channel", - "value": { - "name": "stable", - "replaces": "cockroachdb.v2.0.9" - } - }, { "type": "olm.package", "value": { @@ -320,6 +338,46 @@ var validFS = fstest.MapFS{ }, "description": "A message about etcd operator, a description of channels" } +{ + "schema": "olm.channel", + "package": "etcd", + "name": "alpha", + "strategy": { + "legacy": { + "entries": [ + {"name": "etcdoperator-community.v0.6.1"} + ] + } + } +} +{ + "schema": "olm.channel", + "package": "etcd", + "name": "singlenamespace-alpha", + "strategy": { + "legacy": { + "entries": [ + {"name": "etcdoperator.v0.9.0"}, + {"name": "etcdoperator.v0.9.2", "replaces": "etcdoperator.v0.9.0"}, + {"name": "etcdoperator.v0.9.4", "replaces": "etcdoperator.v0.9.2"} + ] + } + } +} +{ + "schema": "olm.channel", + "package": "etcd", + "name": "clusterwide-alpha", + "strategy": { + "legacy": { + "entries": [ + {"name": "etcdoperator.v0.9.0"}, + {"name": "etcdoperator.v0.9.2-clusterwide", "replaces": "etcdoperator.v0.9.0", "skips": ["etcdoperator.v0.6.1","etcdoperator.v0.9.0"], "skipRange": ">=0.9.0 <=0.9.1"}, + {"name": "etcdoperator.v0.9.4-clusterwide", "replaces": "etcdoperator.v0.9.2-clusterwide"} + ] + } + } +} { "schema": "olm.bundle", "name": "etcdoperator-community.v0.6.1", @@ -340,12 +398,6 @@ var validFS = fstest.MapFS{ "kind": "EtcdCluster", "version": "v1beta2" } - }, - { - "type": "olm.channel", - "value": { - "name": "alpha" - } } ], "relatedImages": [ @@ -375,18 +427,6 @@ var validFS = fstest.MapFS{ "kind": "EtcdBackup", "version": "v1beta2" } - }, - { - "type": "olm.channel", - "value": { - "name": "singlenamespace-alpha" - } - }, - { - "type": "olm.channel", - "value": { - "name": "clusterwide-alpha" - } } ], "relatedImages" : [ @@ -416,13 +456,6 @@ var validFS = fstest.MapFS{ "kind": "EtcdRestore", "version": "v1beta2" } - }, - { - "type": "olm.channel", - "value": { - "name": "singlenamespace-alpha", - "replaces": "etcdoperator.v0.9.0" - } } ], "relatedImages":[ @@ -452,25 +485,6 @@ var validFS = fstest.MapFS{ "kind": "EtcdBackup", "version": "v1beta2" } - }, - { - "type": "olm.skipRange", - "value": ">=0.9.0 <=0.9.1" - }, - { - "type": "olm.skips", - "value" : "etcdoperator.v0.6.1" - }, - { - "type": "olm.skips", - "value" : "etcdoperator.v0.9.0" - }, - { - "type": "olm.channel", - "value": { - "name": "clusterwide-alpha", - "replaces": "etcdoperator.v0.9.0" - } } ], "relatedImages":[ @@ -515,13 +529,6 @@ var validFS = fstest.MapFS{ "kind": "Testapi", "version": "v1" } - }, - { - "type": "olm.channel", - "value": { - "name": "singlenamespace-alpha", - "replaces": "etcdoperator.v0.9.2" - } } ], "relatedImages":[ @@ -551,13 +558,6 @@ var validFS = fstest.MapFS{ "kind": "EtcdBackup", "version": "v1beta2" } - }, - { - "type": "olm.channel", - "value": { - "name": "clusterwide-alpha", - "replaces": "etcdoperator.v0.9.2-clusterwide" - } } ], "relatedImages":[ diff --git a/pkg/registry/registry_to_model_test.go b/pkg/registry/registry_to_model_test.go index 916e9b588..265894b02 100644 --- a/pkg/registry/registry_to_model_test.go +++ b/pkg/registry/registry_to_model_test.go @@ -31,10 +31,7 @@ func testModelBundle() model.Bundle { Replaces: "etcdoperator.v0.9.0", Skips: []string{"etcdoperator.v0.9.1"}, Properties: []property.Property{ - property.MustBuildChannel("alpha", "etcdoperator.v0.9.0"), - property.MustBuildChannel("stable", "etcdoperator.v0.9.0"), property.MustBuildPackage("etcd", "0.9.2"), - property.MustBuildSkips("etcdoperator.v0.9.1"), property.MustBuildGVKRequired("etcd.database.coreos.com", "v1beta2", "EtcdCluster"), property.MustBuildGVKRequired("testapi.coreos.com", "v1", "testapi"), property.MustBuildGVK("etcd.database.coreos.com", "v1beta2", "EtcdCluster"), From ca53411042ffb4762c83c087ce18f051c49cc00d Mon Sep 17 00:00:00 2001 From: Joe Lanford Date: Wed, 1 Sep 2021 15:26:06 -0400 Subject: [PATCH 4/5] remove strategy.legacy layer from olm.channel schema Signed-off-by: Joe Lanford --- alpha/action/render_test.go | 32 +-- .../foo-index-v0.2.0-declcfg/foo/index.yaml | 37 ++- .../index-declcfgs/exp-headsonly/index.yaml | 47 ++-- .../index-declcfgs/exp-latest/index.yaml | 38 ++- .../testdata/index-declcfgs/latest/index.yaml | 82 +++--- .../testdata/index-declcfgs/old/index.yaml | 56 ++--- .../action/testdata/list-index/bar/index.yaml | 36 ++- .../action/testdata/list-index/foo/index.yaml | 36 ++- alpha/declcfg/declcfg.go | 18 +- alpha/declcfg/declcfg_to_model.go | 5 +- alpha/declcfg/declcfg_to_model_test.go | 29 +-- alpha/declcfg/diff_test.go | 236 +++++++++--------- alpha/declcfg/helpers_test.go | 24 +- alpha/declcfg/model_to_declcfg.go | 12 +- alpha/declcfg/write_test.go | 110 ++++---- pkg/registry/query_test.go | 72 ++---- 16 files changed, 381 insertions(+), 489 deletions(-) diff --git a/alpha/action/render_test.go b/alpha/action/render_test.go index b908b8d21..40cef5250 100644 --- a/alpha/action/render_test.go +++ b/alpha/action/render_test.go @@ -76,14 +76,14 @@ func TestRender(t *testing.T) { }, }, Channels: []declcfg.Channel{ - {Schema: "olm.channel", Package: "foo", Name: "beta", Strategy: declcfg.ChannelStrategy{Legacy: &declcfg.LegacyChannelStrategy{Entries: []declcfg.LegacyChannelEntry{ + {Schema: "olm.channel", Package: "foo", Name: "beta", Entries: []declcfg.ChannelEntry{ {Name: "foo.v0.1.0", SkipRange: "<0.1.0"}, {Name: "foo.v0.2.0", Replaces: "foo.v0.1.0", SkipRange: "<0.2.0", Skips: []string{"foo.v0.1.1", "foo.v0.1.2"}}, - }}}}, - {Schema: "olm.channel", Package: "foo", Name: "stable", Strategy: declcfg.ChannelStrategy{Legacy: &declcfg.LegacyChannelStrategy{Entries: []declcfg.LegacyChannelEntry{ + }}, + {Schema: "olm.channel", Package: "foo", Name: "stable", Entries: []declcfg.ChannelEntry{ {Name: "foo.v0.1.0", SkipRange: "<0.1.0"}, {Name: "foo.v0.2.0", Replaces: "foo.v0.1.0", SkipRange: "<0.2.0", Skips: []string{"foo.v0.1.1", "foo.v0.1.2"}}, - }}}}, + }}, }, Bundles: []declcfg.Bundle{ { @@ -168,14 +168,14 @@ func TestRender(t *testing.T) { }, }, Channels: []declcfg.Channel{ - {Schema: "olm.channel", Package: "foo", Name: "beta", Strategy: declcfg.ChannelStrategy{Legacy: &declcfg.LegacyChannelStrategy{Entries: []declcfg.LegacyChannelEntry{ + {Schema: "olm.channel", Package: "foo", Name: "beta", Entries: []declcfg.ChannelEntry{ {Name: "foo.v0.1.0", SkipRange: "<0.1.0"}, {Name: "foo.v0.2.0", Replaces: "foo.v0.1.0", SkipRange: "<0.2.0", Skips: []string{"foo.v0.1.1", "foo.v0.1.2"}}, - }}}}, - {Schema: "olm.channel", Package: "foo", Name: "stable", Strategy: declcfg.ChannelStrategy{Legacy: &declcfg.LegacyChannelStrategy{Entries: []declcfg.LegacyChannelEntry{ + }}, + {Schema: "olm.channel", Package: "foo", Name: "stable", Entries: []declcfg.ChannelEntry{ {Name: "foo.v0.1.0", SkipRange: "<0.1.0"}, {Name: "foo.v0.2.0", Replaces: "foo.v0.1.0", SkipRange: "<0.2.0", Skips: []string{"foo.v0.1.1", "foo.v0.1.2"}}, - }}}}, + }}, }, Bundles: []declcfg.Bundle{ { @@ -260,13 +260,13 @@ func TestRender(t *testing.T) { }, }, Channels: []declcfg.Channel{ - {Schema: "olm.channel", Package: "foo", Name: "beta", Strategy: declcfg.ChannelStrategy{Legacy: &declcfg.LegacyChannelStrategy{Entries: []declcfg.LegacyChannelEntry{ + {Schema: "olm.channel", Package: "foo", Name: "beta", Entries: []declcfg.ChannelEntry{ {Name: "foo.v0.1.0", SkipRange: "<0.1.0"}, {Name: "foo.v0.2.0", Replaces: "foo.v0.1.0", SkipRange: "<0.2.0", Skips: []string{"foo.v0.1.1", "foo.v0.1.2"}}, - }}}}, - {Schema: "olm.channel", Package: "foo", Name: "stable", Strategy: declcfg.ChannelStrategy{Legacy: &declcfg.LegacyChannelStrategy{Entries: []declcfg.LegacyChannelEntry{ + }}, + {Schema: "olm.channel", Package: "foo", Name: "stable", Entries: []declcfg.ChannelEntry{ {Name: "foo.v0.2.0", Replaces: "foo.v0.1.0", SkipRange: "<0.2.0", Skips: []string{"foo.v0.1.1", "foo.v0.1.2"}}, - }}}}, + }}, }, Bundles: []declcfg.Bundle{ { @@ -351,13 +351,13 @@ func TestRender(t *testing.T) { }, }, Channels: []declcfg.Channel{ - {Schema: "olm.channel", Package: "foo", Name: "beta", Strategy: declcfg.ChannelStrategy{Legacy: &declcfg.LegacyChannelStrategy{Entries: []declcfg.LegacyChannelEntry{ + {Schema: "olm.channel", Package: "foo", Name: "beta", Entries: []declcfg.ChannelEntry{ {Name: "foo.v0.1.0", SkipRange: "<0.1.0"}, {Name: "foo.v0.2.0", Replaces: "foo.v0.1.0", SkipRange: "<0.2.0", Skips: []string{"foo.v0.1.1", "foo.v0.1.2"}}, - }}}}, - {Schema: "olm.channel", Package: "foo", Name: "stable", Strategy: declcfg.ChannelStrategy{Legacy: &declcfg.LegacyChannelStrategy{Entries: []declcfg.LegacyChannelEntry{ + }}, + {Schema: "olm.channel", Package: "foo", Name: "stable", Entries: []declcfg.ChannelEntry{ {Name: "foo.v0.2.0", Replaces: "foo.v0.1.0", SkipRange: "<0.2.0", Skips: []string{"foo.v0.1.1", "foo.v0.1.2"}}, - }}}}, + }}, }, Bundles: []declcfg.Bundle{ { diff --git a/alpha/action/testdata/foo-index-v0.2.0-declcfg/foo/index.yaml b/alpha/action/testdata/foo-index-v0.2.0-declcfg/foo/index.yaml index 75cb7a932..7a126ee50 100644 --- a/alpha/action/testdata/foo-index-v0.2.0-declcfg/foo/index.yaml +++ b/alpha/action/testdata/foo-index-v0.2.0-declcfg/foo/index.yaml @@ -6,31 +6,26 @@ defaultChannel: beta schema: olm.channel package: foo name: beta -strategy: - legacy: - entries: - - name: foo.v0.1.0 - skipRange: <0.1.0 - - name: foo.v0.2.0 - replaces: foo.v0.1.0 - skipRange: <0.2.0 - skips: - - foo.v0.1.1 - - foo.v0.1.2 +entries: + - name: foo.v0.1.0 + skipRange: <0.1.0 + - name: foo.v0.2.0 + replaces: foo.v0.1.0 + skipRange: <0.2.0 + skips: + - foo.v0.1.1 + - foo.v0.1.2 --- schema: olm.channel package: foo name: stable -strategy: - legacy: - entries: - - name: foo.v0.2.0 - replaces: foo.v0.1.0 - skipRange: <0.2.0 - skips: - - foo.v0.1.1 - - foo.v0.1.2 - +entries: + - name: foo.v0.2.0 + replaces: foo.v0.1.0 + skipRange: <0.2.0 + skips: + - foo.v0.1.1 + - foo.v0.1.2 --- schema: olm.bundle package: foo diff --git a/alpha/action/testdata/index-declcfgs/exp-headsonly/index.yaml b/alpha/action/testdata/index-declcfgs/exp-headsonly/index.yaml index 19ed3576b..f3b349d64 100644 --- a/alpha/action/testdata/index-declcfgs/exp-headsonly/index.yaml +++ b/alpha/action/testdata/index-declcfgs/exp-headsonly/index.yaml @@ -6,23 +6,19 @@ schema: olm.package name: alpha package: bar schema: olm.channel -strategy: - legacy: - entries: - - name: bar.v0.1.0 - - name: bar.v0.2.0 - skips: - - bar.v0.1.0 - - name: bar.v1.0.0 - replaces: bar.v0.2.0 +entries: + - name: bar.v0.1.0 + - name: bar.v0.2.0 + skips: + - bar.v0.1.0 + - name: bar.v1.0.0 + replaces: bar.v0.2.0 --- name: stable package: bar schema: olm.channel -strategy: - legacy: - entries: - - name: bar.v1.0.0 +entries: + - name: bar.v1.0.0 --- # Added because foo.v0.3.1 depends on bar <0.2.0 image: test.registry/bar-operator/bar-bundle:v0.1.0 @@ -112,13 +108,11 @@ schema: olm.package name: stable package: baz schema: olm.channel -strategy: - legacy: - entries: - - name: baz.v1.1.0 - replaces: baz.v1.0.0 - skips: - - baz.v1.0.1 +entries: + - name: baz.v1.1.0 + replaces: baz.v1.0.0 + skips: + - baz.v1.0.1 --- image: test.registry/baz-operator/baz-bundle:v1.1.0 name: baz.v1.1.0 @@ -151,13 +145,11 @@ schema: olm.package name: beta package: foo schema: olm.channel -strategy: - legacy: - entries: - - name: foo.v0.3.1 - replaces: foo.v0.2.0 - skips: - - foo.v0.3.0 +entries: + - name: foo.v0.3.1 + replaces: foo.v0.2.0 + skips: + - foo.v0.3.0 --- image: test.registry/foo-operator/foo-bundle:v0.3.1 name: foo.v0.3.1 @@ -190,6 +182,7 @@ properties: version: 0.3.1 - type: olm.package.required value: + packageName: bar packageName: bar versionRange: <0.2.0 relatedImages: diff --git a/alpha/action/testdata/index-declcfgs/exp-latest/index.yaml b/alpha/action/testdata/index-declcfgs/exp-latest/index.yaml index 9a92d816d..8911e9a15 100644 --- a/alpha/action/testdata/index-declcfgs/exp-latest/index.yaml +++ b/alpha/action/testdata/index-declcfgs/exp-latest/index.yaml @@ -6,19 +6,15 @@ schema: olm.package name: alpha package: bar schema: olm.channel -strategy: - legacy: - entries: - - name: bar.v1.0.0 - replaces: bar.v0.2.0 +entries: + - name: bar.v1.0.0 + replaces: bar.v0.2.0 --- name: stable package: bar schema: olm.channel -strategy: - legacy: - entries: - - name: bar.v1.0.0 +entries: + - name: bar.v1.0.0 --- image: test.registry/bar-operator/bar-bundle:v1.0.0 name: bar.v1.0.0 @@ -56,13 +52,11 @@ schema: olm.package name: stable package: baz schema: olm.channel -strategy: - legacy: - entries: - - name: baz.v1.1.0 - replaces: baz.v1.0.0 - skips: - - baz.v1.0.1 +entries: + - name: baz.v1.1.0 + replaces: baz.v1.0.0 + skips: + - baz.v1.0.1 --- image: test.registry/baz-operator/baz-bundle:v1.1.0 name: baz.v1.1.0 @@ -95,13 +89,11 @@ schema: olm.package name: beta package: foo schema: olm.channel -strategy: - legacy: - entries: - - name: foo.v0.3.1 - replaces: foo.v0.2.0 - skips: - - foo.v0.3.0 +entries: + - name: foo.v0.3.1 + replaces: foo.v0.2.0 + skips: + - foo.v0.3.0 --- image: test.registry/foo-operator/foo-bundle:v0.3.1 name: foo.v0.3.1 diff --git a/alpha/action/testdata/index-declcfgs/latest/index.yaml b/alpha/action/testdata/index-declcfgs/latest/index.yaml index fe52f39cd..7ef42c6a9 100644 --- a/alpha/action/testdata/index-declcfgs/latest/index.yaml +++ b/alpha/action/testdata/index-declcfgs/latest/index.yaml @@ -6,24 +6,20 @@ schema: olm.package name: alpha package: bar schema: olm.channel -strategy: - legacy: - entries: - - name: bar.v0.1.0 - - name: bar.v0.2.0 - skipRange: <0.2.0 - skips: - - bar.v0.1.0 - - name: bar.v1.0.0 - replaces: bar.v0.2.0 +entries: + - name: bar.v0.1.0 + - name: bar.v0.2.0 + skipRange: <0.2.0 + skips: + - bar.v0.1.0 + - name: bar.v1.0.0 + replaces: bar.v0.2.0 --- name: stable package: bar schema: olm.channel -strategy: - legacy: - entries: - - name: bar.v1.0.0 +entries: + - name: bar.v1.0.0 --- image: test.registry/bar-operator/bar-bundle:v0.1.0 name: bar.v0.1.0 @@ -109,20 +105,18 @@ schema: olm.package schema: olm.channel package: baz name: stable -strategy: - legacy: - entries: - - name: baz.v1.0.0 - skipRange: <1.0.0 - - name: baz.v1.0.1 - replaces: baz.v1.0.0 - skipRange: <1.0.0 - skips: - - baz.v1.0.0 - - name: baz.v1.1.0 - replaces: baz.v1.0.0 - skips: - - baz.v1.0.1 +entries: + - name: baz.v1.0.0 + skipRange: <1.0.0 + - name: baz.v1.0.1 + replaces: baz.v1.0.0 + skipRange: <1.0.0 + skips: + - baz.v1.0.0 + - name: baz.v1.1.0 + replaces: baz.v1.0.0 + skips: + - baz.v1.0.1 --- image: test.registry/baz-operator/baz-bundle:v1.0.0 name: baz.v1.0.0 @@ -203,23 +197,21 @@ schema: olm.package schema: olm.channel package: foo name: beta -strategy: - legacy: - entries: - - name: foo.v0.1.0 - skipRange: <0.1.0 - - name: foo.v0.2.0 - replaces: foo.v0.1.0 - skipRange: <0.2.0 - skips: - - foo.v0.1.1 - - foo.v0.1.2 - - name: foo.v0.3.0 - replaces: foo.v0.2.0 - - name: foo.v0.3.1 - replaces: foo.v0.2.0 - skips: - - foo.v0.3.0 +entries: + - name: foo.v0.1.0 + skipRange: <0.1.0 + - name: foo.v0.2.0 + replaces: foo.v0.1.0 + skipRange: <0.2.0 + skips: + - foo.v0.1.1 + - foo.v0.1.2 + - name: foo.v0.3.0 + replaces: foo.v0.2.0 + - name: foo.v0.3.1 + replaces: foo.v0.2.0 + skips: + - foo.v0.3.0 --- image: test.registry/foo-operator/foo-bundle:v0.1.0 name: foo.v0.1.0 diff --git a/alpha/action/testdata/index-declcfgs/old/index.yaml b/alpha/action/testdata/index-declcfgs/old/index.yaml index e02cc4ff0..4e77597bc 100644 --- a/alpha/action/testdata/index-declcfgs/old/index.yaml +++ b/alpha/action/testdata/index-declcfgs/old/index.yaml @@ -6,14 +6,12 @@ schema: olm.package schema: olm.channel package: bar name: alpha -strategy: - legacy: - entries: - - name: bar.v0.1.0 - - name: bar.v0.2.0 - skipRange: <0.2.0 - skips: - - bar.v0.1.0 +entries: + - name: bar.v0.1.0 + - name: bar.v0.2.0 + skipRange: <0.2.0 + skips: + - bar.v0.1.0 --- image: test.registry/bar-operator/bar-bundle:v0.1.0 name: bar.v0.1.0 @@ -70,16 +68,14 @@ schema: olm.package schema: olm.channel package: baz name: stable -strategy: - legacy: - entries: - - name: baz.v1.0.0 - skipRange: <1.0.0 - - name: baz.v1.0.1 - replaces: baz.v1.0.0 - skipRange: <1.0.0 - skips: - - baz.v1.0.0 +entries: + - name: baz.v1.0.0 + skipRange: <1.0.0 + - name: baz.v1.0.1 + replaces: baz.v1.0.0 + skipRange: <1.0.0 + skips: + - baz.v1.0.0 --- image: test.registry/baz-operator/baz-bundle:v1.0.0 name: baz.v1.0.0 @@ -136,19 +132,17 @@ schema: olm.package schema: olm.channel package: foo name: beta -strategy: - legacy: - entries: - - name: foo.v0.1.0 - skipRange: <0.1.0 - - name: foo.v0.2.0 - replaces: foo.v0.1.0 - skipRange: <0.2.0 - skips: - - foo.v0.1.1 - - foo.v0.1.2 - - name: foo.v0.3.0 - replaces: foo.v0.2.0 +entries: + - name: foo.v0.1.0 + skipRange: <0.1.0 + - name: foo.v0.2.0 + replaces: foo.v0.1.0 + skipRange: <0.2.0 + skips: + - foo.v0.1.1 + - foo.v0.1.2 + - name: foo.v0.3.0 + replaces: foo.v0.2.0 --- image: test.registry/foo-operator/foo-bundle:v0.1.0 name: foo.v0.1.0 diff --git a/alpha/action/testdata/list-index/bar/index.yaml b/alpha/action/testdata/list-index/bar/index.yaml index 95766aae8..37190ffb8 100644 --- a/alpha/action/testdata/list-index/bar/index.yaml +++ b/alpha/action/testdata/list-index/bar/index.yaml @@ -6,30 +6,26 @@ defaultChannel: beta schema: olm.channel package: bar name: beta -strategy: - legacy: - entries: - - name: bar.v0.1.0 - skipRange: <0.1.0 - - name: bar.v0.2.0 - replaces: bar.v0.1.0 - skipRange: <0.2.0 - skips: - - bar.v0.1.1 - - bar.v0.1.2 +entries: + - name: bar.v0.1.0 + skipRange: <0.1.0 + - name: bar.v0.2.0 + replaces: bar.v0.1.0 + skipRange: <0.2.0 + skips: + - bar.v0.1.1 + - bar.v0.1.2 --- schema: olm.channel package: bar name: stable -strategy: - legacy: - entries: - - name: bar.v0.2.0 - replaces: bar.v0.1.0 - skipRange: <0.2.0 - skips: - - bar.v0.1.1 - - bar.v0.1.2 +entries: + - name: bar.v0.2.0 + replaces: bar.v0.1.0 + skipRange: <0.2.0 + skips: + - bar.v0.1.1 + - bar.v0.1.2 --- schema: olm.bundle package: bar diff --git a/alpha/action/testdata/list-index/foo/index.yaml b/alpha/action/testdata/list-index/foo/index.yaml index 6a397cef1..41b7d22df 100644 --- a/alpha/action/testdata/list-index/foo/index.yaml +++ b/alpha/action/testdata/list-index/foo/index.yaml @@ -6,30 +6,26 @@ defaultChannel: beta schema: olm.channel package: foo name: beta -strategy: - legacy: - entries: - - name: foo.v0.1.0 - skipRange: <0.1.0 - - name: foo.v0.2.0 - replaces: foo.v0.1.0 - skipRange: <0.2.0 - skips: - - foo.v0.1.1 - - foo.v0.1.2 +entries: + - name: foo.v0.1.0 + skipRange: <0.1.0 + - name: foo.v0.2.0 + replaces: foo.v0.1.0 + skipRange: <0.2.0 + skips: + - foo.v0.1.1 + - foo.v0.1.2 --- schema: olm.channel package: foo name: stable -strategy: - legacy: - entries: - - name: foo.v0.2.0 - replaces: foo.v0.1.0 - skipRange: <0.2.0 - skips: - - foo.v0.1.1 - - foo.v0.1.2 +entries: + - name: foo.v0.2.0 + replaces: foo.v0.1.0 + skipRange: <0.2.0 + skips: + - foo.v0.1.1 + - foo.v0.1.2 --- schema: olm.bundle package: foo diff --git a/alpha/declcfg/declcfg.go b/alpha/declcfg/declcfg.go index 6ed802661..688d5982a 100644 --- a/alpha/declcfg/declcfg.go +++ b/alpha/declcfg/declcfg.go @@ -33,21 +33,13 @@ type Icon struct { } type Channel struct { - Schema string `json:"schema"` - Name string `json:"name"` - Package string `json:"package"` - Strategy ChannelStrategy `json:"strategy"` + Schema string `json:"schema"` + Name string `json:"name"` + Package string `json:"package"` + Entries []ChannelEntry `json:"entries"` } -type ChannelStrategy struct { - Legacy *LegacyChannelStrategy `json:"legacy,omitempty"` -} - -type LegacyChannelStrategy struct { - Entries []LegacyChannelEntry `json:"entries"` -} - -type LegacyChannelEntry struct { +type ChannelEntry struct { Name string `json:"name"` Replaces string `json:"replaces,omitempty"` Skips []string `json:"skips,omitempty"` diff --git a/alpha/declcfg/declcfg_to_model.go b/alpha/declcfg/declcfg_to_model.go index b02ebfc92..19b0faf38 100644 --- a/alpha/declcfg/declcfg_to_model.go +++ b/alpha/declcfg/declcfg_to_model.go @@ -52,10 +52,7 @@ func ConvertToModel(cfg DeclarativeConfig) (model.Model, error) { } cde := sets.NewString() - if c.Strategy.Legacy == nil { - return nil, fmt.Errorf("package %q, channel %q has no defined strategy", c.Package, c.Name) - } - for _, entry := range c.Strategy.Legacy.Entries { + for _, entry := range c.Entries { if _, ok := mch.Bundles[entry.Name]; ok { return nil, fmt.Errorf("invalid package %q, channel %q: duplicate entry %q", c.Package, c.Name, entry.Name) } diff --git a/alpha/declcfg/declcfg_to_model_test.go b/alpha/declcfg/declcfg_to_model_test.go index 06b2754d0..6cfceedb2 100644 --- a/alpha/declcfg/declcfg_to_model_test.go +++ b/alpha/declcfg/declcfg_to_model_test.go @@ -94,7 +94,7 @@ func TestConvertToModel(t *testing.T) { └── default channel must be set`), cfg: DeclarativeConfig{ Packages: []Package{newTestPackage("foo", "", svgSmallCircle)}, - Channels: []Channel{newTestChannel("foo", "bar", LegacyChannelEntry{Name: testBundleName("foo", "0.1.0")})}, + Channels: []Channel{newTestChannel("foo", "bar", ChannelEntry{Name: testBundleName("foo", "0.1.0")})}, Bundles: []Bundle{newTestBundle("foo", "0.1.0")}, }, }, @@ -135,7 +135,7 @@ func TestConvertToModel(t *testing.T) { assertion: require.NoError, cfg: DeclarativeConfig{ Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, - Channels: []Channel{newTestChannel("foo", "alpha", LegacyChannelEntry{Name: testBundleName("foo", "0.1.0")})}, + Channels: []Channel{newTestChannel("foo", "alpha", ChannelEntry{Name: testBundleName("foo", "0.1.0")})}, Bundles: []Bundle{newTestBundle("foo", "0.1.0", withNoBundleImage())}, }, }, @@ -144,7 +144,7 @@ func TestConvertToModel(t *testing.T) { assertion: hasError(`no olm.bundle blobs found in package "foo" for olm.channel entries [foo.v0.1.0]`), cfg: DeclarativeConfig{ Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, - Channels: []Channel{newTestChannel("foo", "alpha", LegacyChannelEntry{Name: "foo.v0.1.0"})}, + Channels: []Channel{newTestChannel("foo", "alpha", ChannelEntry{Name: "foo.v0.1.0"})}, }, }, { @@ -152,7 +152,7 @@ func TestConvertToModel(t *testing.T) { assertion: hasError(`package "foo", bundle "foo.v0.2.0" not found in any channel entries`), cfg: DeclarativeConfig{ Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, - Channels: []Channel{newTestChannel("foo", "alpha", LegacyChannelEntry{Name: "foo.v0.1.0"})}, + Channels: []Channel{newTestChannel("foo", "alpha", ChannelEntry{Name: "foo.v0.1.0"})}, Bundles: []Bundle{newTestBundle("foo", "0.2.0")}, }, }, @@ -161,7 +161,7 @@ func TestConvertToModel(t *testing.T) { assertion: hasError(`package "foo" contains channel with no name`), cfg: DeclarativeConfig{ Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, - Channels: []Channel{newTestChannel("foo", "", LegacyChannelEntry{Name: "foo.v0.1.0"})}, + Channels: []Channel{newTestChannel("foo", "", ChannelEntry{Name: "foo.v0.1.0"})}, Bundles: []Bundle{newTestBundle("foo", "0.2.0")}, }, }, @@ -170,16 +170,7 @@ func TestConvertToModel(t *testing.T) { assertion: hasError(`unknown package "" for channel "alpha"`), cfg: DeclarativeConfig{ Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, - Channels: []Channel{newTestChannel("", "alpha", LegacyChannelEntry{Name: "foo.v0.1.0"})}, - Bundles: []Bundle{newTestBundle("foo", "0.2.0")}, - }, - }, - { - name: "Error/ChannelMissingStrategy", - assertion: hasError(`package "foo", channel "alpha" has no defined strategy`), - cfg: DeclarativeConfig{ - Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, - Channels: []Channel{{Schema: schemaChannel, Package: "foo", Name: "alpha"}}, + Channels: []Channel{newTestChannel("", "alpha", ChannelEntry{Name: "foo.v0.1.0"})}, Bundles: []Bundle{newTestBundle("foo", "0.2.0")}, }, }, @@ -188,7 +179,7 @@ func TestConvertToModel(t *testing.T) { assertion: hasError(`unknown package "non-existent" for channel "alpha"`), cfg: DeclarativeConfig{ Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, - Channels: []Channel{newTestChannel("non-existent", "alpha", LegacyChannelEntry{Name: "foo.v0.1.0"})}, + Channels: []Channel{newTestChannel("non-existent", "alpha", ChannelEntry{Name: "foo.v0.1.0"})}, Bundles: []Bundle{newTestBundle("foo", "0.1.0")}, }, }, @@ -198,8 +189,8 @@ func TestConvertToModel(t *testing.T) { cfg: DeclarativeConfig{ Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, Channels: []Channel{newTestChannel("foo", "alpha", - LegacyChannelEntry{Name: "foo.v0.1.0"}, - LegacyChannelEntry{Name: "foo.v0.1.0"}, + ChannelEntry{Name: "foo.v0.1.0"}, + ChannelEntry{Name: "foo.v0.1.0"}, )}, Bundles: []Bundle{newTestBundle("foo", "0.1.0")}, }, @@ -209,7 +200,7 @@ func TestConvertToModel(t *testing.T) { assertion: require.NoError, cfg: DeclarativeConfig{ Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)}, - Channels: []Channel{newTestChannel("foo", "alpha", LegacyChannelEntry{Name: "foo.v0.1.0"})}, + Channels: []Channel{newTestChannel("foo", "alpha", ChannelEntry{Name: "foo.v0.1.0"})}, Bundles: []Bundle{newTestBundle("foo", "0.1.0")}, }, }, diff --git a/alpha/declcfg/diff_test.go b/alpha/declcfg/diff_test.go index 581bfcbd8..0f0a25fff 100644 --- a/alpha/declcfg/diff_test.go +++ b/alpha/declcfg/diff_test.go @@ -42,9 +42,9 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, Channels: []Channel{ - {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.1.0"}, - }}}}, + }}, }, Bundles: []Bundle{ { @@ -63,9 +63,9 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, Channels: []Channel{ - {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.1.0"}, - }}}}, + }}, }, Bundles: []Bundle{ { @@ -89,9 +89,9 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, Channels: []Channel{ - {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.1.0"}, - }}}}, + }}, }, Bundles: []Bundle{ { @@ -110,9 +110,9 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, Channels: []Channel{ - {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.1.0"}, - }}}}, + }}, }, Bundles: []Bundle{ { @@ -136,9 +136,9 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, Channels: []Channel{ - {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.1.0"}, - }}}}, + }}, }, Bundles: []Bundle{ { @@ -157,9 +157,9 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, Channels: []Channel{ - {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.1.0"}, - }}}}, + }}, }, Bundles: []Bundle{ { @@ -180,9 +180,9 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, Channels: []Channel{ - {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.1.0"}, - }}}}, + }}, }, Bundles: []Bundle{ { @@ -205,13 +205,13 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, Channels: []Channel{ - {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.1.0"}, - }}}}, - {Schema: schemaChannel, Name: "fast", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + }}, + {Schema: schemaChannel, Name: "fast", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.2.0-alpha.0"}, {Name: "foo.v0.2.0-alpha.1", Replaces: "foo.v0.2.0-alpha.0"}, - }}}}, + }}, }, Bundles: []Bundle{ { @@ -248,17 +248,17 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, Channels: []Channel{ - {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.1.0"}, {Name: "foo.v0.2.0", Skips: []string{"foo.v0.1.0"}}, - }}}}, - {Schema: schemaChannel, Name: "fast", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + }}, + {Schema: schemaChannel, Name: "fast", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.2.0-alpha.0"}, {Name: "foo.v0.2.0-alpha.1", Replaces: "foo.v0.2.0-alpha.0"}, - }}}}, - {Schema: schemaChannel, Name: "clusterwide", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + }}, + {Schema: schemaChannel, Name: "clusterwide", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.1.0-clusterwide"}, - }}}}, + }}, }, Bundles: []Bundle{ { @@ -315,13 +315,13 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, Channels: []Channel{ - {Schema: schemaChannel, Name: "clusterwide", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Schema: schemaChannel, Name: "clusterwide", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.1.0-clusterwide"}, - }}}}, - {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + }}, + {Schema: schemaChannel, Name: "stable", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.1.0"}, {Name: "foo.v0.2.0", Skips: []string{"foo.v0.1.0"}}, - }}}}, + }}, }, Bundles: []Bundle{ { @@ -363,12 +363,12 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, Channels: []Channel{ - {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.1.0"}, - }}}}, - {Schema: schemaChannel, Name: "stable", Package: "etcd", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + }}, + {Schema: schemaChannel, Name: "stable", Package: "etcd", Entries: []ChannelEntry{ {Name: "etcd.v0.9.1"}, - }}}}, + }}, }, Bundles: []Bundle{ { @@ -397,12 +397,12 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, Channels: []Channel{ - {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.1.0"}, - }}}}, - {Schema: schemaChannel, Name: "stable", Package: "etcd", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + }}, + {Schema: schemaChannel, Name: "stable", Package: "etcd", Entries: []ChannelEntry{ {Name: "etcd.v0.9.1"}, - }}}}, + }}, }, Bundles: []Bundle{ { @@ -432,9 +432,9 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, Channels: []Channel{ - {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.1.0"}, - }}}}, + }}, }, Bundles: []Bundle{ { @@ -457,9 +457,9 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, Channels: []Channel{ - {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.1.0"}, - }}}}, + }}, }, Bundles: []Bundle{ { @@ -479,12 +479,12 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, Channels: []Channel{ - {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.1.0"}, - }}}}, - {Schema: schemaChannel, Name: "stable", Package: "etcd", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + }}, + {Schema: schemaChannel, Name: "stable", Package: "etcd", Entries: []ChannelEntry{ {Name: "etcd.v0.9.1"}, - }}}}, + }}, }, Bundles: []Bundle{ { @@ -515,12 +515,12 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, Channels: []Channel{ - {Schema: schemaChannel, Name: "stable", Package: "etcd", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Schema: schemaChannel, Name: "stable", Package: "etcd", Entries: []ChannelEntry{ {Name: "etcd.v0.9.1"}, - }}}}, - {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + }}, + {Schema: schemaChannel, Name: "stable", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.1.0"}, - }}}}, + }}, }, Bundles: []Bundle{ { @@ -552,9 +552,9 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, Channels: []Channel{ - {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.1.0"}, - }}}}, + }}, }, Bundles: []Bundle{ { @@ -574,15 +574,15 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, Channels: []Channel{ - {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.1.0"}, - }}}}, - {Schema: schemaChannel, Name: "clusterwide", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + }}, + {Schema: schemaChannel, Name: "clusterwide", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.1.0-clusterwide"}, - }}}}, - {Schema: schemaChannel, Name: "stable", Package: "etcd", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + }}, + {Schema: schemaChannel, Name: "stable", Package: "etcd", Entries: []ChannelEntry{ {Name: "etcd.v0.9.1"}, - }}}}, + }}, }, Bundles: []Bundle{ { @@ -622,12 +622,12 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, Channels: []Channel{ - {Schema: schemaChannel, Name: "stable", Package: "etcd", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Schema: schemaChannel, Name: "stable", Package: "etcd", Entries: []ChannelEntry{ {Name: "etcd.v0.9.1"}, - }}}}, - {Schema: schemaChannel, Name: "clusterwide", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + }}, + {Schema: schemaChannel, Name: "clusterwide", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.1.0-clusterwide"}, - }}}}, + }}, }, Bundles: []Bundle{ { @@ -660,12 +660,12 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, Channels: []Channel{ - {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.1.0"}, - }}}}, - {Schema: schemaChannel, Name: "stable", Package: "etcd", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + }}, + {Schema: schemaChannel, Name: "stable", Package: "etcd", Entries: []ChannelEntry{ {Name: "etcd.v0.9.1"}, - }}}}, + }}, }, Bundles: []Bundle{ { @@ -695,13 +695,13 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, Channels: []Channel{ - {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.1.0"}, - }}}}, - {Schema: schemaChannel, Name: "stable", Package: "etcd", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + }}, + {Schema: schemaChannel, Name: "stable", Package: "etcd", Entries: []ChannelEntry{ {Name: "etcd.v0.9.1"}, {Name: "etcd.v0.9.2", Replaces: "etcd.v0.9.1"}, - }}}}, + }}, }, Bundles: []Bundle{ { @@ -740,9 +740,9 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "etcd", DefaultChannel: "stable"}, }, Channels: []Channel{ - {Schema: schemaChannel, Name: "stable", Package: "etcd", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Schema: schemaChannel, Name: "stable", Package: "etcd", Entries: []ChannelEntry{ {Name: "etcd.v0.9.2", Replaces: "etcd.v0.9.1"}, - }}}}, + }}, }, Bundles: []Bundle{ { @@ -764,9 +764,9 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, Channels: []Channel{ - {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.1.0"}, - }}}}, + }}, }, Bundles: []Bundle{ { @@ -786,14 +786,14 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, Channels: []Channel{ - {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.1.0"}, {Name: "foo.v0.2.0", Replaces: "foo.v0.1.0"}, - }}}}, - {Schema: schemaChannel, Name: "stable", Package: "etcd", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + }}, + {Schema: schemaChannel, Name: "stable", Package: "etcd", Entries: []ChannelEntry{ {Name: "etcd.v0.9.1"}, {Name: "etcd.v0.9.2", Replaces: "etcd.v0.9.1"}, - }}}}, + }}, }, Bundles: []Bundle{ { @@ -843,14 +843,14 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, Channels: []Channel{ - {Schema: schemaChannel, Name: "stable", Package: "etcd", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Schema: schemaChannel, Name: "stable", Package: "etcd", Entries: []ChannelEntry{ {Name: "etcd.v0.9.1"}, {Name: "etcd.v0.9.2", Replaces: "etcd.v0.9.1"}, - }}}}, - {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + }}, + {Schema: schemaChannel, Name: "stable", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.1.0"}, {Name: "foo.v0.2.0", Replaces: "foo.v0.1.0"}, - }}}}, + }}, }, Bundles: []Bundle{ { @@ -901,9 +901,9 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, Channels: []Channel{ - {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.1.0"}, - }}}}, + }}, }, Bundles: []Bundle{ { @@ -923,12 +923,12 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, Channels: []Channel{ - {Schema: schemaChannel, Name: "stable", Package: "etcd", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Schema: schemaChannel, Name: "stable", Package: "etcd", Entries: []ChannelEntry{ {Name: "etcd.v0.9.1"}, - }}}}, - {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + }}, + {Schema: schemaChannel, Name: "stable", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.1.0"}, - }}}}, + }}, }, Bundles: []Bundle{ { @@ -960,12 +960,12 @@ func TestDiffLatest(t *testing.T) { {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, Channels: []Channel{ - {Schema: schemaChannel, Name: "stable", Package: "etcd", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Schema: schemaChannel, Name: "stable", Package: "etcd", Entries: []ChannelEntry{ {Name: "etcd.v0.9.1"}, - }}}}, - {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + }}, + {Schema: schemaChannel, Name: "stable", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.1.0"}, - }}}}, + }}, }, Bundles: []Bundle{ { @@ -1037,9 +1037,9 @@ func TestDiffHeadsOnly(t *testing.T) { {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, Channels: []Channel{ - {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.1.0"}, - }}}}, + }}, }, Bundles: []Bundle{ { @@ -1059,9 +1059,9 @@ func TestDiffHeadsOnly(t *testing.T) { {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, Channels: []Channel{ - {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Schema: schemaChannel, Name: "stable", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.1.0"}, - }}}}, + }}, }, Bundles: []Bundle{ { @@ -1084,22 +1084,22 @@ func TestDiffHeadsOnly(t *testing.T) { {Schema: schemaPackage, Name: "etcd", DefaultChannel: "stable"}, }, Channels: []Channel{ - {Schema: schemaChannel, Name: "stable", Package: "etcd", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Schema: schemaChannel, Name: "stable", Package: "etcd", Entries: []ChannelEntry{ {Name: "etcd.v0.9.0"}, {Name: "etcd.v0.9.1", Replaces: "etcd.v0.9.0"}, - }}}}, - {Schema: schemaChannel, Name: "clusterwide", Package: "etcd", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + }}, + {Schema: schemaChannel, Name: "clusterwide", Package: "etcd", Entries: []ChannelEntry{ {Name: "etcd.v0.9.1-clusterwide"}, - }}}}, - {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + }}, + {Schema: schemaChannel, Name: "stable", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.1.0"}, {Name: "foo.v0.2.0", Replaces: "foo.v0.1.0"}, - }}}}, - {Schema: schemaChannel, Name: "alpha", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + }}, + {Schema: schemaChannel, Name: "alpha", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.2.0-alpha.0"}, {Name: "foo.v0.2.0-alpha.1", Replaces: "foo.v0.2.0-alpha.0"}, {Name: "foo.v0.2.0", Replaces: "foo.v0.2.0-alpha.1"}, - }}}}, + }}, }, Bundles: []Bundle{ { @@ -1174,18 +1174,18 @@ func TestDiffHeadsOnly(t *testing.T) { {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, Channels: []Channel{ - {Schema: schemaChannel, Name: "clusterwide", Package: "etcd", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Schema: schemaChannel, Name: "clusterwide", Package: "etcd", Entries: []ChannelEntry{ {Name: "etcd.v0.9.1-clusterwide"}, - }}}}, - {Schema: schemaChannel, Name: "stable", Package: "etcd", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + }}, + {Schema: schemaChannel, Name: "stable", Package: "etcd", Entries: []ChannelEntry{ {Name: "etcd.v0.9.1", Replaces: "etcd.v0.9.0"}, - }}}}, - {Schema: schemaChannel, Name: "alpha", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + }}, + {Schema: schemaChannel, Name: "alpha", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.2.0", Replaces: "foo.v0.2.0-alpha.1"}, - }}}}, - {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + }}, + {Schema: schemaChannel, Name: "stable", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.2.0", Replaces: "foo.v0.1.0"}, - }}}}, + }}, }, Bundles: []Bundle{ { @@ -1228,13 +1228,13 @@ func TestDiffHeadsOnly(t *testing.T) { {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, Channels: []Channel{ - {Schema: schemaChannel, Name: "stable", Package: "etcd", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Schema: schemaChannel, Name: "stable", Package: "etcd", Entries: []ChannelEntry{ {Name: "etcd.v0.9.1"}, {Name: "etcd.v0.9.2", Replaces: "etcd.v0.9.1"}, - }}}}, - {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + }}, + {Schema: schemaChannel, Name: "stable", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.1.0"}, - }}}}, + }}, }, Bundles: []Bundle{ { @@ -1278,12 +1278,12 @@ func TestDiffHeadsOnly(t *testing.T) { {Schema: schemaPackage, Name: "foo", DefaultChannel: "stable"}, }, Channels: []Channel{ - {Schema: schemaChannel, Name: "stable", Package: "etcd", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + {Schema: schemaChannel, Name: "stable", Package: "etcd", Entries: []ChannelEntry{ {Name: "etcd.v0.9.2", Replaces: "etcd.v0.9.1"}, - }}}}, - {Schema: schemaChannel, Name: "stable", Package: "foo", Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: []LegacyChannelEntry{ + }}, + {Schema: schemaChannel, Name: "stable", Package: "foo", Entries: []ChannelEntry{ {Name: "foo.v0.1.0"}, - }}}}, + }}, }, Bundles: []Bundle{ { diff --git a/alpha/declcfg/helpers_test.go b/alpha/declcfg/helpers_test.go index f92504154..86111c770 100644 --- a/alpha/declcfg/helpers_test.go +++ b/alpha/declcfg/helpers_test.go @@ -46,33 +46,33 @@ func buildValidDeclarativeConfig(includeUnrecognized bool) DeclarativeConfig { }, Channels: []Channel{ newTestChannel("anakin", "dark", - LegacyChannelEntry{ + ChannelEntry{ Name: testBundleName("anakin", "0.0.1"), }, - LegacyChannelEntry{ + ChannelEntry{ Name: testBundleName("anakin", "0.1.0"), Replaces: testBundleName("anakin", "0.0.1"), }, - LegacyChannelEntry{ + ChannelEntry{ Name: testBundleName("anakin", "0.1.1"), Replaces: testBundleName("anakin", "0.0.1"), Skips: []string{testBundleName("anakin", "0.1.0")}, }, ), newTestChannel("anakin", "light", - LegacyChannelEntry{ + ChannelEntry{ Name: testBundleName("anakin", "0.0.1"), }, - LegacyChannelEntry{ + ChannelEntry{ Name: testBundleName("anakin", "0.1.0"), Replaces: testBundleName("anakin", "0.0.1"), }, ), newTestChannel("boba-fett", "mando", - LegacyChannelEntry{ + ChannelEntry{ Name: testBundleName("boba-fett", "1.0.0"), }, - LegacyChannelEntry{ + ChannelEntry{ Name: testBundleName("boba-fett", "2.0.0"), Replaces: testBundleName("boba-fett", "1.0.0"), }, @@ -159,12 +159,12 @@ func newTestPackage(packageName, defaultChannel, svgData string) Package { return p } -func newTestChannel(packageName, channelName string, entries ...LegacyChannelEntry) Channel { +func newTestChannel(packageName, channelName string, entries ...ChannelEntry) Channel { return Channel{ - Schema: schemaChannel, - Name: channelName, - Package: packageName, - Strategy: ChannelStrategy{Legacy: &LegacyChannelStrategy{Entries: entries}}, + Schema: schemaChannel, + Name: channelName, + Package: packageName, + Entries: entries, } } diff --git a/alpha/declcfg/model_to_declcfg.go b/alpha/declcfg/model_to_declcfg.go index d7c306a46..fc7424004 100644 --- a/alpha/declcfg/model_to_declcfg.go +++ b/alpha/declcfg/model_to_declcfg.go @@ -63,16 +63,12 @@ func traverseModelChannels(mpkg model.Package) ([]Channel, []Bundle) { Schema: schemaChannel, Name: ch.Name, Package: ch.Package.Name, - Strategy: ChannelStrategy{ - Legacy: &LegacyChannelStrategy{ - Entries: []LegacyChannelEntry{}, - }, - }, + Entries: []ChannelEntry{}, } for _, chb := range ch.Bundles { // populate channel entry - c.Strategy.Legacy.Entries = append(c.Strategy.Legacy.Entries, LegacyChannelEntry{ + c.Entries = append(c.Entries, ChannelEntry{ Name: chb.Name, Replaces: chb.Replaces, Skips: chb.Skips, @@ -97,8 +93,8 @@ func traverseModelChannels(mpkg model.Package) ([]Channel, []Bundle) { } // sort channel entries by name - sort.Slice(c.Strategy.Legacy.Entries, func(i, j int) bool { - return c.Strategy.Legacy.Entries[i].Name < c.Strategy.Legacy.Entries[j].Name + sort.Slice(c.Entries, func(i, j int) bool { + return c.Entries[i].Name < c.Entries[j].Name }) channels = append(channels, c) } diff --git a/alpha/declcfg/write_test.go b/alpha/declcfg/write_test.go index 522861323..d8c909d8f 100644 --- a/alpha/declcfg/write_test.go +++ b/alpha/declcfg/write_test.go @@ -32,44 +32,36 @@ func TestWriteJSON(t *testing.T) { "schema": "olm.channel", "name": "dark", "package": "anakin", - "strategy": { - "legacy": { - "entries": [ - { - "name": "anakin.v0.0.1" - }, - { - "name": "anakin.v0.1.0", - "replaces": "anakin.v0.0.1" - }, - { - "name": "anakin.v0.1.1", - "replaces": "anakin.v0.0.1", - "skips": [ - "anakin.v0.1.0" - ] - } + "entries": [ + { + "name": "anakin.v0.0.1" + }, + { + "name": "anakin.v0.1.0", + "replaces": "anakin.v0.0.1" + }, + { + "name": "anakin.v0.1.1", + "replaces": "anakin.v0.0.1", + "skips": [ + "anakin.v0.1.0" ] } - } + ] } { "schema": "olm.channel", "name": "light", "package": "anakin", - "strategy": { - "legacy": { - "entries": [ - { - "name": "anakin.v0.0.1" - }, - { - "name": "anakin.v0.1.0", - "replaces": "anakin.v0.0.1" - } - ] + "entries": [ + { + "name": "anakin.v0.0.1" + }, + { + "name": "anakin.v0.1.0", + "replaces": "anakin.v0.0.1" } - } + ] } { "schema": "olm.bundle", @@ -189,19 +181,15 @@ func TestWriteJSON(t *testing.T) { "schema": "olm.channel", "name": "mando", "package": "boba-fett", - "strategy": { - "legacy": { - "entries": [ - { - "name": "boba-fett.v1.0.0" - }, - { - "name": "boba-fett.v2.0.0", - "replaces": "boba-fett.v1.0.0" - } - ] + "entries": [ + { + "name": "boba-fett.v1.0.0" + }, + { + "name": "boba-fett.v2.0.0", + "replaces": "boba-fett.v1.0.0" } - } + ] } { "schema": "olm.bundle", @@ -312,29 +300,25 @@ icon: name: anakin schema: olm.package --- +entries: +- name: anakin.v0.0.1 +- name: anakin.v0.1.0 + replaces: anakin.v0.0.1 +- name: anakin.v0.1.1 + replaces: anakin.v0.0.1 + skips: + - anakin.v0.1.0 name: dark package: anakin schema: olm.channel -strategy: - legacy: - entries: - - name: anakin.v0.0.1 - - name: anakin.v0.1.0 - replaces: anakin.v0.0.1 - - name: anakin.v0.1.1 - replaces: anakin.v0.0.1 - skips: - - anakin.v0.1.0 --- +entries: +- name: anakin.v0.0.1 +- name: anakin.v0.1.0 + replaces: anakin.v0.0.1 name: light package: anakin schema: olm.channel -strategy: - legacy: - entries: - - name: anakin.v0.0.1 - - name: anakin.v0.1.0 - replaces: anakin.v0.0.1 --- image: anakin-bundle:v0.0.1 name: anakin.v0.0.1 @@ -405,15 +389,13 @@ icon: name: boba-fett schema: olm.package --- +entries: +- name: boba-fett.v1.0.0 +- name: boba-fett.v2.0.0 + replaces: boba-fett.v1.0.0 name: mando package: boba-fett schema: olm.channel -strategy: - legacy: - entries: - - name: boba-fett.v1.0.0 - - name: boba-fett.v2.0.0 - replaces: boba-fett.v1.0.0 --- image: boba-fett-bundle:v1.0.0 name: boba-fett.v1.0.0 diff --git a/pkg/registry/query_test.go b/pkg/registry/query_test.go index be153aa21..4a3988b98 100644 --- a/pkg/registry/query_test.go +++ b/pkg/registry/query_test.go @@ -205,39 +205,27 @@ var validFS = fstest.MapFS{ "schema": "olm.channel", "package": "cockroachdb", "name": "stable", - "strategy": { - "legacy": { - "entries": [ - {"name": "cockroachdb.v2.0.9"}, - {"name": "cockroachdb.v2.1.1", "replaces": "cockroachdb.v2.0.9"}, - {"name": "cockroachdb.v2.1.11", "replaces": "cockroachdb.v2.1.1"} - ] - } - } + "entries": [ + {"name": "cockroachdb.v2.0.9"}, + {"name": "cockroachdb.v2.1.1", "replaces": "cockroachdb.v2.0.9"}, + {"name": "cockroachdb.v2.1.11", "replaces": "cockroachdb.v2.1.1"} + ] } { "schema": "olm.channel", "package": "cockroachdb", "name": "stable-3.x", - "strategy": { - "legacy": { - "entries": [ - {"name": "cockroachdb.v3.0.7"} - ] - } - } + "entries": [ + {"name": "cockroachdb.v3.0.7"} + ] } { "schema": "olm.channel", "package": "cockroachdb", "name": "stable-5.x", - "strategy": { - "legacy": { - "entries": [ - {"name": "cockroachdb.v5.0.3"} - ] - } - } + "entries": [ + {"name": "cockroachdb.v5.0.3"} + ] } { "schema": "olm.bundle", @@ -342,41 +330,29 @@ var validFS = fstest.MapFS{ "schema": "olm.channel", "package": "etcd", "name": "alpha", - "strategy": { - "legacy": { - "entries": [ - {"name": "etcdoperator-community.v0.6.1"} - ] - } - } + "entries": [ + {"name": "etcdoperator-community.v0.6.1"} + ] } { "schema": "olm.channel", "package": "etcd", "name": "singlenamespace-alpha", - "strategy": { - "legacy": { - "entries": [ - {"name": "etcdoperator.v0.9.0"}, - {"name": "etcdoperator.v0.9.2", "replaces": "etcdoperator.v0.9.0"}, - {"name": "etcdoperator.v0.9.4", "replaces": "etcdoperator.v0.9.2"} - ] - } - } + "entries": [ + {"name": "etcdoperator.v0.9.0"}, + {"name": "etcdoperator.v0.9.2", "replaces": "etcdoperator.v0.9.0"}, + {"name": "etcdoperator.v0.9.4", "replaces": "etcdoperator.v0.9.2"} + ] } { "schema": "olm.channel", "package": "etcd", "name": "clusterwide-alpha", - "strategy": { - "legacy": { - "entries": [ - {"name": "etcdoperator.v0.9.0"}, - {"name": "etcdoperator.v0.9.2-clusterwide", "replaces": "etcdoperator.v0.9.0", "skips": ["etcdoperator.v0.6.1","etcdoperator.v0.9.0"], "skipRange": ">=0.9.0 <=0.9.1"}, - {"name": "etcdoperator.v0.9.4-clusterwide", "replaces": "etcdoperator.v0.9.2-clusterwide"} - ] - } - } + "entries": [ + {"name": "etcdoperator.v0.9.0"}, + {"name": "etcdoperator.v0.9.2-clusterwide", "replaces": "etcdoperator.v0.9.0", "skips": ["etcdoperator.v0.6.1","etcdoperator.v0.9.0"], "skipRange": ">=0.9.0 <=0.9.1"}, + {"name": "etcdoperator.v0.9.4-clusterwide", "replaces": "etcdoperator.v0.9.2-clusterwide"} + ] } { "schema": "olm.bundle", From f4868c3f66d9b6d174ab4d41926600864c968cd6 Mon Sep 17 00:00:00 2001 From: Joe Lanford Date: Wed, 1 Sep 2021 15:49:52 -0400 Subject: [PATCH 5/5] minor cleanups Signed-off-by: Joe Lanford --- alpha/declcfg/declcfg_to_model.go | 2 -- alpha/declcfg/model_to_declcfg.go | 2 +- pkg/lib/indexer/index.Dockerfile047416381 | 0 pkg/lib/indexer/index.Dockerfile062873339 | 0 pkg/lib/indexer/index.Dockerfile622193597 | 0 5 files changed, 1 insertion(+), 3 deletions(-) delete mode 100644 pkg/lib/indexer/index.Dockerfile047416381 delete mode 100644 pkg/lib/indexer/index.Dockerfile062873339 delete mode 100644 pkg/lib/indexer/index.Dockerfile622193597 diff --git a/alpha/declcfg/declcfg_to_model.go b/alpha/declcfg/declcfg_to_model.go index 19b0faf38..d539c165f 100644 --- a/alpha/declcfg/declcfg_to_model.go +++ b/alpha/declcfg/declcfg_to_model.go @@ -33,7 +33,6 @@ func ConvertToModel(cfg DeclarativeConfig) (model.Model, error) { mpkgs[p.Name] = mpkg } - channelDefinedEdges := sets.NewString() channelDefinedEntries := map[string]sets.String{} for _, c := range cfg.Channels { mpkg, ok := mpkgs[c.Package] @@ -67,7 +66,6 @@ func ConvertToModel(cfg DeclarativeConfig) (model.Model, error) { } } channelDefinedEntries[c.Package] = cde - channelDefinedEdges = channelDefinedEdges.Insert(c.Package) mpkg.Channels[c.Name] = mch diff --git a/alpha/declcfg/model_to_declcfg.go b/alpha/declcfg/model_to_declcfg.go index fc7424004..9d6651e8b 100644 --- a/alpha/declcfg/model_to_declcfg.go +++ b/alpha/declcfg/model_to_declcfg.go @@ -86,10 +86,10 @@ func traverseModelChannels(mpkg model.Package) ([]Channel, []Bundle) { RelatedImages: modelRelatedImagesToRelatedImages(chb.RelatedImages), CsvJSON: chb.CsvJSON, Objects: chb.Objects, - Properties: chb.Properties, } bundleMap[b.Name] = b } + b.Properties = append(b.Properties, chb.Properties...) } // sort channel entries by name diff --git a/pkg/lib/indexer/index.Dockerfile047416381 b/pkg/lib/indexer/index.Dockerfile047416381 deleted file mode 100644 index e69de29bb..000000000 diff --git a/pkg/lib/indexer/index.Dockerfile062873339 b/pkg/lib/indexer/index.Dockerfile062873339 deleted file mode 100644 index e69de29bb..000000000 diff --git a/pkg/lib/indexer/index.Dockerfile622193597 b/pkg/lib/indexer/index.Dockerfile622193597 deleted file mode 100644 index e69de29bb..000000000