Skip to content
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

VLAN alloc with new KO #140

Merged
merged 3 commits into from
Apr 30, 2023
Merged

Conversation

henderiw
Copy link
Contributor

this PR implements the VLAN Allocation library with the new KubeObject aligned with SetSpec/SetStatus

@henderiw henderiw changed the title Alan alloc with new KO VLAN alloc with new KO Apr 28, 2023
Copy link

@gvbalaji gvbalaji left a 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 .

vlanv1alpha1 "github.com/nokia/k8s-ipam/apis/alloc/vlan/v1alpha1"
)

type VLANAllocation struct {

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.

Copy link
Contributor Author

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.


// NewFromKubeObject creates a new KubeObjectExt
// It expects a *fn.KubeObject as input representing the serialized yaml file
func NewFromKubeObject(o *fn.KubeObject) (*VLANAllocation, error) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the same spirit as above comment, show we just return the base KubeObjectExt from here?
In fact I am also thinking can the function devs directly invoke kubeobject.NewFromKubeObject*vlanv1alpha1.VLANAllocation?

That could mean do we really need this library for indirection?

Copy link
Contributor Author

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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @henderiw . Approved.

Copy link

@gvbalaji gvbalaji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

@henderiw
Copy link
Contributor Author

/approve

@nephio-prow
Copy link
Contributor

nephio-prow bot commented Apr 28, 2023

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@nephio-prow nephio-prow bot added the approved label Apr 28, 2023
import (
"github.com/GoogleContainerTools/kpt-functions-sdk/go/fn"
"github.com/nephio-project/nephio/krm-functions/lib/kubeobject"
vlanv1alpha1 "github.com/nokia/k8s-ipam/apis/alloc/vlan/v1alpha1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious, will this always be in the nokia repo?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no this is to be merged. But this is the workaround for now. So next week we start bringing this into nephio.

@kispaljr
Copy link
Contributor

kispaljr commented Apr 28, 2023

If I understand correctly, the main reason to have this wrapper at all, is the lack of static type checking in the interface{} type parameter of SetSpec and SetStatus. I agree that this is a valid concern, however I suggest to use the power of Go generics to fix this, as opposed to implementing it one-by-one for each type (avoiding this is the main reason for having generics).
Here is my proposal to add static type checking: #141

@ganchandrasekaran
Copy link
Contributor

/lgtm

@nephio-prow nephio-prow bot added the lgtm label Apr 30, 2023
@nephio-prow nephio-prow bot merged commit 3732ae4 into nephio-project:main Apr 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants