Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions alpha/action/render_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package action_test
import (
"context"
"embed"
"encoding/json"
"errors"
"io/fs"
"os"
Expand Down Expand Up @@ -265,13 +266,20 @@ func TestRender(t *testing.T) {
Schema: "olm.package",
Name: "foo",
DefaultChannel: "beta",
Properties: []property.Property{
{Type: "owner", Value: json.RawMessage("{\"group\":\"abc.com\",\"name\":\"admin\"}")},
},
},
},
Channels: []declcfg.Channel{
{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"}},
}},
},
Properties: []property.Property{
{Type: "user", Value: json.RawMessage("{\"group\":\"xyz.com\",\"name\":\"account\"}")},
},
},
{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"}},
}},
Expand Down Expand Up @@ -356,13 +364,20 @@ func TestRender(t *testing.T) {
Schema: "olm.package",
Name: "foo",
DefaultChannel: "beta",
Properties: []property.Property{
{Type: "owner", Value: json.RawMessage("{\"group\":\"abc.com\",\"name\":\"admin\"}")},
},
},
},
Channels: []declcfg.Channel{
{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"}},
}},
},
Properties: []property.Property{
{Type: "user", Value: json.RawMessage("{\"group\":\"xyz.com\",\"name\":\"account\"}")},
},
},
{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"}},
}},
Expand Down
10 changes: 10 additions & 0 deletions alpha/action/testdata/foo-index-v0.2.0-declcfg/foo/index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
schema: olm.package
name: foo
defaultChannel: beta
properties:
- type: owner
value:
group: abc.com
name: admin
---
schema: olm.channel
package: foo
Expand All @@ -15,6 +20,11 @@ entries:
skips:
- foo.v0.1.1
- foo.v0.1.2
properties:
- type: user
value:
group: xyz.com
name: account
---
schema: olm.channel
package: foo
Expand Down
20 changes: 11 additions & 9 deletions alpha/declcfg/declcfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ type DeclarativeConfig struct {
}

type Package struct {
Schema string `json:"schema"`
Name string `json:"name"`
DefaultChannel string `json:"defaultChannel"`
Icon *Icon `json:"icon,omitempty"`
Description string `json:"description,omitempty"`
Schema string `json:"schema"`
Name string `json:"name"`
DefaultChannel string `json:"defaultChannel"`
Icon *Icon `json:"icon,omitempty"`
Description string `json:"description,omitempty"`
Properties []property.Property `json:"properties,omitempty" hash:"set"`
}

type Icon struct {
Expand All @@ -33,10 +34,11 @@ type Icon struct {
}

type Channel struct {
Schema string `json:"schema"`
Name string `json:"name"`
Package string `json:"package"`
Entries []ChannelEntry `json:"entries"`
Schema string `json:"schema"`
Name string `json:"name"`
Package string `json:"package"`
Entries []ChannelEntry `json:"entries"`
Properties []property.Property `json:"properties,omitempty" hash:"set"`
}

type ChannelEntry struct {
Expand Down
32 changes: 32 additions & 0 deletions alpha/declcfg/declcfg_to_model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,38 @@ func TestConvertToModel(t *testing.T) {
Bundles: []Bundle{newTestBundle("foo", "0.1.0")},
},
},
{
name: "Success/ValidModelWithChannelProperties",
assertion: require.NoError,
cfg: DeclarativeConfig{
Packages: []Package{newTestPackage("foo", "alpha", svgSmallCircle)},
Channels: []Channel{
addChannelProperties(
newTestChannel("foo", "alpha", ChannelEntry{Name: "foo.v0.1.0"}),
[]property.Property{
{Type: "user", Value: json.RawMessage("{\"group\":\"xyz.com\",\"name\":\"account\"}")},
},
),
},
Bundles: []Bundle{newTestBundle("foo", "0.1.0")},
},
},
{
name: "Success/ValidModelWithPackageProperties",
assertion: require.NoError,
cfg: DeclarativeConfig{
Packages: []Package{
addPackageProperties(
newTestPackage("foo", "alpha", svgSmallCircle),
[]property.Property{
{Type: "owner", Value: json.RawMessage("{\"group\":\"abc.com\",\"name\":\"admin\"}")},
},
),
},
Channels: []Channel{newTestChannel("foo", "alpha", ChannelEntry{Name: "foo.v0.1.0"})},
Bundles: []Bundle{newTestBundle("foo", "0.1.0")},
},
},
}

for _, s := range specs {
Expand Down
10 changes: 10 additions & 0 deletions alpha/declcfg/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ func newTestPackage(packageName, defaultChannel, svgData string) Package {
return p
}

func addPackageProperties(in Package, p []property.Property) Package {
in.Properties = p
return in
}

func newTestChannel(packageName, channelName string, entries ...ChannelEntry) Channel {
return Channel{
Schema: schemaChannel,
Expand All @@ -168,6 +173,11 @@ func newTestChannel(packageName, channelName string, entries ...ChannelEntry) Ch
}
}

func addChannelProperties(in Channel, p []property.Property) Channel {
in.Properties = p
return in
}

func buildTestModel() model.Model {
return model.Model{
"anakin": buildAnakinPkgModel(),
Expand Down