Print recognized file extensions in resource builder error

This commit is contained in:
Jeff Lowdermilk
2015-09-01 16:36:55 -07:00
parent b6f2f396ba
commit cb65cfa746
3 changed files with 36 additions and 28 deletions

View File

@@ -19,12 +19,18 @@ limitations under the License.
package kubectl
import (
"strings"
"github.com/spf13/cobra"
"k8s.io/kubernetes/pkg/kubectl/resource"
)
func AddJsonFilenameFlag(cmd *cobra.Command, value *[]string, usage string) {
cmd.Flags().StringSliceVarP(value, "filename", "f", *value, usage)
annotations := []string{"json", "yaml", "yml"}
annotations := []string{}
for _, ext := range resource.FileExtensions {
annotations = append(annotations, strings.TrimLeft(ext, "."))
}
cmd.Flags().SetAnnotation("filename", cobra.BashCompFilenameExt, annotations)
}