-
Notifications
You must be signed in to change notification settings - Fork 217
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
Add condition helpers to Multi-Network API. #526
Conversation
e4551bd
to
e80dc36
Compare
/cc @mrthinger |
@mskrocki: GitHub didn't allow me to request PR reviews from the following users: mrthinger. Note that only kubernetes members and repo collaborators can review this PR, and authors cannot review their own PRs. In response to this:
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/test-infra repository. |
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.
Could this be a method on the structs instead?
I don't think branching on type is a great way of implementing this, but this obviously works fine.
I just was inclined to avoid that #526 (comment), adding methods to the struct will add a dependency on the object that is versioned, and the function is agnostic of that, per example, you can use this function with existing version, but in order to use the method you have to update your dependency first |
LGTM I do not know if you prefer to use generics, cast interfaces or one function per object, but I have doubts on the method per object approach per #526 (comment), but I may be wrong too |
@mskrocki: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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/test-infra repository. I understand the commands that are listed here. |
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. The conditions function will be scoped to the network package anyway, so discoverability and maintainability shouldn't be an issue.
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
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: MrHohn, mrthinger, mskrocki 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 |
|
||
// GetCondition returns the "condType" condition from the obj. Only Network and | ||
// GKENetworkParamSet types are supported. Returns nil when not found. | ||
func GetCondition(obj interface{}, condType string) (*metav1.Condition, 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.
suggestion
create a struct that wraps metav1.Condition that implements the specific CRUD for conditions that we care about. Might be cleaner for users than one-off functions.
func NewConditionCRUD(c*metav1.Condition) ...
type ConditionCRUD struct { ... }
crud := NewConditionCRUD(obj.Status.Conditions)
if crud.Ready() { ...
}
crud.SetReady(false, "it's not ready")
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.
As I were looking into this I found https://github.com/kubernetes/apimachinery/blob/master/pkg/api/meta/conditions.go which has all the required functions, will close this PR.
/hold |
No description provided.