change annotate_resources to valid_resources

pull/6/head
lojies 2016-09-01 16:33:51 +08:00
parent 0c911ab701
commit 479ddc8818
1 changed files with 7 additions and 12 deletions

View File

@ -21,8 +21,6 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"regexp"
"strings"
"github.com/golang/glog" "github.com/golang/glog"
"github.com/renstrom/dedent" "github.com/renstrom/dedent"
@ -60,12 +58,6 @@ type AnnotateOptions struct {
} }
var ( var (
annotate_resources = `
pod (po), service (svc), replicationcontroller (rc),
node (no), event (ev), componentstatuse (cs),
limitrange (limits), persistentvolume (pv), persistentvolumeclaim (pvc),
horizontalpodautoscaler (hpa), resourcequota (quota), secret`
annotate_long = dedent.Dedent(` annotate_long = dedent.Dedent(`
Update the annotations on one or more resources. Update the annotations on one or more resources.
@ -74,7 +66,7 @@ var (
If --overwrite is true, then existing annotations can be overwritten, otherwise attempting to overwrite an annotation will result in an error. 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. If --resource-version is specified, then updates will use this resource version, otherwise the existing resource-version will be used.
Possible resources include (case insensitive):`) + annotate_resources `) + valid_resources
annotate_example = dedent.Dedent(` annotate_example = dedent.Dedent(`
# Update pod 'foo' with the annotation 'description' and the value 'my frontend'. # Update pod 'foo' with the annotation 'description' and the value 'my frontend'.
@ -102,9 +94,12 @@ func NewCmdAnnotate(f *cmdutil.Factory, out io.Writer) *cobra.Command {
options := &AnnotateOptions{} options := &AnnotateOptions{}
validArgs, argAliases := []string{}, []string{} validArgs, argAliases := []string{}, []string{}
resources := regexp.MustCompile(`\s*,`).Split(annotate_resources, -1) p, err := f.Printer(nil, kubectl.PrintOptions{
for _, r := range resources { ColumnLabels: []string{},
validArgs = append(validArgs, strings.Fields(r)[0]) })
cmdutil.CheckErr(err)
if p != nil {
validArgs = p.HandledResources()
argAliases = kubectl.ResourceAliases(validArgs) argAliases = kubectl.ResourceAliases(validArgs)
} }