-
Couldn't load subscription status.
- Fork 68
[resolution pt.4] crd uniqueness constraints variable source #98
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
[resolution pt.4] crd uniqueness constraints variable source #98
Conversation
35a3f8f to
afe1b58
Compare
| // get bundleID package and update map | ||
| packageName, err := bundleEntity.PackageName() | ||
| if err != nil { | ||
| return nil, fmt.Errorf("error creating global constraints: %s", err) |
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.
wrap err via %w, here and below
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.
I've done a project search and hopefully addressed all of them (I'll check the next branches too)
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.
Odd... this is still showing up as %s?
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.
Other than this, looks fine.
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.
I see this too.
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.
hmmmm - maybe I screwed something up - hold on (sorry for this!)
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.
fixed
afe1b58 to
859ac6e
Compare
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.
Great work @perdasilva, I had one question regarding the returned variables, but this looks good otherwise.
| func NewGlobalConstraintsVariable(id deppy.Identifier, atMostIDs ...deppy.Identifier) *GlobalConstraintsVariable { | ||
| return &GlobalConstraintsVariable{ | ||
| SimpleVariable: input.NewSimpleVariable(id, constraint.AtMost(1, atMostIDs...)), | ||
| } | ||
| } |
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.
I'm not sure that I would infer that theNewGlobalConstraintsVariable function name implies that a single entity will be selected. Could you explain why it can be infered or add a comment or change the name?
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.
Yeah, that's fair. Let me see if I can find a better name. I think I've been using global constraints for so long I just assumed it was a thing =P
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.
I've tried to refactor to a different name - hopefully it will be more descriptive
| ctx = context.Background() | ||
|
|
||
| // the entity is not used in this variable source | ||
| entitySource = &PanicEntitySource{} |
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.
For sake of clarification, the NewGlobalConstraintsVariableSource shouldn't reach out to the entity source because it's used to enforce GVK and Package uniqueness, which is effectively hardcoded in OLM, right?
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.
great call
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.
yup - that's right - but it still needs to pass it to its inputVariableSource (and that one could use it)
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.
Right, makes sense.
| property.TypeGVKRequired: `[{"group":"foo.io","kind":"Foo","version":"v1"}]`, | ||
| property.TypeGVK: `[{"group":"bit.io","kind":"Bit","version":"v1"}]`, | ||
| }), | ||
| "bundle-2": input.NewEntity("bundle-2", map[string]string{ |
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.
Oddly enough we jumped over "bundle-3".
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.
yeah - fixed it =D
| } | ||
| variables, err := globalConstraintVariableSource.GetVariables(ctx, entitySource) | ||
| Expect(err).ToNot(HaveOccurred()) | ||
| Expect(len(variables)).To(Equal(26)) |
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.
How do we land on 26 variables? I counted 16 bundles defined in the bundleSet and I see that we have 11 globalConstraintVariables below, which adds up to 27.
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.
And I keep getting a different count‽‽
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.
oh oh
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.
ah ok - so, it receives 15 variables upstream from it and produces another 11. It seems to be correct.
Basically, you have the required package variables, the bundle variables, and it spits out the uniqueness variables.
859ac6e to
9ab3a4c
Compare
Signed-off-by: perdasilva <perdasilva@redhat.com>
9ab3a4c to
25465b9
Compare
|
@perdasilva I'm happy with the existing changes. |
Signed-off-by: Mikalai Radchuk <mradchuk@redhat.com>
This PR adds the
Global Constraintsvariable source. It groups allBundleVariablesby their underlying entity'spackageandprovided gvksand emitsGlobalConstraintsVariablesthat constrain the solution to only have one bundle for any given package and one bundle for any given provided gvk.