Move printing the valid resource types to a function

Should be calculated from discovery in the future. Also improve
descriptions on the affected commands.
This commit is contained in:
Clayton Coleman
2017-10-23 21:14:31 -04:00
parent 55fdceca93
commit 93fed120fb
12 changed files with 305 additions and 97 deletions

View File

@@ -65,14 +65,16 @@ type AnnotateOptions struct {
var (
annotateLong = templates.LongDesc(`
Update the annotations on one or more resources.
Update the annotations on one or more resources
* An annotation is a key/value pair that can hold larger (compared to a label), and possibly not human-readable, data.
* It is intended to store non-identifying auxiliary data, especially data manipulated by tools and system extensions.
* If --overwrite is true, then existing annotations can be overwritten, otherwise attempting to overwrite an annotation will result in an error.
* If --resource-version is specified, then updates will use this resource version, otherwise the existing resource-version will be used.
All Kubernetes objects support the ability to store additional data with the object as
annotations. Annotations are key/value pairs that can be larger than labels and include
arbitrary string values such as structured JSON. Tools and system extensions may use
annotations to store their own data.
` + validResources)
Attempting to set an annotation that already exists will fail unless --overwrite is set.
If --resource-version is specified and does not match the current resource version on
the server the command will fail.`)
annotateExample = templates.Examples(i18n.T(`
# Update pod 'foo' with the annotation 'description' and the value 'my frontend'.
@@ -113,7 +115,7 @@ func NewCmdAnnotate(f cmdutil.Factory, out io.Writer) *cobra.Command {
cmd := &cobra.Command{
Use: "annotate [--overwrite] (-f FILENAME | TYPE NAME) KEY_1=VAL_1 ... KEY_N=VAL_N [--resource-version=version]",
Short: i18n.T("Update the annotations on a resource"),
Long: annotateLong,
Long: annotateLong + "\n\n" + cmdutil.ValidResourceTypeList(f),
Example: annotateExample,
Run: func(cmd *cobra.Command, args []string) {
if err := options.Complete(out, cmd, args); err != nil {