cmd: refactor common err expr into helper function

The same redundant fmt.Sprintf() and string literal was duplicated
throughout many of the files in kubectl/cmd. Replace with a helper
function.
This commit is contained in:
Alexander Campbell
2017-05-25 12:44:43 -07:00
parent 066dbb7206
commit 01ae6edc6c
10 changed files with 19 additions and 24 deletions

View File

@@ -92,7 +92,7 @@ func createDeployment(f cmdutil.Factory, cmdOut, cmdErr io.Writer, cmd *cobra.Co
case cmdutil.DeploymentBasicV1Beta1GeneratorName:
generator = &kubectl.DeploymentBasicGeneratorV1{Name: name, Images: cmdutil.GetFlagStringSlice(cmd, "image")}
default:
return cmdutil.UsageError(cmd, fmt.Sprintf("Generator: %s not supported.", generatorName))
return errUnsupportedGenerator(cmd, generatorName)
}
return RunCreateSubcommand(f, cmd, cmdOut, &CreateSubcommandOptions{
Name: name,