Skip to content

Commit

Permalink
refactor(constraint): update none compound constraint to be not (#221)
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Slaton <[email protected]>
  • Loading branch information
tylerslaton authored and timflannagan committed Jan 27, 2022
1 parent 1602407 commit 1b2c50b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
9 changes: 5 additions & 4 deletions pkg/constraints/constraint.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ type Constraint struct {
// GVK defines a constraint for a GVK.
GVK *GVKConstraint `json:"gvk,omitempty" yaml:"gvk,omitempty"`

// All, Any, and None are compound constraints. See this enhancement for details:
// All, Any, and Not are compound constraints. See this enhancement for details:
// https://github.com/operator-framework/enhancements/blob/master/enhancements/compound-bundle-constraints.md
All *CompoundConstraint `json:"all,omitempty" yaml:"all,omitempty"`
Any *CompoundConstraint `json:"any,omitempty" yaml:"any,omitempty"`
// A note on None: this constraint is not particularly useful by itself.
// A note on Not: this constraint isn't particularly useful by itself.
// It should be used within an All constraint alongside some other constraint type
// since saying "none of these GVKs/packages/etc." without an alternative doesn't make sense.
None *CompoundConstraint `json:"none,omitempty" yaml:"none,omitempty"`
// since saying "do not use any of these GVKs/packages/etc." without an alternative
// doesn't make sense.
Not *CompoundConstraint `json:"not,omitempty" yaml:"not,omitempty"`
}

// CompoundConstraint holds a list of potentially nested constraints
Expand Down
10 changes: 5 additions & 5 deletions pkg/constraints/constraint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ func TestParse(t *testing.T) {
},
},
{
name: "Valid/BasicNone",
input: json.RawMessage(fmt.Sprintf(inputBasicCompoundTmpl, "none")),
name: "Valid/BasicNot",
input: json.RawMessage(fmt.Sprintf(inputBasicCompoundTmpl, "not")),
expConstraint: Constraint{
FailureMessage: "blah",
None: &CompoundConstraint{
Not: &CompoundConstraint{
Constraints: []Constraint{
{
FailureMessage: "blah blah",
Expand Down Expand Up @@ -109,7 +109,7 @@ func TestParse(t *testing.T) {
},
},
{
None: &CompoundConstraint{
Not: &CompoundConstraint{
Constraints: []Constraint{
{GVK: &GVKConstraint{Group: "bazs.example.com", Kind: "Baz", Version: "v1alpha1"}},
},
Expand Down Expand Up @@ -256,7 +256,7 @@ const (
}
},
{
"none": {
"not": {
"constraints": [
{
"gvk": {
Expand Down

0 comments on commit 1b2c50b

Please sign in to comment.