Skip to content

Commit

Permalink
Record InChannel information for bundles; add test for ProvidesGVK fi…
Browse files Browse the repository at this point in the history
…lter.

Signed-off-by: dtfranz <[email protected]>
  • Loading branch information
dtfranz authored and m1kola committed Sep 7, 2023
1 parent b69c3ca commit f95c32c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
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] {
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

0 comments on commit f95c32c

Please sign in to comment.