Skip to content

Commit 65c171c

Browse files
joehuizengapawicao-ibm
authored andcommitted
Enhance diff logic to set a new defaultChannel by adding a priority property to a channel (#969)
* Added the channel Priority feature * Added comments for the internal usage of Channel properties Signed-off-by: Oskar Pawica <[email protected]> Signed-off-by: Oskar Pawica <[email protected]> Co-authored-by: Oskar Pawica <[email protected]> Upstream-repository: operator-registry Upstream-commit: 208775f5a9bf02804646751ef9c7cf48d7902e9b
1 parent 8280461 commit 65c171c

File tree

10 files changed

+86
-0
lines changed

10 files changed

+86
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ func ConvertToModel(cfg DeclarativeConfig) (model.Model, error) {
5656
Package: mpkg,
5757
Name: c.Name,
5858
Bundles: map[string]*model.Bundle{},
59+
// NOTICE: The field Properties of the type Channel is for internal use only.
60+
// DO NOT use it for any public-facing functionalities.
61+
// This API is in alpha stage and it is subject to change.
62+
Properties: c.Properties,
5963
}
6064

6165
cde := sets.NewString()

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ func traverseModelChannels(mpkg model.Package) ([]Channel, []Bundle) {
6464
Name: ch.Name,
6565
Package: ch.Package.Name,
6666
Entries: []ChannelEntry{},
67+
// NOTICE: The field Properties of the type Channel is for internal use only.
68+
// DO NOT use it for any public-facing functionalities.
69+
// This API is in alpha stage and it is subject to change.
70+
Properties: ch.Properties,
6771
}
6872

6973
for _, chb := range ch.Bundles {

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ type Channel struct {
134134
Package *Package
135135
Name string
136136
Bundles map[string]*Bundle
137+
// NOTICE: The field Properties of the type Channel is for internal use only.
138+
// DO NOT use it for any public-facing functionalities.
139+
// This API is in alpha stage and it is subject to change.
140+
Properties []property.Property
137141
}
138142

139143
// TODO(joelanford): This function determines the channel head by finding the bundle that has 0

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ type Package struct {
3939
Version string `json:"version"`
4040
}
4141

42+
// NOTICE: The Channel properties are for internal use only.
43+
// DO NOT use it for any public-facing functionalities.
44+
// This API is in alpha stage and it is subject to change.
45+
type Channel struct {
46+
ChannelName string `json:"channelName"`
47+
//Priority string `json:"priority"`
48+
Priority int `json:"priority"`
49+
}
50+
4251
type PackageRequired struct {
4352
PackageName string `json:"packageName"`
4453
VersionRange string `json:"versionRange"`
@@ -118,6 +127,7 @@ type Properties struct {
118127
GVKs []GVK `hash:"set"`
119128
GVKsRequired []GVKRequired `hash:"set"`
120129
BundleObjects []BundleObject `hash:"set"`
130+
Channels []Channel `hash:"set"`
121131

122132
Others []Property `hash:"set"`
123133
}
@@ -128,6 +138,7 @@ const (
128138
TypeGVK = "olm.gvk"
129139
TypeGVKRequired = "olm.gvk.required"
130140
TypeBundleObject = "olm.bundle.object"
141+
TypeChannel = "olm.channel"
131142
)
132143

133144
func Parse(in []Property) (*Properties, error) {
@@ -164,6 +175,15 @@ func Parse(in []Property) (*Properties, error) {
164175
return nil, ParseError{Idx: i, Typ: prop.Type, Err: err}
165176
}
166177
out.BundleObjects = append(out.BundleObjects, p)
178+
// NOTICE: The Channel properties are for internal use only.
179+
// DO NOT use it for any public-facing functionalities.
180+
// This API is in alpha stage and it is subject to change.
181+
case TypeChannel:
182+
var p Channel
183+
if err := json.Unmarshal(prop.Value, &p); err != nil {
184+
return nil, ParseError{Idx: i, Typ: prop.Type, Err: err}
185+
}
186+
out.Channels = append(out.Channels, p)
167187
default:
168188
var p json.RawMessage
169189
if err := json.Unmarshal(prop.Value, &p); err != nil {
@@ -265,3 +285,10 @@ func MustBuildBundleObjectRef(ref string) Property {
265285
func MustBuildBundleObjectData(data []byte) Property {
266286
return MustBuild(&BundleObject{File: File{data: data}})
267287
}
288+
289+
// NOTICE: The Channel properties are for internal use only.
290+
// DO NOT use it for any public-facing functionalities.
291+
// This API is in alpha stage and it is subject to change.
292+
func MustBuildChannelPriority(name string, priority int) Property {
293+
return MustBuild(&Channel{ChannelName: name, Priority: priority})
294+
}

staging/operator-registry/alpha/property/scheme.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ func init() {
1212
reflect.TypeOf(&GVK{}): TypeGVK,
1313
reflect.TypeOf(&GVKRequired{}): TypeGVKRequired,
1414
reflect.TypeOf(&BundleObject{}): TypeBundleObject,
15+
// NOTICE: The Channel properties are for internal use only.
16+
// DO NOT use it for any public-facing functionalities.
17+
// This API is in alpha stage and it is subject to change.
18+
reflect.TypeOf(&Channel{}): TypeChannel,
1519
}
1620
}
1721

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

Lines changed: 4 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/model_to_declcfg.go

Lines changed: 4 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/model/model.go

Lines changed: 4 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/property/property.go

Lines changed: 27 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/property/scheme.go

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

0 commit comments

Comments
 (0)