Skip to content

Commit fc13ee2

Browse files
committed
enable clusters package to add --kubeconfig flag
1 parent 67ad75f commit fc13ee2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pkg/clusters/cluster.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ func (c *Cluster) WithRESTConfig(cfg *rest.Config) *Cluster {
6161
}
6262

6363
// RegisterConfigPathFlag adds a flag '--<id>-cluster' for the cluster's config path to the given flag set.
64+
// If only a single kubeconfig is required, RegisterSingleConfigPathFlag can be used instead to have the flag named '--kubeconfig'.
6465
// Panics if the cluster's id is not set.
6566
func (c *Cluster) RegisterConfigPathFlag(flags *flag.FlagSet) {
6667
if !c.HasID() {
@@ -69,6 +70,12 @@ func (c *Cluster) RegisterConfigPathFlag(flags *flag.FlagSet) {
6970
flags.StringVar(&c.cfgPath, fmt.Sprintf("%s-cluster", c.id), "", fmt.Sprintf("Path to the %s cluster kubeconfig file or directory containing either a kubeconfig or host, token, and ca file. Leave empty to use in-cluster config.", c.id))
7071
}
7172

73+
// RegisterSingleConfigPathFlag adds a '--kubeconfig' flag for the cluster's config path to the given flag set.
74+
// If more than one kubeconfig is required, consider using RegisterConfigPathFlag instead, which is identical, but names the flag '--<id>-cluster'.
75+
func (c *Cluster) RegisterSingleConfigPathFlag(flags *flag.FlagSet) {
76+
flags.StringVar(&c.cfgPath, "kubeconfig", "", "Path to the kubeconfig file or directory containing either a kubeconfig or host, token, and ca file. Leave empty to use in-cluster config.")
77+
}
78+
7279
// WithClientOptions allows to overwrite the default client options.
7380
// It must be called before InitializeClient().
7481
// Note that using this method disables the the scheme injection during client initialization.

0 commit comments

Comments
 (0)