-
Notifications
You must be signed in to change notification settings - Fork 260
feat: nnc client sets ownerref #1133
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
Conversation
crd/nodenetworkconfig/client.go
Outdated
| _ = v1alpha.AddToScheme(Scheme) | ||
| } | ||
|
|
||
| type OwnerExistsError struct{} |
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.
can we flip this around to ErrOwnerExists? seems more canonical (https://go.dev/src/os/error.go) even though k/k likes to do "ThingError"
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.
if we still need it instead of using ctrlutil's similar defined 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.
removed, caller can rely on ctrlutil's error with errors.Is/As since we just wrap it
|
|
||
| // SetOwnerRef sets the owner of the NodeNetworkConfig to the given object, using HTTP Patch | ||
| func (c *Client) SetOwnerRef(ctx context.Context, nnc *v1alpha.NodeNetworkConfig, owner metav1.Object) error { | ||
| newNNC := nnc.DeepCopy() |
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 we should either return the newNNC or mutate the passed nnc, since the patch call will write the resultant object to the ref it gets passed.
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.
good point, I'll change that
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.
decided to return instead of mutate since the nnccli.Patch() could fail and we don't want to mutate the caller if we dn't actually make a successful change
crd/nodenetworkconfig/client.go
Outdated
| // SetControllerReference returns an error if the object already has a different owner or | ||
| // if there are issues with the scheme. Since we control the scheme in this package, we can safely | ||
| // assume than any error is caused by an owner already existing | ||
| return &OwnerExistsError{} |
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.
why not lean on ctrlutil's AlreadyOwnedError?
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.
because I didn't read the docs and didn't know it existed 😆
rbtr
left a comment
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
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Reason for Change:
Adds SetOwnerRef to nnc client which sets the NNC ownership to the given object
Requirements: