mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-19 18:02:01 +00:00
kubeadm: modify '--config' flag from required to optional for 'kubeadm kubeconfig user'
This commit is contained in:
parent
0e077bb7ac
commit
70b33409de
@ -20,7 +20,6 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
@ -43,6 +42,9 @@ var (
|
|||||||
`)
|
`)
|
||||||
|
|
||||||
userKubeconfigExample = cmdutil.Examples(`
|
userKubeconfigExample = cmdutil.Examples(`
|
||||||
|
# Output a kubeconfig file for an additional user named foo
|
||||||
|
kubeadm kubeconfig user --client-name=foo
|
||||||
|
|
||||||
# Output a kubeconfig file for an additional user named foo using a kubeadm config file bar
|
# Output a kubeconfig file for an additional user named foo using a kubeadm config file bar
|
||||||
kubeadm kubeconfig user --client-name=foo --config=bar
|
kubeadm kubeconfig user --client-name=foo --config=bar
|
||||||
`)
|
`)
|
||||||
@ -79,9 +81,6 @@ func newCmdUserKubeConfig(out io.Writer) *cobra.Command {
|
|||||||
Long: userKubeconfigLongDesc,
|
Long: userKubeconfigLongDesc,
|
||||||
Example: userKubeconfigExample,
|
Example: userKubeconfigExample,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
if len(cfgPath) == 0 {
|
|
||||||
return errors.New("the kubeadm configuration path cannot be empty")
|
|
||||||
}
|
|
||||||
// This call returns the ready-to-use configuration based on the defaults populated by flags
|
// This call returns the ready-to-use configuration based on the defaults populated by flags
|
||||||
internalCfg, err := configutil.LoadOrDefaultInitConfiguration(cfgPath, initCfg, clusterCfg)
|
internalCfg, err := configutil.LoadOrDefaultInitConfiguration(cfgPath, initCfg, clusterCfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -114,7 +113,6 @@ func newCmdUserKubeConfig(out io.Writer) *cobra.Command {
|
|||||||
cmd.Flags().StringSliceVar(&organizations, "org", organizations, "The organizations of the client certificate. It will be used as the O if client certificates are created")
|
cmd.Flags().StringSliceVar(&organizations, "org", organizations, "The organizations of the client certificate. It will be used as the O if client certificates are created")
|
||||||
cmd.Flags().DurationVar(&validityPeriod, "validity-period", kubeadmconstants.CertificateValidity, "The validity period of the client certificate. It is an offset from the current time.")
|
cmd.Flags().DurationVar(&validityPeriod, "validity-period", kubeadmconstants.CertificateValidity, "The validity period of the client certificate. It is an offset from the current time.")
|
||||||
|
|
||||||
cmd.MarkFlagRequired(options.CfgPath)
|
|
||||||
cmd.MarkFlagRequired("client-name")
|
cmd.MarkFlagRequired("client-name")
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user