Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Record InChannel information for bundles; add test for ProvidesGVK filter. #1

Merged
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
4 changes: 1 addition & 3 deletions internal/catalogmetadata/predicates.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package catalogmetadata
import (
mmsemver "github.com/Masterminds/semver/v3"
bsemver "github.com/blang/semver/v4"

olmentity "github.com/operator-framework/operator-controller/internal/resolution/entities"
)

// TODO: Move somewhere nice. Probably into a ./predicates package
Expand Down Expand Up @@ -54,7 +52,7 @@ func InChannel(channelName string) Predicate[Bundle] {
}
}

func ProvidesGVK(gvk *olmentity.GVK) Predicate[Bundle] {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

func ProvidesGVK(gvk *GVK) Predicate[Bundle] {
return func(bundle *Bundle) bool {
providedGVKs, err := bundle.ProvidedGVKs()
if err != nil {
Expand Down
28 changes: 27 additions & 1 deletion internal/catalogmetadata/predicates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,33 @@ func TestInChannel(t *testing.T) {
}

func TestProvidesGVK(t *testing.T) {
// TODO:
b1 := &catalogmetadata.Bundle{Bundle: declcfg.Bundle{
Properties: []property.Property{
{
Type: property.TypeGVK,
Value: json.RawMessage(`[{"group":"foo.io","kind":"Foo","version":"v1"},{"group":"bar.io","kind":"Bar","version":"v1"}]`),
},
},
}}
b2 := &catalogmetadata.Bundle{Bundle: declcfg.Bundle{
Properties: []property.Property{},
}}
f1 := catalogmetadata.ProvidesGVK(&catalogmetadata.GVK{
Group: "foo.io",
Version: "v1",
Kind: "Foo",
})
f2 := catalogmetadata.ProvidesGVK(&catalogmetadata.GVK{
Group: "baz.io",
Version: "v1alpha1",
Kind: "Baz",
})
// Filter with Bundle which provides the GVK should return true
assert.True(t, f1(b1))
// Filter with Bundle which does not provide the GVK should return false
assert.False(t, f2(b1))
// Filter with Bundle with no GVK should return false
assert.False(t, f1(b2))
}

func TestWithBundleImage(t *testing.T) {
Expand Down