Skip to content

Commit 247887f

Browse files
Merge pull request #181 from joelanford/bz-2000146
Bug 2000146: Introduce olm.channel schema, remove channel metadata-related bundle properties
2 parents 01e1cf8 + bbd687b commit 247887f

File tree

55 files changed

+1407
-1501
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1407
-1501
lines changed

staging/operator-registry/internal/action/list.go

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414

1515
"github.com/operator-framework/operator-registry/internal/declcfg"
1616
"github.com/operator-framework/operator-registry/internal/model"
17-
"github.com/operator-framework/operator-registry/internal/property"
1817
)
1918

2019
type ListPackages struct {
@@ -173,32 +172,13 @@ func (r *ListBundlesResult) WriteColumns(w io.Writer) error {
173172
return err
174173
}
175174
for _, b := range r.Bundles {
176-
skipRange, err := getSkipRange(b)
177-
if err != nil {
178-
return fmt.Errorf("get skipRange for bundle %q: %v", b.Name, err)
179-
}
180-
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 {
175+
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 {
181176
return err
182177
}
183-
184178
}
185179
return tw.Flush()
186180
}
187181

188-
func getSkipRange(b model.Bundle) (string, error) {
189-
props, err := property.Parse(b.Properties)
190-
if err != nil {
191-
return "", err
192-
}
193-
if len(props.SkipRanges) > 1 {
194-
return "", fmt.Errorf("multiple skip ranges not supported")
195-
}
196-
if len(props.SkipRanges) == 0 {
197-
return "", nil
198-
}
199-
return string(props.SkipRanges[0]), nil
200-
}
201-
202182
func indexRefToModel(ctx context.Context, ref string) (model.Model, error) {
203183
render := Render{
204184
Refs: []string{ref},

staging/operator-registry/internal/action/render.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ func combineConfigs(cfgs []declcfg.DeclarativeConfig) *declcfg.DeclarativeConfig
345345
out := &declcfg.DeclarativeConfig{}
346346
for _, in := range cfgs {
347347
out.Packages = append(out.Packages, in.Packages...)
348+
out.Channels = append(out.Channels, in.Channels...)
348349
out.Bundles = append(out.Bundles, in.Bundles...)
349350
out.Others = append(out.Others, in.Others...)
350351
}

staging/operator-registry/internal/action/render_test.go

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,27 @@ func TestRender(t *testing.T) {
7575
DefaultChannel: "beta",
7676
},
7777
},
78+
Channels: []declcfg.Channel{
79+
{Schema: "olm.channel", Package: "foo", Name: "beta", Entries: []declcfg.ChannelEntry{
80+
{Name: "foo.v0.1.0", SkipRange: "<0.1.0"},
81+
{Name: "foo.v0.2.0", Replaces: "foo.v0.1.0", SkipRange: "<0.2.0", Skips: []string{"foo.v0.1.1", "foo.v0.1.2"}},
82+
}},
83+
{Schema: "olm.channel", Package: "foo", Name: "stable", Entries: []declcfg.ChannelEntry{
84+
{Name: "foo.v0.1.0", SkipRange: "<0.1.0"},
85+
{Name: "foo.v0.2.0", Replaces: "foo.v0.1.0", SkipRange: "<0.2.0", Skips: []string{"foo.v0.1.1", "foo.v0.1.2"}},
86+
}},
87+
},
7888
Bundles: []declcfg.Bundle{
7989
{
8090
Schema: "olm.bundle",
8191
Name: "foo.v0.1.0",
8292
Package: "foo",
8393
Image: "test.registry/foo-operator/foo-bundle:v0.1.0",
8494
Properties: []property.Property{
85-
property.MustBuildChannel("beta", ""),
86-
property.MustBuildChannel("stable", ""),
8795
property.MustBuildGVK("test.foo", "v1", "Foo"),
8896
property.MustBuildGVKRequired("test.bar", "v1alpha1", "Bar"),
8997
property.MustBuildPackage("foo", "0.1.0"),
9098
property.MustBuildPackageRequired("bar", "<0.1.0"),
91-
property.MustBuildSkipRange("<0.1.0"),
9299
property.MustBuildBundleObjectData(foov1csv),
93100
property.MustBuildBundleObjectData(foov1crd),
94101
},
@@ -110,15 +117,10 @@ func TestRender(t *testing.T) {
110117
Package: "foo",
111118
Image: "test.registry/foo-operator/foo-bundle:v0.2.0",
112119
Properties: []property.Property{
113-
property.MustBuildChannel("beta", "foo.v0.1.0"),
114-
property.MustBuildChannel("stable", "foo.v0.1.0"),
115120
property.MustBuildGVK("test.foo", "v1", "Foo"),
116121
property.MustBuildGVKRequired("test.bar", "v1alpha1", "Bar"),
117122
property.MustBuildPackage("foo", "0.2.0"),
118123
property.MustBuildPackageRequired("bar", "<0.1.0"),
119-
property.MustBuildSkipRange("<0.2.0"),
120-
property.MustBuildSkips("foo.v0.1.1"),
121-
property.MustBuildSkips("foo.v0.1.2"),
122124
property.MustBuildBundleObjectData(foov2csv),
123125
property.MustBuildBundleObjectData(foov2crd),
124126
},
@@ -152,20 +154,27 @@ func TestRender(t *testing.T) {
152154
DefaultChannel: "beta",
153155
},
154156
},
157+
Channels: []declcfg.Channel{
158+
{Schema: "olm.channel", Package: "foo", Name: "beta", Entries: []declcfg.ChannelEntry{
159+
{Name: "foo.v0.1.0", SkipRange: "<0.1.0"},
160+
{Name: "foo.v0.2.0", Replaces: "foo.v0.1.0", SkipRange: "<0.2.0", Skips: []string{"foo.v0.1.1", "foo.v0.1.2"}},
161+
}},
162+
{Schema: "olm.channel", Package: "foo", Name: "stable", Entries: []declcfg.ChannelEntry{
163+
{Name: "foo.v0.1.0", SkipRange: "<0.1.0"},
164+
{Name: "foo.v0.2.0", Replaces: "foo.v0.1.0", SkipRange: "<0.2.0", Skips: []string{"foo.v0.1.1", "foo.v0.1.2"}},
165+
}},
166+
},
155167
Bundles: []declcfg.Bundle{
156168
{
157169
Schema: "olm.bundle",
158170
Name: "foo.v0.1.0",
159171
Package: "foo",
160172
Image: "test.registry/foo-operator/foo-bundle:v0.1.0",
161173
Properties: []property.Property{
162-
property.MustBuildChannel("beta", ""),
163-
property.MustBuildChannel("stable", ""),
164174
property.MustBuildGVK("test.foo", "v1", "Foo"),
165175
property.MustBuildGVKRequired("test.bar", "v1alpha1", "Bar"),
166176
property.MustBuildPackage("foo", "0.1.0"),
167177
property.MustBuildPackageRequired("bar", "<0.1.0"),
168-
property.MustBuildSkipRange("<0.1.0"),
169178
property.MustBuildBundleObjectData(foov1csv),
170179
property.MustBuildBundleObjectData(foov1crd),
171180
},
@@ -187,15 +196,10 @@ func TestRender(t *testing.T) {
187196
Package: "foo",
188197
Image: "test.registry/foo-operator/foo-bundle:v0.2.0",
189198
Properties: []property.Property{
190-
property.MustBuildChannel("beta", "foo.v0.1.0"),
191-
property.MustBuildChannel("stable", "foo.v0.1.0"),
192199
property.MustBuildGVK("test.foo", "v1", "Foo"),
193200
property.MustBuildGVKRequired("test.bar", "v1alpha1", "Bar"),
194201
property.MustBuildPackage("foo", "0.2.0"),
195202
property.MustBuildPackageRequired("bar", "<0.1.0"),
196-
property.MustBuildSkipRange("<0.2.0"),
197-
property.MustBuildSkips("foo.v0.1.1"),
198-
property.MustBuildSkips("foo.v0.1.2"),
199203
property.MustBuildBundleObjectData(foov2csv),
200204
property.MustBuildBundleObjectData(foov2crd),
201205
},
@@ -229,19 +233,26 @@ func TestRender(t *testing.T) {
229233
DefaultChannel: "beta",
230234
},
231235
},
236+
Channels: []declcfg.Channel{
237+
{Schema: "olm.channel", Package: "foo", Name: "beta", Entries: []declcfg.ChannelEntry{
238+
{Name: "foo.v0.1.0", SkipRange: "<0.1.0"},
239+
{Name: "foo.v0.2.0", Replaces: "foo.v0.1.0", SkipRange: "<0.2.0", Skips: []string{"foo.v0.1.1", "foo.v0.1.2"}},
240+
}},
241+
{Schema: "olm.channel", Package: "foo", Name: "stable", Entries: []declcfg.ChannelEntry{
242+
{Name: "foo.v0.2.0", Replaces: "foo.v0.1.0", SkipRange: "<0.2.0", Skips: []string{"foo.v0.1.1", "foo.v0.1.2"}},
243+
}},
244+
},
232245
Bundles: []declcfg.Bundle{
233246
{
234247
Schema: "olm.bundle",
235248
Name: "foo.v0.1.0",
236249
Package: "foo",
237250
Image: "test.registry/foo-operator/foo-bundle:v0.1.0",
238251
Properties: []property.Property{
239-
property.MustBuildChannel("beta", ""),
240252
property.MustBuildGVK("test.foo", "v1", "Foo"),
241253
property.MustBuildGVKRequired("test.bar", "v1alpha1", "Bar"),
242254
property.MustBuildPackage("foo", "0.1.0"),
243255
property.MustBuildPackageRequired("bar", "<0.1.0"),
244-
property.MustBuildSkipRange("<0.1.0"),
245256
property.MustBuildBundleObjectData(foov1csv),
246257
property.MustBuildBundleObjectData(foov1crd),
247258
},
@@ -263,15 +274,10 @@ func TestRender(t *testing.T) {
263274
Package: "foo",
264275
Image: "test.registry/foo-operator/foo-bundle:v0.2.0",
265276
Properties: []property.Property{
266-
property.MustBuildChannel("beta", "foo.v0.1.0"),
267-
property.MustBuildChannel("stable", "foo.v0.1.0"),
268277
property.MustBuildGVK("test.foo", "v1", "Foo"),
269278
property.MustBuildGVKRequired("test.bar", "v1alpha1", "Bar"),
270279
property.MustBuildPackage("foo", "0.2.0"),
271280
property.MustBuildPackageRequired("bar", "<0.1.0"),
272-
property.MustBuildSkipRange("<0.2.0"),
273-
property.MustBuildSkips("foo.v0.1.1"),
274-
property.MustBuildSkips("foo.v0.1.2"),
275281
property.MustBuildBundleObjectData(foov2csv),
276282
property.MustBuildBundleObjectData(foov2crd),
277283
},
@@ -305,19 +311,26 @@ func TestRender(t *testing.T) {
305311
DefaultChannel: "beta",
306312
},
307313
},
314+
Channels: []declcfg.Channel{
315+
{Schema: "olm.channel", Package: "foo", Name: "beta", Entries: []declcfg.ChannelEntry{
316+
{Name: "foo.v0.1.0", SkipRange: "<0.1.0"},
317+
{Name: "foo.v0.2.0", Replaces: "foo.v0.1.0", SkipRange: "<0.2.0", Skips: []string{"foo.v0.1.1", "foo.v0.1.2"}},
318+
}},
319+
{Schema: "olm.channel", Package: "foo", Name: "stable", Entries: []declcfg.ChannelEntry{
320+
{Name: "foo.v0.2.0", Replaces: "foo.v0.1.0", SkipRange: "<0.2.0", Skips: []string{"foo.v0.1.1", "foo.v0.1.2"}},
321+
}},
322+
},
308323
Bundles: []declcfg.Bundle{
309324
{
310325
Schema: "olm.bundle",
311326
Name: "foo.v0.1.0",
312327
Package: "foo",
313328
Image: "test.registry/foo-operator/foo-bundle:v0.1.0",
314329
Properties: []property.Property{
315-
property.MustBuildChannel("beta", ""),
316330
property.MustBuildGVK("test.foo", "v1", "Foo"),
317331
property.MustBuildGVKRequired("test.bar", "v1alpha1", "Bar"),
318332
property.MustBuildPackage("foo", "0.1.0"),
319333
property.MustBuildPackageRequired("bar", "<0.1.0"),
320-
property.MustBuildSkipRange("<0.1.0"),
321334
property.MustBuildBundleObjectData(foov1csv),
322335
property.MustBuildBundleObjectData(foov1crd),
323336
},
@@ -339,15 +352,10 @@ func TestRender(t *testing.T) {
339352
Package: "foo",
340353
Image: "test.registry/foo-operator/foo-bundle:v0.2.0",
341354
Properties: []property.Property{
342-
property.MustBuildChannel("beta", "foo.v0.1.0"),
343-
property.MustBuildChannel("stable", "foo.v0.1.0"),
344355
property.MustBuildGVK("test.foo", "v1", "Foo"),
345356
property.MustBuildGVKRequired("test.bar", "v1alpha1", "Bar"),
346357
property.MustBuildPackage("foo", "0.2.0"),
347358
property.MustBuildPackageRequired("bar", "<0.1.0"),
348-
property.MustBuildSkipRange("<0.2.0"),
349-
property.MustBuildSkips("foo.v0.1.1"),
350-
property.MustBuildSkips("foo.v0.1.2"),
351359
property.MustBuildBundleObjectData(foov2csv),
352360
property.MustBuildBundleObjectData(foov2crd),
353361
},
@@ -381,15 +389,10 @@ func TestRender(t *testing.T) {
381389
Package: "foo",
382390
Image: "test.registry/foo-operator/foo-bundle:v0.2.0",
383391
Properties: []property.Property{
384-
property.MustBuildChannel("beta", "foo.v0.1.0"),
385-
property.MustBuildChannel("stable", "foo.v0.1.0"),
386392
property.MustBuildGVK("test.foo", "v1", "Foo"),
387393
property.MustBuildGVKRequired("test.bar", "v1alpha1", "Bar"),
388394
property.MustBuildPackage("foo", "0.2.0"),
389395
property.MustBuildPackageRequired("bar", "<0.1.0"),
390-
property.MustBuildSkipRange("<0.2.0"),
391-
property.MustBuildSkips("foo.v0.1.1"),
392-
property.MustBuildSkips("foo.v0.1.2"),
393396
},
394397
RelatedImages: []declcfg.RelatedImage{
395398
{

staging/operator-registry/internal/action/testdata/foo-index-v0.2.0-declcfg/foo/index.yaml

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,35 @@ schema: olm.package
33
name: foo
44
defaultChannel: beta
55
---
6+
schema: olm.channel
7+
package: foo
8+
name: beta
9+
entries:
10+
- name: foo.v0.1.0
11+
skipRange: <0.1.0
12+
- name: foo.v0.2.0
13+
replaces: foo.v0.1.0
14+
skipRange: <0.2.0
15+
skips:
16+
- foo.v0.1.1
17+
- foo.v0.1.2
18+
---
19+
schema: olm.channel
20+
package: foo
21+
name: stable
22+
entries:
23+
- name: foo.v0.2.0
24+
replaces: foo.v0.1.0
25+
skipRange: <0.2.0
26+
skips:
27+
- foo.v0.1.1
28+
- foo.v0.1.2
29+
---
630
schema: olm.bundle
731
package: foo
832
name: foo.v0.1.0
933
image: test.registry/foo-operator/foo-bundle:v0.1.0
1034
properties:
11-
- type: olm.channel
12-
value:
13-
name: beta
1435
- type: olm.gvk
1536
value:
1637
group: test.foo
@@ -29,8 +50,6 @@ properties:
2950
value:
3051
packageName: bar
3152
versionRange: <0.1.0
32-
- type: olm.skipRange
33-
value: <0.1.0
3453
- type: olm.bundle.object
3554
value:
3655
data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsiYW5ub3RhdGlvbnMiOnsib2xtLnNraXBSYW5nZSI6Ilx1MDAzYzAuMS4wIn0sIm5hbWUiOiJmb28udjAuMS4wIn0sInNwZWMiOnsiY3VzdG9tcmVzb3VyY2VkZWZpbml0aW9ucyI6eyJvd25lZCI6W3siZ3JvdXAiOiJ0ZXN0LmZvbyIsImtpbmQiOiJGb28iLCJuYW1lIjoiZm9vcy50ZXN0LmZvbyIsInZlcnNpb24iOiJ2MSJ9XX0sImRpc3BsYXlOYW1lIjoiRm9vIE9wZXJhdG9yIiwicmVsYXRlZEltYWdlcyI6W3siaW1hZ2UiOiJ0ZXN0LnJlZ2lzdHJ5L2Zvby1vcGVyYXRvci9mb286djAuMS4wIiwibmFtZSI6Im9wZXJhdG9yIn1dLCJ2ZXJzaW9uIjoiMC4xLjAifX0=
@@ -47,14 +66,6 @@ package: foo
4766
name: foo.v0.2.0
4867
image: test.registry/foo-operator/foo-bundle:v0.2.0
4968
properties:
50-
- type: olm.channel
51-
value:
52-
name: beta
53-
replaces: foo.v0.1.0
54-
- type: olm.channel
55-
value:
56-
name: stable
57-
replaces: foo.v0.1.0
5869
- type: olm.gvk
5970
value:
6071
group: test.foo
@@ -73,12 +84,6 @@ properties:
7384
value:
7485
packageName: bar
7586
versionRange: <0.1.0
76-
- type: olm.skipRange
77-
value: <0.2.0
78-
- type: olm.skips
79-
value: foo.v0.1.1
80-
- type: olm.skips
81-
value: foo.v0.1.2
8287
- type: olm.bundle.object
8388
value:
8489
data: eyJhcGlWZXJzaW9uIjoib3BlcmF0b3JzLmNvcmVvcy5jb20vdjFhbHBoYTEiLCJraW5kIjoiQ2x1c3RlclNlcnZpY2VWZXJzaW9uIiwibWV0YWRhdGEiOnsiYW5ub3RhdGlvbnMiOnsib2xtLnNraXBSYW5nZSI6Ilx1MDAzYzAuMi4wIn0sIm5hbWUiOiJmb28udjAuMi4wIn0sInNwZWMiOnsiY3VzdG9tcmVzb3VyY2VkZWZpbml0aW9ucyI6eyJvd25lZCI6W3siZ3JvdXAiOiJ0ZXN0LmZvbyIsImtpbmQiOiJGb28iLCJuYW1lIjoiZm9vcy50ZXN0LmZvbyIsInZlcnNpb24iOiJ2MSJ9XX0sImRpc3BsYXlOYW1lIjoiRm9vIE9wZXJhdG9yIiwicmVsYXRlZEltYWdlcyI6W3siaW1hZ2UiOiJ0ZXN0LnJlZ2lzdHJ5L2Zvby1vcGVyYXRvci9mb286djAuMi4wIiwibmFtZSI6Im9wZXJhdG9yIn1dLCJyZXBsYWNlcyI6ImZvby52MC4xLjAiLCJza2lwcyI6WyJmb28udjAuMS4xIiwiZm9vLnYwLjEuMiJdLCJ2ZXJzaW9uIjoiMC4yLjAifX0=

0 commit comments

Comments
 (0)