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

APICLI-528: adding option to pick context name in 'kubeconfig save' #1075

Merged
merged 4 commits into from
Dec 27, 2021

Conversation

danaelhe
Copy link
Member

@danaelhe danaelhe commented Dec 20, 2021

per #856- adding the option to add an alias for a kubernetes context, as such:
go run cmd/doctl/main.go kubernetes cluster kubeconfig save k8ds-test --alias=newalias_k8ds

@danaelhe
Copy link
Member Author

danaelhe commented Dec 20, 2021

Though the tests runs successfully, I have a mild concern when testing out the command via the cli. I run the command:
go run cmd/doctl/main.go kubernetes cluster kubeconfig save k8ds-test --alias=newalias_k8ds
and get the expected response:

Notice: Adding cluster credentials to kubeconfig file found in "/Users/myuser/.kube/config"
Notice: Setting current-context to newalias_k8ds

I check the "current_context" in the kubeconfig in "/Users/myuser/.kube/config" and get the expected value of the alias, "newalias_k8ds":

xxx@xxx doctl % cat /Users/myuser/.kube/config
apiVersion: v1
clusters:
- cluster:
    server: https://xxxx.k8s.ondigitalocean.com
  name: do-nyc1-k8s-1-00-2-do-0-nyc1-1xxx
- context:
    cluster: do-nyc1-k8ds-test
    user: do-nyc1-k8ds-test-admin
  name: newalias_k8ds
current-context: newalias_k8ds
kind: Config

but when I run the doctl command:
go run cmd/doctl/main.go kubernetes cluster kubeconfig show k8ds-test
it appears the current_context value is the old current_context of "current-context: do-nyc1-k8ds-test", instead of the alias "newalias_k8ds"

I'm wondering if there's just a slight lag or if this will be problematic later?

@danaelhe danaelhe changed the title adding option to pick context name in 'kubeconfig save' APICLI-528: adding option to pick context name in 'kubeconfig save' Dec 20, 2021
Copy link
Contributor

@ChiefMateStarbuck ChiefMateStarbuck left a comment

Choose a reason for hiding this comment

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

Looking Great!

args.go Outdated Show resolved Hide resolved
@andrewsomething
Copy link
Member

but when I run the doctl command:
go run cmd/doctl/main.go kubernetes cluster kubeconfig show k8ds-test
it appears the current_context value is the old current_context of "current-context: do-nyc1-k8ds-test", instead of the alias "newalias_k8ds"

This change only effects the the local file written to disk by the save command. The show command downloads a new kubeconfig file from the API. So this won't be reflected there.

Copy link
Member

@andrewsomething andrewsomething left a comment

Choose a reason for hiding this comment

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

👍 Looks great. A couple small suggestions inline.

commands/kubernetes.go Outdated Show resolved Hide resolved
@guardrails
Copy link

guardrails bot commented Dec 20, 2021

⚠️ We detected 1 security issue in this pull request:

Insecure Use of Dangerous Function (1)
Docs Details
💡 Title: Review use of exec.Command(), Severity: High

More info on how to fix Insecure Use of Dangerous Function in Go.


👉 Go to the dashboard for detailed results.

📥 Happy? Share your feedback with us.

Copy link
Contributor

@ChiefMateStarbuck ChiefMateStarbuck left a comment

Choose a reason for hiding this comment

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

Good to merge on green guardrailscan. great work Dana

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.

None yet

3 participants