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

Consolidate create/switch/update context with --connect #2112

Merged
merged 3 commits into from
Sep 16, 2024

Conversation

johannesfrey
Copy link
Contributor

What issue type does this pull request address? (keep at least one, remove the others)
/kind enhancement

What does this pull request do? Which issues does it resolve? (use resolves #<issue_number> if possible)
resolves #

Please provide a short message that should be published in the vcluster release notes
Fixed an issue where vcluster ...

What else do we need to know?

Copy link

netlify bot commented Sep 4, 2024

Deploy Preview for vcluster-docs canceled.

Name Link
🔨 Latest commit 111dcde
🔍 Latest deploy log https://app.netlify.com/sites/vcluster-docs/deploys/66deb13e02625e000876c9b1

Copy link
Member

@FabianKramm FabianKramm left a comment

Choose a reason for hiding this comment

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

@johannesfrey looks good to me, but I'm a little scared to remove the update-current flag, since it is referenced a lot. Can we basically just remove the functionality of it, but still have it as a hidden flag that is deprecated?

@@ -164,7 +164,7 @@ func CreatePlatform(ctx context.Context, options *CreateOptions, globalFlags *fl
// check if we should connect to the vcluster or print the kubeconfig
if options.Connect || options.Print {
return ConnectPlatform(ctx, &ConnectOptions{
UpdateCurrent: options.UpdateCurrent,
UpdateCurrent: true,
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 ConnectPlatform and UpdateKubeconfig above duplicate some of the connection functionality

Copy link
Contributor

Choose a reason for hiding this comment

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

The ConnectPlatform() function ends with a writkubeconfig() function

Copy link
Contributor Author

@johannesfrey johannesfrey Sep 6, 2024

Choose a reason for hiding this comment

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

Good point. I checked the code and it looks like ConnectPlatform does call platform.CreateVirtualClusterInstanceOptions internally, so essentially doing the same as the block L148-L162 you mentioned above. I went ahead and removed this block and checked create in the different combinations (--connect=true, --connect=false, --connect=false --print=true once without a platform and once with being logged into the platform). Looks good so far.

@@ -145,9 +145,9 @@ func CreatePlatform(ctx context.Context, options *CreateOptions, globalFlags *fl
}
log.Donef("Successfully created the virtual cluster %s in project %s", virtualClusterName, options.Project)

if options.CreateContext {
if options.Connect {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if this block could just be removed

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 removed it. See the comment above.

Copy link
Contributor

@rohantmp rohantmp left a comment

Choose a reason for hiding this comment

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

LGTM :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants