-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Implement setter by reflection #8896
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: justinsb 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 |
ffd3037
to
27ed901
Compare
Removing WIP, this seems to work and I wish we had this e.g. when I was testing CoreDNS! |
/test pull-kops-e2e-k8s-containerd /test pull-kops-verify-staticcheck Timeout & an old test |
/test pull-kops-e2e-k8s-containerd |
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.
Really looking forward to this. I think the pointer assignability is the only real blocker, though we should decide if we want to split on "," for string slices.
Path: "Spec.Containers[0].Policy.Name", | ||
Value: "allowed", | ||
}, | ||
// Not sure if we should do 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.
I think if it's effectively appending an element, then it's okay.
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.
It's appending an intermediate element (containers[0]
) which is what gave me pause. In this semi-fictional example, the created container is unlikely to be valid; it feels more likely to be an array indexing user-error.
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.
We insert intermediate elements when they're nil pointers, which seems analogous. If it's not valid after processing all setters then API validation will catch that.
This means we no longer have to individually hard-code the `kops set` fields, however we use the "language" we're now demonstrated. We add tests to ensure we have parity with our existing (hard-coded) setter logic.
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.
/lgtm
Path: "Spec.Containers[0].Policy.Name", | ||
Value: "allowed", | ||
}, | ||
// Not sure if we should do 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.
We insert intermediate elements when they're nil pointers, which seems analogous. If it's not valid after processing all setters then API validation will catch that.
This means we no longer have to individually hard-code the
kops set
fields, however we use the "language" we're now demonstrated.We add tests to ensure we have parity with our existing (hard-coded) setter logic.