Skip to content

Commit 63b1606

Browse files
akihikokurodaperdasilva
authored andcommitted
adding properties to package and channel (#900)
Signed-off-by: akihikokuroda <[email protected]> Upstream-repository: operator-registry Upstream-commit: 5c3f4a3a3365c6684f78a3617e4cfc650bec73e3
1 parent a6f1618 commit 63b1606

File tree

7 files changed

+101
-20
lines changed

7 files changed

+101
-20
lines changed

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package action_test
33
import (
44
"context"
55
"embed"
6+
"encoding/json"
67
"errors"
78
"io/fs"
89
"os"
@@ -265,13 +266,20 @@ func TestRender(t *testing.T) {
265266
Schema: "olm.package",
266267
Name: "foo",
267268
DefaultChannel: "beta",
269+
Properties: []property.Property{
270+
{Type: "owner", Value: json.RawMessage("{\"group\":\"abc.com\",\"name\":\"admin\"}")},
271+
},
268272
},
269273
},
270274
Channels: []declcfg.Channel{
271275
{Schema: "olm.channel", Package: "foo", Name: "beta", Entries: []declcfg.ChannelEntry{
272276
{Name: "foo.v0.1.0", SkipRange: "<0.1.0"},
273277
{Name: "foo.v0.2.0", Replaces: "foo.v0.1.0", SkipRange: "<0.2.0", Skips: []string{"foo.v0.1.1", "foo.v0.1.2"}},
274-
}},
278+
},
279+
Properties: []property.Property{
280+
{Type: "user", Value: json.RawMessage("{\"group\":\"xyz.com\",\"name\":\"account\"}")},
281+
},
282+
},
275283
{Schema: "olm.channel", Package: "foo", Name: "stable", Entries: []declcfg.ChannelEntry{
276284
{Name: "foo.v0.2.0", Replaces: "foo.v0.1.0", SkipRange: "<0.2.0", Skips: []string{"foo.v0.1.1", "foo.v0.1.2"}},
277285
}},
@@ -356,13 +364,20 @@ func TestRender(t *testing.T) {
356364
Schema: "olm.package",
357365
Name: "foo",
358366
DefaultChannel: "beta",
367+
Properties: []property.Property{
368+
{Type: "owner", Value: json.RawMessage("{\"group\":\"abc.com\",\"name\":\"admin\"}")},
369+
},
359370
},
360371
},
361372
Channels: []declcfg.Channel{
362373
{Schema: "olm.channel", Package: "foo", Name: "beta", Entries: []declcfg.ChannelEntry{
363374
{Name: "foo.v0.1.0", SkipRange: "<0.1.0"},
364375
{Name: "foo.v0.2.0", Replaces: "foo.v0.1.0", SkipRange: "<0.2.0", Skips: []string{"foo.v0.1.1", "foo.v0.1.2"}},
365-
}},
376+
},
377+
Properties: []property.Property{
378+
{Type: "user", Value: json.RawMessage("{\"group\":\"xyz.com\",\"name\":\"account\"}")},
379+
},
380+
},
366381
{Schema: "olm.channel", Package: "foo", Name: "stable", Entries: []declcfg.ChannelEntry{
367382
{Name: "foo.v0.2.0", Replaces: "foo.v0.1.0", SkipRange: "<0.2.0", Skips: []string{"foo.v0.1.1", "foo.v0.1.2"}},
368383
}},

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
schema: olm.package
33
name: foo
44
defaultChannel: beta
5+
properties:
6+
- type: owner
7+
value:
8+
group: abc.com
9+
name: admin
510
---
611
schema: olm.channel
712
package: foo
@@ -15,6 +20,11 @@ entries:
1520
skips:
1621
- foo.v0.1.1
1722
- foo.v0.1.2
23+
properties:
24+
- type: user
25+
value:
26+
group: xyz.com
27+
name: account
1828
---
1929
schema: olm.channel
2030
package: foo

staging/operator-registry/alpha/declcfg/declcfg.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ type DeclarativeConfig struct {
2020
}
2121

2222
type Package struct {
23-
Schema string `json:"schema"`
24-
Name string `json:"name"`
25-
DefaultChannel string `json:"defaultChannel"`
26-
Icon *Icon `json:"icon,omitempty"`
27-
Description string `json:"description,omitempty"`
23+
Schema string `json:"schema"`
24+
Name string `json:"name"`
25+
DefaultChannel string `json:"defaultChannel"`
26+
Icon *Icon `json:"icon,omitempty"`
27+
Description string `json:"description,omitempty"`
28+
Properties []property.Property `json:"properties,omitempty" hash:"set"`
2829
}
2930

3031
type Icon struct {
@@ -33,10 +34,11 @@ type Icon struct {
3334
}
3435

3536
type Channel struct {
36-
Schema string `json:"schema"`
37-
Name string `json:"name"`
38-
Package string `json:"package"`
39-
Entries []ChannelEntry `json:"entries"`
37+
Schema string `json:"schema"`
38+
Name string `json:"name"`
39+
Package string `json:"package"`
40+
Entries []ChannelEntry `json:"entries"`
41+
Properties []property.Property `json:"properties,omitempty" hash:"set"`
4042
}
4143

4244
type ChannelEntry struct {

staging/operator-registry/alpha/declcfg/declcfg_to_model_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,38 @@ func TestConvertToModel(t *testing.T) {
248248
Bundles: []Bundle{newTestBundle("foo", "0.1.0")},
249249
},
250250
},
251+
{
252+
name: "Success/ValidModelWithChannelProperties",
253+
assertion: require.NoError,
254+
cfg: DeclarativeConfig{
255+
Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)},
256+
Channels: []Channel{
257+
addChannelProperties(
258+
newTestChannel("foo", "alpha", ChannelEntry{Name: "foo.v0.1.0"}),
259+
[]property.Property{
260+
{Type: "user", Value: json.RawMessage("{\"group\":\"xyz.com\",\"name\":\"account\"}")},
261+
},
262+
),
263+
},
264+
Bundles: []Bundle{newTestBundle("foo", "0.1.0")},
265+
},
266+
},
267+
{
268+
name: "Success/ValidModelWithPackageProperties",
269+
assertion: require.NoError,
270+
cfg: DeclarativeConfig{
271+
Packages: []Package{
272+
addPackageProperties(
273+
newTestPackage("foo", "alpha", svgSmallCircle),
274+
[]property.Property{
275+
{Type: "owner", Value: json.RawMessage("{\"group\":\"abc.com\",\"name\":\"admin\"}")},
276+
},
277+
),
278+
},
279+
Channels: []Channel{newTestChannel("foo", "alpha", ChannelEntry{Name: "foo.v0.1.0"})},
280+
Bundles: []Bundle{newTestBundle("foo", "0.1.0")},
281+
},
282+
},
251283
}
252284

253285
for _, s := range specs {

staging/operator-registry/alpha/declcfg/helpers_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,11 @@ func newTestPackage(packageName, defaultChannel, svgData string) Package {
159159
return p
160160
}
161161

162+
func addPackageProperties(in Package, p []property.Property) Package {
163+
in.Properties = p
164+
return in
165+
}
166+
162167
func newTestChannel(packageName, channelName string, entries ...ChannelEntry) Channel {
163168
return Channel{
164169
Schema: schemaChannel,
@@ -168,6 +173,11 @@ func newTestChannel(packageName, channelName string, entries ...ChannelEntry) Ch
168173
}
169174
}
170175

176+
func addChannelProperties(in Channel, p []property.Property) Channel {
177+
in.Properties = p
178+
return in
179+
}
180+
171181
func buildTestModel() model.Model {
172182
return model.Model{
173183
"anakin": buildAnakinPkgModel(),

vendor/github.com/operator-framework/operator-registry/alpha/action/testdata/foo-index-v0.2.0-declcfg/foo/index.yaml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/operator-framework/operator-registry/alpha/declcfg/declcfg.go

Lines changed: 11 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)