-
Notifications
You must be signed in to change notification settings - Fork 52
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
Iflib newKO #122
Iflib newKO #122
Conversation
My comment for the IPAllocation resource lib, also applies here: |
Please see my comments on #121 which is base for others. I beleive if we take that path implementation of these individual libraries will be simpler. |
Thanks @kispaljr . Yes a rebase with main needed . In addition as discussed this PR will change in many ways and be simpler as we discussed. This will only have methods directly implemented on |
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.
Thanks @henderiw . I was hoping we will avoid all "Newfromxxx "methods in this file. Basically instead of creating a new structure, add the interface specific methods directly on KubeObjectEx created in the base parser( few get/set/deletes). Then the usage pattern would be callers first create the object using the base parser and call respective methods based on which function they are implementing. That way these libraries will be simpler. What do you think?
Specifically only these methods
GetAttachmentType
GetCNIType
GetNetworkInstanceName
SetAttachmentType
SetCNIType
SetNetworkInstanceName
SetSpec
DeleteAttachmentType
DeleteCNIType
(Updating comment)
I understand the approach you've taken is cleaner than what I am suggesting as the methods will be scoped to a particular structure and is very definitive. I am thinking since we are on both sides of the library (library consumers and library implementors) probably it's okay to have library methods on the base structure (no interface). Love to hear your thoughts.
It's more idiomatic in Go to avoid field setters and getters. So IMO, methods to create from YAML or Go struct, and to convert to Go struct, and to set via Go struct are all we need, as described here: #123 (review) |
Aligned the interface lib with the new setSpec library in kubeobject |
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.
Thanks @henderiw . I am on the fence if we really need this with all the changes we made to the base KubeObjectExt. Added a couple of comments.
I think the tests for SetSpec and SetStatus are useful. Even if we decide to do away from this library, I suggest we keep the tests by moving them to the base KubeObjectExt .
cniType = []string{"spec", "cniType"} | ||
networkInstanceName = []string{"spec", "networkInstance", "name"} | ||
) | ||
type Interface 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.
Is there a need to create this structure? Can the functions developers just directly create the base KubeObjectExt structure? All the methods are used from there anyway.
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.
The value is you get explicit type checking for the object and we need this in several libraries. This is the reason to do this. otherwise people need to implement this in each function independently again and again.
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 I did not do so far is have the explicit SeptSpec and SetStatus with their specific type, so this would add even more type awareness.
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.
the way to look at this is a the specific KubeObj extensions for the InterfaceReq CRD
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.
/approve
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: gvbalaji, henderiw 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 |
If I understand correctly, the main reason to have this wrapper at all, is the lack of static type checking in the |
/lgtm |
aligned the interface with the new parser implementation
added setters using the real types as this eases validation.