mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-10-31 10:18:13 +00:00 
			
		
		
		
	Make "BoolFlag" booleans not require =true
This commit is contained in:
		| @@ -64,8 +64,8 @@ $ kubectl config set-cluster e2e --insecure-skip-tls-verify=true | ||||
| ``` | ||||
|       --api-version="": api-version for the cluster entry in kubeconfig | ||||
|       --certificate-authority="": path to certificate-authority for the cluster entry in kubeconfig | ||||
|       --embed-certs=false: embed-certs for the cluster entry in kubeconfig | ||||
|       --insecure-skip-tls-verify=false: insecure-skip-tls-verify for the cluster entry in kubeconfig | ||||
|       --embed-certs[=false]: embed-certs for the cluster entry in kubeconfig | ||||
|       --insecure-skip-tls-verify[=false]: insecure-skip-tls-verify for the cluster entry in kubeconfig | ||||
|       --server="": server for the cluster entry in kubeconfig | ||||
| ``` | ||||
|  | ||||
| @@ -97,7 +97,7 @@ $ kubectl config set-cluster e2e --insecure-skip-tls-verify=true | ||||
|  | ||||
| * [kubectl config](kubectl_config.md)	 - config modifies kubeconfig files | ||||
|  | ||||
| ###### Auto generated by spf13/cobra on 8-Dec-2015 | ||||
| ###### Auto generated by spf13/cobra on 8-Jan-2016 | ||||
|  | ||||
| <!-- BEGIN MUNGE: GENERATED_ANALYTICS --> | ||||
| []() | ||||
|   | ||||
| @@ -77,7 +77,7 @@ $ kubectl config set-credentials cluster-admin --client-certificate=~/.kube/admi | ||||
| ``` | ||||
|       --client-certificate="": path to client-certificate for the user entry in kubeconfig | ||||
|       --client-key="": path to client-key for the user entry in kubeconfig | ||||
|       --embed-certs=false: embed client cert/key for the user entry in kubeconfig | ||||
|       --embed-certs[=false]: embed client cert/key for the user entry in kubeconfig | ||||
|       --password="": password for the user entry in kubeconfig | ||||
|       --token="": token for the user entry in kubeconfig | ||||
|       --username="": username for the user entry in kubeconfig | ||||
| @@ -110,7 +110,7 @@ $ kubectl config set-credentials cluster-admin --client-certificate=~/.kube/admi | ||||
|  | ||||
| * [kubectl config](kubectl_config.md)	 - config modifies kubeconfig files | ||||
|  | ||||
| ###### Auto generated by spf13/cobra on 8-Dec-2015 | ||||
| ###### Auto generated by spf13/cobra on 8-Jan-2016 | ||||
|  | ||||
| <!-- BEGIN MUNGE: GENERATED_ANALYTICS --> | ||||
| []() | ||||
|   | ||||
| @@ -61,7 +61,7 @@ $ kubectl config view -o template --template='{{range .users}}{{ if eq .name "e2 | ||||
|  | ||||
| ``` | ||||
|       --flatten[=false]: flatten the resulting kubeconfig file into self contained output (useful for creating portable kubeconfig files) | ||||
|       --merge=true: merge together the full hierarchy of kubeconfig files | ||||
|       --merge[=true]: merge together the full hierarchy of kubeconfig files | ||||
|       --minify[=false]: remove all information not used by current-context from the output | ||||
|       --no-headers[=false]: When using the default output, don't print headers. | ||||
|   -o, --output="": Output format. One of: json|yaml|wide|name|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://releases.k8s.io/HEAD/docs/user-guide/jsonpath.md]. | ||||
| @@ -104,7 +104,7 @@ $ kubectl config view -o template --template='{{range .users}}{{ if eq .name "e2 | ||||
|  | ||||
| * [kubectl config](kubectl_config.md)	 - config modifies kubeconfig files | ||||
|  | ||||
| ###### Auto generated by spf13/cobra on 8-Dec-2015 | ||||
| ###### Auto generated by spf13/cobra on 8-Jan-2016 | ||||
|  | ||||
| <!-- BEGIN MUNGE: GENERATED_ANALYTICS --> | ||||
| []() | ||||
|   | ||||
| @@ -95,7 +95,8 @@ func NewCmdConfigSetAuthInfo(out io.Writer, configAccess ConfigAccess) *cobra.Co | ||||
| 	cmd.Flags().Var(&options.token, clientcmd.FlagBearerToken, clientcmd.FlagBearerToken+" for the user entry in kubeconfig") | ||||
| 	cmd.Flags().Var(&options.username, clientcmd.FlagUsername, clientcmd.FlagUsername+" for the user entry in kubeconfig") | ||||
| 	cmd.Flags().Var(&options.password, clientcmd.FlagPassword, clientcmd.FlagPassword+" for the user entry in kubeconfig") | ||||
| 	cmd.Flags().Var(&options.embedCertData, clientcmd.FlagEmbedCerts, "embed client cert/key for the user entry in kubeconfig") | ||||
| 	f := cmd.Flags().VarPF(&options.embedCertData, clientcmd.FlagEmbedCerts, "", "embed client cert/key for the user entry in kubeconfig") | ||||
| 	f.NoOptDefVal = "true" | ||||
|  | ||||
| 	return cmd | ||||
| } | ||||
|   | ||||
| @@ -79,9 +79,11 @@ func NewCmdConfigSetCluster(out io.Writer, configAccess ConfigAccess) *cobra.Com | ||||
|  | ||||
| 	cmd.Flags().Var(&options.server, clientcmd.FlagAPIServer, clientcmd.FlagAPIServer+" for the cluster entry in kubeconfig") | ||||
| 	cmd.Flags().Var(&options.apiVersion, clientcmd.FlagAPIVersion, clientcmd.FlagAPIVersion+" for the cluster entry in kubeconfig") | ||||
| 	cmd.Flags().Var(&options.insecureSkipTLSVerify, clientcmd.FlagInsecure, clientcmd.FlagInsecure+" for the cluster entry in kubeconfig") | ||||
| 	f := cmd.Flags().VarPF(&options.insecureSkipTLSVerify, clientcmd.FlagInsecure, "", clientcmd.FlagInsecure+" for the cluster entry in kubeconfig") | ||||
| 	f.NoOptDefVal = "true" | ||||
| 	cmd.Flags().Var(&options.certificateAuthority, clientcmd.FlagCAFile, "path to "+clientcmd.FlagCAFile+" for the cluster entry in kubeconfig") | ||||
| 	cmd.Flags().Var(&options.embedCAData, clientcmd.FlagEmbedCerts, clientcmd.FlagEmbedCerts+" for the cluster entry in kubeconfig") | ||||
| 	f = cmd.Flags().VarPF(&options.embedCAData, clientcmd.FlagEmbedCerts, "", clientcmd.FlagEmbedCerts+" for the cluster entry in kubeconfig") | ||||
| 	f.NoOptDefVal = "true" | ||||
|  | ||||
| 	return cmd | ||||
| } | ||||
|   | ||||
| @@ -82,7 +82,8 @@ func NewCmdConfigView(out io.Writer, ConfigAccess ConfigAccess) *cobra.Command { | ||||
| 	cmd.Flags().Set("output", defaultOutputFormat) | ||||
|  | ||||
| 	options.Merge.Default(true) | ||||
| 	cmd.Flags().Var(&options.Merge, "merge", "merge together the full hierarchy of kubeconfig files") | ||||
| 	f := cmd.Flags().VarPF(&options.Merge, "merge", "", "merge together the full hierarchy of kubeconfig files") | ||||
| 	f.NoOptDefVal = "true" | ||||
| 	cmd.Flags().BoolVar(&options.RawByteData, "raw", false, "display raw byte data") | ||||
| 	cmd.Flags().BoolVar(&options.Flatten, "flatten", false, "flatten the resulting kubeconfig file into self contained output (useful for creating portable kubeconfig files)") | ||||
| 	cmd.Flags().BoolVar(&options.Minify, "minify", false, "remove all information not used by current-context from the output") | ||||
|   | ||||
| @@ -22,8 +22,9 @@ import ( | ||||
| ) | ||||
|  | ||||
| // BoolFlag is a boolean flag compatible with flags and pflags that keeps track of whether it had a value supplied or not. | ||||
| // Beware!  If you use this type, you must actually specify --flag-name=true, you cannot leave it as --flag-name and still have | ||||
| // the value set | ||||
| // Getting this flag to act like a normal bool, where true/false are not required needs a little bit of extra code, example: | ||||
| //    f := cmd.Flags().VarPF(&BoolFlagVar, "flagname", "", "help about the flag") | ||||
| //    f.NoOptDefVal = "true" | ||||
| type BoolFlag struct { | ||||
| 	// If Set has been invoked this value is true | ||||
| 	provided bool | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Eric Paris
					Eric Paris