Skip to content

Commit 98e5686

Browse files
joehuizengagrokspawn
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]> Upstream-commit: 208775f5a9bf02804646751ef9c7cf48d7902e9b Upstream-repository: operator-registry
1 parent 2c1d93c commit 98e5686

File tree

57 files changed

+97
-3878
lines changed

Some content is hidden

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

57 files changed

+97
-3878
lines changed

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ require (
161161
github.com/mitchellh/copystructure v1.2.0 // indirect
162162
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
163163
github.com/mitchellh/hashstructure v1.0.0 // indirect
164-
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
165164
github.com/mitchellh/mapstructure v1.4.1 // indirect
166165
github.com/mitchellh/reflectwalk v1.0.2 // indirect
167166
github.com/moby/locker v1.0.1 // indirect

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -889,8 +889,6 @@ github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUb
889889
github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
890890
github.com/mitchellh/hashstructure v1.0.0 h1:ZkRJX1CyOoTkar7p/mLS5TZU4nJ1Rn/F8u9dGS02Q3Y=
891891
github.com/mitchellh/hashstructure v1.0.0/go.mod h1:QjSHrPWS+BGUVBYkbTZWEnOh3G1DutKwClXU/ABz6AQ=
892-
github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4=
893-
github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE=
894892
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
895893
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
896894
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=

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/mitchellh/hashstructure/v2/LICENSE

Lines changed: 0 additions & 21 deletions
This file was deleted.

vendor/github.com/mitchellh/hashstructure/v2/README.md

Lines changed: 0 additions & 76 deletions
This file was deleted.

vendor/github.com/mitchellh/hashstructure/v2/errors.go

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)