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
5 changes: 5 additions & 0 deletions bundles/etcd.0.9.2/metadata/dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ dependencies:
group: testapi.coreos.com
kind: testapi
version: v1
- type: olm.constraint
value:
failureMessage: 'require to have "certified"'
cel:
rule: 'properties.exists(p, p.type == "certified")'
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ require (
github.com/onsi/gomega v1.15.0
github.com/opencontainers/go-digest v1.0.0
github.com/opencontainers/image-spec v1.0.2-0.20190823105129-775207bd45b6
github.com/operator-framework/api v0.11.0
github.com/operator-framework/api v0.11.1
github.com/otiai10/copy v1.2.0
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2
github.com/pkg/errors v0.9.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -649,8 +649,8 @@ github.com/opencontainers/runtime-spec v0.1.2-0.20190507144316-5b71a03e2700 h1:e
github.com/opencontainers/runtime-spec v0.1.2-0.20190507144316-5b71a03e2700/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw=
github.com/operator-framework/api v0.11.0 h1:W9V1NNwl3LWPQL9S1pDaFONCarJLl8Xu6gdF9w54hTE=
github.com/operator-framework/api v0.11.0/go.mod h1:FTiYGm11fZQ3cSX+EQHc/UWoGZAwkGfyeHU+wMJ8jmA=
github.com/operator-framework/api v0.11.1 h1:5eNUMplyL/GZrnBgG4SS2csO3+Fl4F79OqXN6POHQyA=
github.com/operator-framework/api v0.11.1/go.mod h1:FTiYGm11fZQ3cSX+EQHc/UWoGZAwkGfyeHU+wMJ8jmA=
github.com/otiai10/copy v1.2.0 h1:HvG945u96iNadPoG2/Ja2+AUJeW5YuFQMixq9yirC+k=
github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw=
github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE=
Expand Down
16 changes: 16 additions & 0 deletions pkg/registry/populator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ func TestQuerierForImage(t *testing.T) {
Type: "olm.gvk",
Value: `{"group":"etcd.database.coreos.com","kind":"EtcdCluster","version":"v1beta2"}`,
},
{
Type: "olm.constraint",
Value: `{"cel":{"rule":"properties.exists(p, p.type == \"certified\")"},"failureMessage":"require to have \"certified\""}`,
},
},
Properties: []*api.Property{
{
Expand Down Expand Up @@ -572,6 +576,10 @@ func TestQuerierForDependencies(t *testing.T) {
Type: "olm.gvk",
Value: `{"group":"testprometheus.coreos.com","kind":"testtestprometheus","version":"v1"}`,
},
{
Type: "olm.constraint",
Value: `{"cel":{"rule":"properties.exists(p, p.type == \"certified\")"},"failureMessage":"require to have \"certified\""}`,
},
}

type operatorbundle struct {
Expand Down Expand Up @@ -635,6 +643,14 @@ func TestListBundles(t *testing.T) {
Type: "olm.gvk",
Value: `{"group":"etcd.database.coreos.com","kind":"EtcdCluster","version":"v1beta2"}`,
},
{
Type: "olm.constraint",
Value: `{"cel":{"rule":"properties.exists(p, p.type == \"certified\")"},"failureMessage":"require to have \"certified\""}`,
},
{
Type: "olm.constraint",
Value: `{"cel":{"rule":"properties.exists(p, p.type == \"certified\")"},"failureMessage":"require to have \"certified\""}`,
},
}

dependencies := []*api.Dependency{}
Expand Down
5 changes: 5 additions & 0 deletions pkg/registry/registry_to_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ func ObjectsAndPropertiesFromBundle(b *Bundle) ([]string, []property.Property, e
return nil, nil, property.ParseError{Idx: i, Typ: p.Type, Err: err}
}
packageRequiredProps = append(packageRequiredProps, property.MustBuildPackageRequired(v.PackageName, v.Version))
default:
otherProps = append(otherProps, property.Property{
Type: p.Type,
Value: p.Value,
})
}
}

Expand Down
6 changes: 6 additions & 0 deletions pkg/registry/registry_to_model_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package registry

import (
"encoding/json"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -44,7 +45,12 @@ func testExpectedProperties() []property.Property {
property.MustBuildGVK("etcd.database.coreos.com", "v1beta2", "EtcdCluster"),
property.MustBuildGVK("etcd.database.coreos.com", "v1beta2", "EtcdBackup"),
property.MustBuildGVK("etcd.database.coreos.com", "v1beta2", "EtcdRestore"),
property.Property{
Type: "olm.constraint",
Value: json.RawMessage(`{"cel":{"rule":"properties.exists(p, p.type == \"certified\")"},"failureMessage":"require to have \"certified\""}`),
},
}

for _, obj := range testExpectedObjects() {
props = append(props, property.MustBuildBundleObjectData([]byte(obj)))
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/registry/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ type LabelDependency struct {
}

type CelConstraint struct {
// Constraint message that surfaces in resolution
// Constraint failure message that surfaces in resolution
// This field is optional
Message string `json:"message" yaml:"message"`
FailureMessage string `json:"failureMessage" yaml:"failureMessage"`

// The cel struct that contraints CEL expression
// This field is required
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ github.com/opencontainers/go-digest
## explicit
github.com/opencontainers/image-spec/specs-go
github.com/opencontainers/image-spec/specs-go/v1
# github.com/operator-framework/api v0.11.0
# github.com/operator-framework/api v0.11.1
## explicit
github.com/operator-framework/api/pkg/constraints
github.com/operator-framework/api/pkg/lib/version
Expand Down