-
Notifications
You must be signed in to change notification settings - Fork 77
feat(constraints): add compound constraints and olm.constraint value parser #203
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
feat(constraints): add compound constraints and olm.constraint value parser #203
Conversation
pkg/constraints/constraint.go
Outdated
// CompoundConstraint holds a list of potentially nested constraints | ||
// over which a boolean operation is applied. | ||
type CompoundConstraint struct { | ||
Constraints []Constraint `json:"constraints"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I understand CompoundConstraint
is a list of constraints but then Constraint
itself can be a All
, Any
, None
constraint which is a CompoundConstraint
itself. So we potentially have a CompoundConstraint
as a list of CompoundConstraint
. While it is not a problem programmatically but logically it is convoluted and frankly difficult to test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not quite, since CompoundConstraint
does not alias Constraint
; they're two distinct types. I don't see how you would get nice recursion that leverages std serialization libs otherwise. The encoded form is readable and comprehensible imo. Plus this is what the EP proposed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Primarily non-blocking nits and generic comments.
// Constraint is a struct representing the new generic constraint type | ||
type Constraint struct { | ||
// Constraint message that surfaces in resolution | ||
// This field is optional | ||
Message string `json:"message" yaml:"message"` | ||
|
||
// The cel struct that contraints CEL expression | ||
// This field is required | ||
Cel *Cel `json:"cel" yaml:"cel"` | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: This was just moved to constraints.go
and is still available within the package.
…parser Signed-off-by: Eric Stroczynski <[email protected]>
b075448
to
ed76771
Compare
eb20dfd
to
cb519f1
Compare
Signed-off-by: Eric Stroczynski <[email protected]>
/approve I'm happy with the changes introduced in this PR, but I will wait for @dinhxuanvu to lgtm as he has been involved. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: awgreene, estroz The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
input: func(t *testing.T) json.RawMessage { | ||
p := make([]byte, maxConstraintSize+1) | ||
_, err := rand.Read(p) | ||
require.NoError(t, err) | ||
return json.RawMessage(p) | ||
}(t), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
/lgtm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a bit about version vs versionRange for package dependency that I need to look into but lgtm overall.
/lgtm
Follow-up on #202 for https://github.com/operator-framework/enhancements/blob/master/enhancements/compound-bundle-constraints.md
Signed-off-by: Eric Stroczynski [email protected]