Merge pull request #14406 from hurf/config_message

Improve message from kubectl config
This commit is contained in:
Brian Grant 2015-09-25 11:01:34 -07:00
commit b90797d941
11 changed files with 45 additions and 33 deletions

View File

@ -3,7 +3,7 @@
.SH NAME
.PP
kubectl config view \- displays Merged kubeconfig settings or a specified kubeconfig file.
kubectl config view \- Displays merged kubeconfig settings or a specified kubeconfig file.
.SH SYNOPSIS
@ -13,7 +13,7 @@ kubectl config view \- displays Merged kubeconfig settings or a specified kubeco
.SH DESCRIPTION
.PP
displays Merged kubeconfig settings or a specified kubeconfig file.
Displays merged kubeconfig settings or a specified kubeconfig file.
.PP
You can use \-\-output=template \-\-template=TEMPLATE to extract specific values.

View File

@ -92,9 +92,9 @@ kubectl config SUBCOMMAND
* [kubectl config set-credentials](kubectl_config_set-credentials.md) - Sets a user entry in kubeconfig
* [kubectl config unset](kubectl_config_unset.md) - Unsets an individual value in a kubeconfig file
* [kubectl config use-context](kubectl_config_use-context.md) - Sets the current-context in a kubeconfig file
* [kubectl config view](kubectl_config_view.md) - displays Merged kubeconfig settings or a specified kubeconfig file.
* [kubectl config view](kubectl_config_view.md) - Displays merged kubeconfig settings or a specified kubeconfig file.
###### Auto generated by spf13/cobra at 2015-09-10 18:53:03.163685546 +0000 UTC
###### Auto generated by spf13/cobra at 2015-09-23 08:09:58.253683538 +0000 UTC
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_config.md?pixel)]()

View File

@ -33,12 +33,12 @@ Documentation for other releases can be found at
## kubectl config view
displays Merged kubeconfig settings or a specified kubeconfig file.
Displays merged kubeconfig settings or a specified kubeconfig file.
### Synopsis
displays Merged kubeconfig settings or a specified kubeconfig file.
Displays merged kubeconfig settings or a specified kubeconfig file.
You can use --output=template --template=TEMPLATE to extract specific values.
@ -103,7 +103,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 at 2015-09-10 18:53:03.161359997 +0000 UTC
###### Auto generated by spf13/cobra at 2015-09-23 08:09:58.252744701 +0000 UTC
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_config_view.md?pixel)]()

View File

@ -101,7 +101,7 @@ func TestSetNonExistentContext(t *testing.T) {
args: []string{"use-context", "non-existent-config"},
startingConfig: expectedConfig,
expectedConfig: expectedConfig,
expectedOutputs: []string{`No context exists with the name: "non-existent-config"`},
expectedOutputs: []string{`no context exists with the name: "non-existent-config"`},
}
test.run(t)
}

View File

@ -84,6 +84,8 @@ func NewCmdConfigSetAuthInfo(out io.Writer, configAccess ConfigAccess) *cobra.Co
err := options.run()
if err != nil {
fmt.Fprintf(out, "%v\n", err)
} else {
fmt.Fprintf(out, "user %q set.\n", options.name)
}
},
}
@ -197,7 +199,7 @@ func (o *createAuthInfoOptions) complete(cmd *cobra.Command) bool {
func (o createAuthInfoOptions) validate() error {
if len(o.name) == 0 {
return errors.New("You must specify a non-empty user name")
return errors.New("you must specify a non-empty user name")
}
methods := []string{}
if len(o.token.Value()) > 0 {
@ -207,22 +209,22 @@ func (o createAuthInfoOptions) validate() error {
methods = append(methods, fmt.Sprintf("--%v/--%v", clientcmd.FlagUsername, clientcmd.FlagPassword))
}
if len(methods) > 1 {
return fmt.Errorf("You cannot specify more than one authentication method at the same time: %v", strings.Join(methods, ", "))
return fmt.Errorf("you cannot specify more than one authentication method at the same time: %v", strings.Join(methods, ", "))
}
if o.embedCertData.Value() {
certPath := o.clientCertificate.Value()
keyPath := o.clientKey.Value()
if certPath == "" && keyPath == "" {
return fmt.Errorf("You must specify a --%s or --%s to embed", clientcmd.FlagCertFile, clientcmd.FlagKeyFile)
return fmt.Errorf("you must specify a --%s or --%s to embed", clientcmd.FlagCertFile, clientcmd.FlagKeyFile)
}
if certPath != "" {
if _, err := ioutil.ReadFile(certPath); err != nil {
return fmt.Errorf("Error reading %s data from %s: %v", clientcmd.FlagCertFile, certPath, err)
return fmt.Errorf("error reading %s data from %s: %v", clientcmd.FlagCertFile, certPath, err)
}
}
if keyPath != "" {
if _, err := ioutil.ReadFile(keyPath); err != nil {
return fmt.Errorf("Error reading %s data from %s: %v", clientcmd.FlagKeyFile, keyPath, err)
return fmt.Errorf("error reading %s data from %s: %v", clientcmd.FlagKeyFile, keyPath, err)
}
}
}

View File

@ -69,6 +69,8 @@ func NewCmdConfigSetCluster(out io.Writer, configAccess ConfigAccess) *cobra.Com
err := options.run()
if err != nil {
fmt.Fprintf(out, "%v\n", err)
} else {
fmt.Fprintf(out, "cluster %q set.\n", options.name)
}
},
}
@ -160,18 +162,18 @@ func (o *createClusterOptions) complete(cmd *cobra.Command) bool {
func (o createClusterOptions) validate() error {
if len(o.name) == 0 {
return errors.New("You must specify a non-empty cluster name")
return errors.New("you must specify a non-empty cluster name")
}
if o.insecureSkipTLSVerify.Value() && o.certificateAuthority.Value() != "" {
return errors.New("You cannot specify a certificate authority and insecure mode at the same time")
return errors.New("you cannot specify a certificate authority and insecure mode at the same time")
}
if o.embedCAData.Value() {
caPath := o.certificateAuthority.Value()
if caPath == "" {
return fmt.Errorf("You must specify a --%s to embed", clientcmd.FlagCAFile)
return fmt.Errorf("you must specify a --%s to embed", clientcmd.FlagCAFile)
}
if _, err := ioutil.ReadFile(caPath); err != nil {
return fmt.Errorf("Could not read %s data from %s: %v", clientcmd.FlagCAFile, caPath, err)
return fmt.Errorf("could not read %s data from %s: %v", clientcmd.FlagCAFile, caPath, err)
}
}

View File

@ -58,7 +58,9 @@ func NewCmdConfigSetContext(out io.Writer, configAccess ConfigAccess) *cobra.Com
err := options.run()
if err != nil {
fmt.Printf("%v\n", err)
fmt.Fprintf(out, "%v\n", err)
} else {
fmt.Fprintf(out, "context %q set.\n", options.name)
}
},
}
@ -124,7 +126,7 @@ func (o *createContextOptions) complete(cmd *cobra.Command) bool {
func (o createContextOptions) validate() error {
if len(o.name) == 0 {
return errors.New("You must specify a non-empty context name")
return errors.New("you must specify a non-empty context name")
}
return nil

View File

@ -55,7 +55,9 @@ func NewCmdConfigSet(out io.Writer, configAccess ConfigAccess) *cobra.Command {
err := options.run()
if err != nil {
fmt.Printf("%v\n", err)
fmt.Fprintf(out, "%v\n", err)
} else {
fmt.Fprintf(out, "property %q set.\n", options.propertyName)
}
},
}
@ -103,11 +105,11 @@ func (o *setOptions) complete(cmd *cobra.Command) bool {
func (o setOptions) validate() error {
if len(o.propertyValue) == 0 {
return errors.New("You cannot use set to unset a property")
return errors.New("you cannot use set to unset a property")
}
if len(o.propertyName) == 0 {
return errors.New("You must specify a property")
return errors.New("you must specify a property")
}
return nil
@ -124,7 +126,7 @@ func modifyConfig(curr reflect.Value, steps *navigationSteps, propertyValue stri
switch actualCurrValue.Kind() {
case reflect.Map:
if !steps.moreStepsRemaining() && !unset {
return fmt.Errorf("Can't set a map to a value: %v", actualCurrValue)
return fmt.Errorf("can't set a map to a value: %v", actualCurrValue)
}
mapKey := reflect.ValueOf(currStep.stepValue)
@ -152,14 +154,14 @@ func modifyConfig(curr reflect.Value, steps *navigationSteps, propertyValue stri
case reflect.String:
if steps.moreStepsRemaining() {
return fmt.Errorf("Can't have more steps after a string. %v", steps)
return fmt.Errorf("can't have more steps after a string. %v", steps)
}
actualCurrValue.SetString(propertyValue)
return nil
case reflect.Bool:
if steps.moreStepsRemaining() {
return fmt.Errorf("Can't have more steps after a bool. %v", steps)
return fmt.Errorf("can't have more steps after a bool. %v", steps)
}
boolValue, err := toBool(propertyValue)
if err != nil {
@ -198,9 +200,9 @@ func modifyConfig(curr reflect.Value, steps *navigationSteps, propertyValue stri
}
}
return fmt.Errorf("Unable to locate path %#v under %v", currStep, actualCurrValue)
return fmt.Errorf("unable to locate path %#v under %v", currStep, actualCurrValue)
}
panic(fmt.Errorf("Unrecognized type: %v", actualCurrValue))
panic(fmt.Errorf("unrecognized type: %v", actualCurrValue))
}

View File

@ -47,7 +47,9 @@ func NewCmdConfigUnset(out io.Writer, configAccess ConfigAccess) *cobra.Command
err := options.run()
if err != nil {
fmt.Printf("%v\n", err)
fmt.Fprintf(out, "%v\n", err)
} else {
fmt.Fprintf(out, "property %q unset.\n", options.propertyName)
}
},
}
@ -95,7 +97,7 @@ func (o *unsetOptions) complete(cmd *cobra.Command) bool {
func (o unsetOptions) validate() error {
if len(o.propertyName) == 0 {
return errors.New("You must specify a property")
return errors.New("you must specify a property")
}
return nil

View File

@ -46,6 +46,8 @@ func NewCmdConfigUseContext(out io.Writer, configAccess ConfigAccess) *cobra.Com
err := options.run()
if err != nil {
fmt.Fprintf(out, "%v\n", err)
} else {
fmt.Fprintf(out, "switched to context %q.\n", options.contextName)
}
},
}
@ -86,7 +88,7 @@ func (o *useContextOptions) complete(cmd *cobra.Command) bool {
func (o useContextOptions) validate(config *clientcmdapi.Config) error {
if len(o.contextName) == 0 {
return errors.New("You must specify a current-context")
return errors.New("you must specify a current-context")
}
for name := range config.Contexts {
@ -95,5 +97,5 @@ func (o useContextOptions) validate(config *clientcmdapi.Config) error {
}
}
return fmt.Errorf("No context exists with the name: %q.", o.contextName)
return fmt.Errorf("no context exists with the name: %q.", o.contextName)
}

View File

@ -40,7 +40,7 @@ type ViewOptions struct {
}
const (
view_long = `displays Merged kubeconfig settings or a specified kubeconfig file.
view_long = `Displays merged kubeconfig settings or a specified kubeconfig file.
You can use --output=template --template=TEMPLATE to extract specific values.`
view_example = `# Show Merged kubeconfig settings.
@ -55,7 +55,7 @@ func NewCmdConfigView(out io.Writer, ConfigAccess ConfigAccess) *cobra.Command {
cmd := &cobra.Command{
Use: "view",
Short: "displays Merged kubeconfig settings or a specified kubeconfig file.",
Short: "Displays merged kubeconfig settings or a specified kubeconfig file.",
Long: view_long,
Example: view_example,
Run: func(cmd *cobra.Command, args []string) {