Skip to content

Conversation

@Jan-Schuppik
Copy link
Collaborator

@Jan-Schuppik Jan-Schuppik commented Sep 4, 2024

No description provided.

@Jan-Schuppik Jan-Schuppik self-assigned this Sep 4, 2024
@cla-bot cla-bot bot added the cla/signed CLA is signed by all contributors of a PR label Sep 4, 2024
return nil
})

flag.StringVar(&contextName, "context", "", "name of the kubeconfig context to use")
Copy link
Member

@lippserd lippserd Sep 9, 2024

Choose a reason for hiding this comment

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

Is context and cluster really necessary? Doesn't clientcmd.RecommendedConfigOverrideFlags("") already provide that options?

I have something like this in my stash:

	loadingRules := clientcmd.NewDefaultClientConfigLoadingRules()
	loadingRules.DefaultClientConfig = &clientcmd.DefaultClientConfig
	overrides := clientcmd.ConfigOverrides{}
	kflags := clientcmd.RecommendedConfigOverrideFlags("")
	flag.StringVar(&loadingRules.ExplicitPath, "kubeconfig", "", "Path to a kube config. Only required if out-of-cluster")
	clientcmd.BindOverrideFlags(&overrides, flag.CommandLine, kflags)
	flag.Parse()
	clientconfig := clientcmd.NewInteractiveDeferredLoadingClientConfig(loadingRules, &overrides, os.Stdin)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You are absolutely right! I have now also completely changed to ‘pflag’ (cause BindOverrideFlags needs a *pflag.FlagSet) and adapted the version-flag so that it also works with it

@lippserd lippserd changed the title Feature/cli flags Introduce common Kubernetes config CLI flags Sep 11, 2024
@lippserd lippserd added this to the 0.2.0 milestone Sep 11, 2024
@lippserd lippserd merged commit 496d2b4 into main Sep 11, 2024
@lippserd lippserd deleted the feature/cli-flags branch September 11, 2024 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla/signed CLA is signed by all contributors of a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants