-
Notifications
You must be signed in to change notification settings - Fork 561
WIP: [CCXDEV-15259]: promote InsightConfigAPI and OnDemandDataGather to v1 #2448
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
base: master
Are you sure you want to change the base?
Conversation
Hello @opokornyy! Some important instructions when contributing to openshift/api: |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: opokornyy The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest |
/test verify-feature-promotion |
d7b46b0
to
dce787e
Compare
dce787e
to
337fbf2
Compare
config/v1/types_insights.go
Outdated
Spec InsightsDataGatherSpec `json:"spec,omitempty,omitzero"` | ||
// status holds observed values from the cluster. They may not be overridden. | ||
// +optional | ||
Status *InsightsDataGatherStatus `json:"status,omitempty,omitzero"` |
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.
Is status: {}
valid? Usually it isn't something we would expect, so this shouldn't need to be a pointer
382e32d
to
c47f3e9
Compare
Signed-off-by: Ondrej Pokorny <[email protected]>
Signed-off-by: Ondrej Pokorny <[email protected]>
Signed-off-by: Ondrej Pokorny <[email protected]>
Signed-off-by: Ondrej Pokorny <[email protected]>
// +kubebuilder:validation:XValidation:rule="self.all(x, self.exists_one(y, x == y))",message="dataPolicy items must be unique" | ||
// +listType=atomic | ||
// +optional | ||
DataPolicy []DataPolicyOption `json:"dataPolicy,omitempty"` |
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.
What does it mean for this to be dataPolicy: []
vs just omitting the dataPolicy
field? We generally prefer to avoid having more than one way to "say" the same thing.
IIUC, the current validation of allowing a length of 0 for this means that unstructured clients can set dataPolicy: []
but is not something that structured clients would ever be able to set because of the omitempty
.
We should make sure that unstructured and structured clients behave the same here.
IIRC, that means:
- IF
dataPolicy: []
is semantically different than omission of the field, swap theomitempty
toomitzero
(allows marshalling of the[]
but notnull
values) - ELSE make
MinItems
validation to be1
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.
Double checked with @JoelSpeed and am making a correction to:
IF dataPolicy: [] is semantically different than omission of the field, swap the omitempty to omitzero (allows marshalling of the [] but not null values)
This should actually be making the type *[]DataPolicyOption
and keeping the omitempty
because that sets us up for more idiomatic Go nil
checking behavior where this field is actually referenced.
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.
With that I am running into the linting error:
optionalfields: field DataPolicy does not allow the zero value. The field does not need to be a pointer. (kubeapilinter)
DataPolicy *[]DataPolicyOption `json:"dataPolicy,omitempty"`
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.
Did you also change the MinItems
validation? I'd expect a change to only one or the other.
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.
What does it mean for this to be dataPolicy: [] vs just omitting the dataPolicy field? We generally prefer to avoid having more than one way to "say" the same thing.
This is the important part of the conversation to answer first, and it drives the other decisions.
I believe the answer is that dataPolicy: []
is semantically equivalent to being omitted.
In which case, we would say that we don't want to allow dataPolicy: []
to be persisted as a valid value.
In which case, it should have a non-zero +kubebuilder:validation:MinProperties
, which will then force the list to be []T
not *[]T
.
The ordering of answering the questions influences the correct end result.
@opokornyy are you in agreement that the following is true?
`dataPolicy: []` is semantically equivalent to being omitted.
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.
Agree, I have set the // +kubebuilder:validation:MinItems=1
for dataPolicy and now it does not require to use a pointer.
Signed-off-by: Ondrej Pokorny <[email protected]>
c47f3e9
to
d29ee57
Compare
@opokornyy: The following tests failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
No description provided.