Skip to content

chore(constraint): Correct message to failureMessage in olm.constraint schema #2572

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

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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ require (
github.com/onsi/gomega v1.15.0
github.com/openshift/api v0.0.0-20200331152225-585af27e34fd
github.com/openshift/client-go v0.0.0-20200326155132-2a6cd50aedd0
github.com/operator-framework/api v0.11.0
github.com/operator-framework/api v0.11.1
Copy link
Member

Choose a reason for hiding this comment

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

Just for other reviewers: operator-framework/api@1602407 is tagged v0.11.1 on the o-f/api side.

github.com/operator-framework/operator-registry v1.17.5
github.com/otiai10/copy v1.2.0
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 @@ -927,8 +927,8 @@ github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJ
github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4=
github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4=
github.com/operator-framework/api v0.7.1/go.mod h1:L7IvLd/ckxJEJg/t4oTTlnHKAJIP/p51AvEslW3wYdY=
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/operator-framework/operator-registry v1.17.5 h1:LR8m1rFz5Gcyje8WK6iYt+gIhtzqo52zMRALdmTYHT0=
github.com/operator-framework/operator-registry v1.17.5/go.mod h1:sRQIgDMZZdUcmHltzyCnM6RUoDF+WS8Arj1BQIARDS8=
github.com/otiai10/copy v1.2.0 h1:HvG945u96iNadPoG2/Ja2+AUJeW5YuFQMixq9yirC+k=
Expand Down
12 changes: 6 additions & 6 deletions pkg/controller/registry/resolver/cache/predicates.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,9 @@ func CountingPredicate(p Predicate, n *int) Predicate {
}

type celPredicate struct {
program constraints.CelProgram
rule string
message string
program constraints.CelProgram
rule string
failureMessage string
}

func (cp *celPredicate) Test(entry *Entry) bool {
Expand All @@ -383,14 +383,14 @@ func (cp *celPredicate) Test(entry *Entry) bool {
return ok
}

func CreateCelPredicate(env *constraints.CelEnvironment, rule string, message string) (Predicate, error) {
func CreateCelPredicate(env *constraints.CelEnvironment, rule string, failureMessage string) (Predicate, error) {
prog, err := env.Validate(rule)
if err != nil {
return nil, err
}
return &celPredicate{program: prog, rule: rule, message: message}, nil
return &celPredicate{program: prog, rule: rule, failureMessage: failureMessage}, nil
}

func (cp *celPredicate) String() string {
return fmt.Sprintf("with constraint: %q and message: %q", cp.rule, cp.message)
return fmt.Sprintf("with constraint: %q and message: %q", cp.rule, cp.failureMessage)
}
2 changes: 1 addition & 1 deletion pkg/controller/registry/resolver/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ func (pc *predicateConverter) convertConstraints(constraints ...constraints.Cons
subs, perr := pc.convertConstraints(constraint.None.Constraints...)
preds[i], err = cache.Not(subs...), perr
case constraint.Cel != nil:
preds[i], err = cache.CreateCelPredicate(pc.celEnv, constraint.Cel.Rule, constraint.Message)
preds[i], err = cache.CreateCelPredicate(pc.celEnv, constraint.Cel.Rule, constraint.FailureMessage)
default:
// Unknown constraint types are handled by constraints.Parse(),
// but parsed constraints may be empty.
Expand Down
14 changes: 7 additions & 7 deletions pkg/controller/registry/resolver/resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ func TestSolveOperators_OLMConstraint_CompoundAll(t *testing.T) {
catName: csName, catNamespace: namespace,
properties: []*api.Property{{
Type: constraints.OLMConstraintType,
Value: `{"message": "all constraint",
Value: `{"failureMessage": "all constraint",
"all": {"constraints": [
{"package": {"packageName": "foo", "versionRange": ">=1.0.0"}},
{"gvk": {"group": "g1", "version": "v1", "kind": "k1"}},
Expand Down Expand Up @@ -985,7 +985,7 @@ func TestSolveOperators_OLMConstraint_CompoundAny(t *testing.T) {
catName: csName, catNamespace: namespace,
properties: []*api.Property{{
Type: constraints.OLMConstraintType,
Value: `{"message": "any constraint",
Value: `{"failureMessage": "any constraint",
"any": {"constraints": [
{"gvk": {"group": "g1", "version": "v1", "kind": "k1"}},
{"gvk": {"group": "g2", "version": "v2", "kind": "k2"}}
Expand Down Expand Up @@ -1065,7 +1065,7 @@ func TestSolveOperators_OLMConstraint_CompoundNone(t *testing.T) {
properties: []*api.Property{
{
Type: constraints.OLMConstraintType,
Value: `{"message": "compound none constraint",
Value: `{"failureMessage": "compound none constraint",
"all": {"constraints": [
{"gvk": {"group": "g0", "version": "v0", "kind": "k0"}},
{"none": {"constraints": [
Expand Down Expand Up @@ -1150,7 +1150,7 @@ func TestSolveOperators_OLMConstraint_Unknown(t *testing.T) {
catName: csName, catNamespace: namespace,
properties: []*api.Property{{
Type: constraints.OLMConstraintType,
Value: `{"message": "unknown constraint", "unknown": {"foo": "bar"}}`,
Value: `{"failureMessage": "unknown constraint", "unknown": {"foo": "bar"}}`,
}},
}}

Expand Down Expand Up @@ -2489,21 +2489,21 @@ func TestSolveOperators_GenericConstraint(t *testing.T) {
deps1 := []*api.Dependency{
{
Type: "olm.constraint",
Value: `{"message":"gvk-constraint",
Value: `{"failureMessage":"gvk-constraint",
"cel":{"rule":"properties.exists(p, p.type == 'olm.gvk' && p.value == {'group': 'g', 'version': 'v', 'kind': 'k'})"}}`,
},
}
deps2 := []*api.Dependency{
{
Type: "olm.constraint",
Value: `{"message":"gvk2-constraint",
Value: `{"failureMessage":"gvk2-constraint",
"cel":{"rule":"properties.exists(p, p.type == 'olm.gvk' && p.value == {'group': 'g2', 'version': 'v', 'kind': 'k'})"}}`,
},
}
deps3 := []*api.Dependency{
{
Type: "olm.constraint",
Value: `{"message":"package-constraint",
Value: `{"failureMessage":"package-constraint",
"cel":{"rule":"properties.exists(p, p.type == 'olm.package' && p.value.packageName == 'packageB' && (semver_compare(p.value.version, '1.0.1') == 0))"}}`,
},
}
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 @@ -624,7 +624,7 @@ github.com/openshift/client-go/config/informers/externalversions/config
github.com/openshift/client-go/config/informers/externalversions/config/v1
github.com/openshift/client-go/config/informers/externalversions/internalinterfaces
github.com/openshift/client-go/config/listers/config/v1
# github.com/operator-framework/api v0.11.0
# github.com/operator-framework/api v0.11.1
## explicit; go 1.16
github.com/operator-framework/api/crds
github.com/operator-framework/api/pkg/constraints
Expand Down