mirror of https://github.com/kubernetes/kops.git
Merge pull request #8110 from vvbogdanov87/validate-cluster-kubeconfig
Add kubeconfig flag to validate cluster command
This commit is contained in:
commit
db11481e37
|
@ -48,8 +48,9 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
type ValidateClusterOptions struct {
|
type ValidateClusterOptions struct {
|
||||||
output string
|
output string
|
||||||
wait time.Duration
|
wait time.Duration
|
||||||
|
kubeconfig string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *ValidateClusterOptions) InitDefaults() {
|
func (o *ValidateClusterOptions) InitDefaults() {
|
||||||
|
@ -80,6 +81,7 @@ func NewCmdValidateCluster(f *util.Factory, out io.Writer) *cobra.Command {
|
||||||
|
|
||||||
cmd.Flags().StringVarP(&options.output, "output", "o", options.output, "Output format. One of json|yaml|table.")
|
cmd.Flags().StringVarP(&options.output, "output", "o", options.output, "Output format. One of json|yaml|table.")
|
||||||
cmd.Flags().DurationVar(&options.wait, "wait", options.wait, "If set, will wait for cluster to be ready")
|
cmd.Flags().DurationVar(&options.wait, "wait", options.wait, "If set, will wait for cluster to be ready")
|
||||||
|
cmd.Flags().StringVar(&options.kubeconfig, "kubeconfig", "", "Path to the kubeconfig file")
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
@ -126,8 +128,12 @@ func RunValidateCluster(f *util.Factory, cmd *cobra.Command, args []string, out
|
||||||
|
|
||||||
// TODO: Refactor into util.Factory
|
// TODO: Refactor into util.Factory
|
||||||
contextName := cluster.ObjectMeta.Name
|
contextName := cluster.ObjectMeta.Name
|
||||||
|
configLoadingRules := clientcmd.NewDefaultClientConfigLoadingRules()
|
||||||
|
if options.kubeconfig != "" {
|
||||||
|
configLoadingRules.ExplicitPath = options.kubeconfig
|
||||||
|
}
|
||||||
config, err := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
|
config, err := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
|
||||||
clientcmd.NewDefaultClientConfigLoadingRules(),
|
configLoadingRules,
|
||||||
&clientcmd.ConfigOverrides{CurrentContext: contextName}).ClientConfig()
|
&clientcmd.ConfigOverrides{CurrentContext: contextName}).ClientConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Cannot load kubecfg settings for %q: %v", contextName, err)
|
return nil, fmt.Errorf("Cannot load kubecfg settings for %q: %v", contextName, err)
|
||||||
|
|
|
@ -30,9 +30,10 @@ kops validate cluster [flags]
|
||||||
### Options
|
### Options
|
||||||
|
|
||||||
```
|
```
|
||||||
-h, --help help for cluster
|
-h, --help help for cluster
|
||||||
-o, --output string Output format. One of json|yaml|table. (default "table")
|
--kubeconfig string Path to the kubeconfig file
|
||||||
--wait duration If set, will wait for cluster to be ready
|
-o, --output string Output format. One of json|yaml|table. (default "table")
|
||||||
|
--wait duration If set, will wait for cluster to be ready
|
||||||
```
|
```
|
||||||
|
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
Loading…
Reference in New Issue