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

Update tanzu context APIs to support ClusterGroup #142

Merged
merged 4 commits into from
Dec 26, 2023

Conversation

anujc25
Copy link
Contributor

@anujc25 anujc25 commented Dec 20, 2023

What this PR does / why we need it

  • Updates tanzu context APIs to support ClusterGroup
  • Updates the GetKubeconfigForContext to make it more generalized. Users can pass resource options as opts argument.
- func GetKubeconfigForContext(contextName, projectName, spaceName string) ([]byte, error) {
+ func GetKubeconfigForContext(contextName string, opts ...ResourceOptions) ([]byte, error) {

Example usage of GetKubeconfigForContext:

GetKubeconfigForContext("context-name-1", ForProject("test-project"))
GetKubeconfigForContext("context-name-1", ForProject("test-project"), ForClusterGroup("clustergroup1"))
GetKubeconfigForContext("context-name-1", ForProject("test-project"), ForSpace("space1"))
  • Updates the SetTanzuContextActiveResource to make it more generalized that now takes the resourceInfo object.
- func SetTanzuContextActiveResource(contextName, projectName, spaceName string, opts ...CommandOptions) error {
+ func SetTanzuContextActiveResource(contextName string, resourceInfo ResourceInfo, opts ...CommandOptions) error {

Example usage of SetTanzuContextActiveResource:

SetTanzuContextActiveResource("test-context", ResourceInfo{ProjectName: "projectA", SpaceName: "spaceA"})
SetTanzuContextActiveResource("test-context", ResourceInfo{ProjectName: "projectA", ClusterGroupName: "clustergroupB"})

Which issue(s) this PR fixes

Fixes #143

Describe testing done for PR

Release note

Add support for `clustergroup` for the `tanzu` context. This updates the API signature for the `GetKubeconfigForContext` and the `SetTanzuContextActiveResource`

Additional information

Special notes for your reviewer

@anujc25 anujc25 requested a review from a team as a code owner December 20, 2023 14:27
@anujc25 anujc25 force-pushed the api-to-support-clustergroups branch from 48120d8 to 5d84d5c Compare December 20, 2023 15:05
// ex: kubeconfig's cluster.server URL: https://endpoint/org/orgid/project/<projectName>/space/<spaceName>
func GetKubeconfigForContext(contextName, projectName, spaceName string) ([]byte, error) {
// Note: Specifying `spaceName` and `clusterGroupName` both at the same time is incorrect input.
func GetKubeconfigForContext(contextName string, opts ...ResourceOptions) ([]byte, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function only supports getting kubeconfig for the tanzu context-type and no other context type.

Should we consider renaming this function to be more specific like GetKubeconfigForTanzuContext?
Or
Should we consider supporting the kubernetes context-type and make this API more generic? cc @prkalle @vuil @marckhouzam

Copy link
Contributor

Choose a reason for hiding this comment

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

Does renaming cause a backwards compatibility problem?

Copy link
Contributor

@prkalle prkalle Dec 20, 2023

Choose a reason for hiding this comment

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

Initially these methods were under tae package and it was not an issue as user has to call them as tae.GetKubeconfigForContext, but later due to renaming the context type to tanzu and re-organizing them under config package, it is causing confusion. So, i feel it is good to rename to avoid confusion. I believe these changes are breaking ( I see SetTanzuContextActiveResource()signature also changed), so we can use this oppurtunity if possible (there should be only 2 affected plugins project and space).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback @prkalle and @marckhouzam.

Does renaming cause a backwards compatibility problem?

I think all the APIs related to the tanzu context are experimental APIs and we should be able to make changes to the API at the moment. Also, my existing changes do update the API signature as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will keep this thread open to get feedback from @vuil as well. However, I am not planning to do this rename as part of this PR. If we decide, I will create follow-up PR for the rename.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the idea of supporting the kubernetes context-type is interesting.
I'm not sure if it would be easy.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest keeping the name look into add suport the kubernetes context-type in a followup, since the usecase for wanting to use this API for tanzu context is not that different from when context type is kubernetes. I also think it should be quite straightfoward to add this support.

@anujc25 anujc25 force-pushed the api-to-support-clustergroups branch from fb79f95 to 450decc Compare December 20, 2023 16:23
@prkalle prkalle self-requested a review December 21, 2023 00:16
Copy link
Contributor

@prkalle prkalle left a comment

Choose a reason for hiding this comment

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

The changes LGTM.
I would wait for others opinions regarding the discussion regarding renaming the method name GetKubeconfigForContext().

@anujc25
Copy link
Contributor Author

anujc25 commented Dec 21, 2023

I would wait for others opinions regarding the discussion regarding renaming the method name GetKubeconfigForContext().

I am not planning to do any method name change as part of this PR. If we decide, I can create a follow-up PR to rename the method.

Copy link
Contributor

@marckhouzam marckhouzam left a comment

Choose a reason for hiding this comment

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

LGTM
One nit about adding a extra test.

config/tanzu_context.go Show resolved Hide resolved
// ex: kubeconfig's cluster.server URL: https://endpoint/org/orgid/project/<projectName>/space/<spaceName>
func GetKubeconfigForContext(contextName, projectName, spaceName string) ([]byte, error) {
// Note: Specifying `spaceName` and `clusterGroupName` both at the same time is incorrect input.
func GetKubeconfigForContext(contextName string, opts ...ResourceOptions) ([]byte, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the idea of supporting the kubernetes context-type is interesting.
I'm not sure if it would be easy.

config/tanzu_context_test.go Show resolved Hide resolved
@anujc25 anujc25 merged commit ad86606 into vmware-tanzu:main Dec 26, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-not-required docs-impact issues with documentation impact kind/feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update plugin runtime APIs to account for clustergroup support
5 participants