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

Adds a kubecontext global flag #296

Merged
merged 1 commit into from
Feb 26, 2018

Conversation

blakebarnett
Copy link
Contributor

@blakebarnett blakebarnett commented Feb 3, 2018

Fixes #207

f.flags.StringVarP(&f.namespace, "namespace", "n", f.namespace, "The namespace in which Ark should operate")
f.flags.StringVar(&f.kubecontext, "kubecontext", "", "The context to use to talk to the Kubernetes apiserver. If unset defaults to whatever your current-context is (kubectl config current-context)")
Copy link
Contributor

Choose a reason for hiding this comment

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

@Bradamant3 pls review the text here

f.flags.StringVarP(&f.namespace, "namespace", "n", f.namespace, "The namespace in which Ark should operate")
f.flags.StringVar(&f.kubecontext, "kubecontext", "", "The context to use to talk to the Kubernetes apiserver. If unset defaults to whatever your current-context is (kubectl config current-context)")
f.flags.StringVar(&f.kubeconfig, "kubeconfig", "", "Path to the kubeconfig file to use to talk to the Kubernetes apiserver. If unset, try the environment variable KUBECONFIG, as well as in-cluster configuration")
Copy link
Contributor

Choose a reason for hiding this comment

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

@blakebarnett any particular reason you moved this down?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nope, I must have done that when I rebased, will fix.

func Config(kubeconfig, kubecontext, baseName string) (*rest.Config, error) {
loadingRules := clientcmd.NewDefaultClientConfigLoadingRules()
loadingRules.ExplicitPath = kubeconfig
configOverrides := &clientcmd.ConfigOverrides{}
Copy link
Contributor

Choose a reason for hiding this comment

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

Since you're only setting 1 field in here, how about this?

configOverrides := &clientcmd.ConfigOverrides{CurrentContext: kubecontext}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@ncdc
Copy link
Contributor

ncdc commented Feb 3, 2018

@blakebarnett thanks for the PR! Would you please sign your commit, and also run gofmt on the files you changed? Thanks!

@ncdc ncdc self-assigned this Feb 3, 2018
@blakebarnett blakebarnett force-pushed the bdb/add_kubecontext_flag branch from 0147b73 to 8172d24 Compare February 3, 2018 23:29
@blakebarnett
Copy link
Contributor Author

Ah I see, I need to actually update the docs to include, I'll take care of that in the next commit.

@ncdc
Copy link
Contributor

ncdc commented Feb 5, 2018

@blakebarnett looking pretty good! Just run make update to update everything (docs).

@@ -68,6 +69,7 @@ func NewFactory(baseName string) Factory {

f.flags.StringVar(&f.kubeconfig, "kubeconfig", "", "Path to the kubeconfig file to use to talk to the Kubernetes apiserver. If unset, try the environment variable KUBECONFIG, as well as in-cluster configuration")
Copy link
Contributor

Choose a reason for hiding this comment

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

This part of the message isn't clear:
"If unset, try the environment variable KUBECONFIG, as well as in-cluster configuration"
Are these meant to be alternatives to setting the path? Do you need both? Is either of them the default if not set? Or would you have to try one or the other for the command to succeed? In other words, does not specifying result in an error condition?
Or does the command look for a KUBECONFIG environment variable, and if not found then look for the path in the cluster config?
If it's the latter, the fix is fairly simple:
"If unset, tries the environment variable KUBECONFIG, and if not present, tries in-cluster configuration"
If not the latter, questions ^^ might help with clearer text.

Copy link
Contributor

Choose a reason for hiding this comment

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

@Bradamant3 we can address the kubeconfig text in another issue. This PR is about kubecontext 😄

@ncdc
Copy link
Contributor

ncdc commented Feb 12, 2018

@blakebarnett FYI, we'll pick this up as soon as master is open for v0.8.0 later this week. Thanks for your patience!

@ncdc
Copy link
Contributor

ncdc commented Feb 26, 2018

@blakebarnett we'd like to get this in sometime soon. Could you please squash & sign your commit?

@blakebarnett
Copy link
Contributor Author

I signed it, I thought GH would auto-squash on merge?

@ncdc
Copy link
Contributor

ncdc commented Feb 26, 2018

You currently have 4 commits, and each one must have the DCO stanza in it. I don't see it in any of them?

@blakebarnett blakebarnett force-pushed the bdb/add_kubecontext_flag branch from 4153f5f to a2b6075 Compare February 26, 2018 18:46
Signed-off-by: Blake <blake.barnett@postmates.com>
@blakebarnett blakebarnett force-pushed the bdb/add_kubecontext_flag branch from a2b6075 to 465c60b Compare February 26, 2018 18:47
@blakebarnett
Copy link
Contributor Author

blakebarnett commented Feb 26, 2018

sorry, never used GH's signing stuff, I think that's done it?

@ncdc
Copy link
Contributor

ncdc commented Feb 26, 2018

DCO is good, thanks!

@ncdc ncdc assigned nrb Feb 26, 2018
@nrb
Copy link
Contributor

nrb commented Feb 26, 2018

Tested this, can confirm that it works as described.

@nrb nrb merged commit e73ba83 into vmware-tanzu:master Feb 26, 2018
@bryanlarsen
Copy link

Ugh, helm uses --kube-context, kubectl uses --context and now ark uses --kubecontext. I'm probably going to get it wrong every single time.

@ncdc
Copy link
Contributor

ncdc commented Apr 23, 2018

We could probably support both --kubecontext and --kube-context. I think --context is potentially too generic for Ark, though.

@blakebarnett
Copy link
Contributor Author

Yeah, I did it this way because it already had --kubeconfig but I'd prefer if it matched helm also.

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.

5 participants