From 837719a02d9137ed03a1973547389b4f576aec84 Mon Sep 17 00:00:00 2001 From: bryanl <bryanliles@gmail.com> Date: Tue, 28 Nov 2017 14:48:29 -0500 Subject: [PATCH] Use component name for param name if name parameter is omitted In general, prototypes have a name param. To reduce duplication, use the component name for the name param if the name parameter is omitted. This will turn : ``` ks prototype use deployed-service guestbook-ui \ --name guestbook-ui \ --image alpinejay/dns-single-redis-guestbook:1.0 \ --type LoadBalancer ``` into ``` ks prototype use deployed-service guestbook-ui \ --image alpinejay/dns-single-redis-guestbook:1.0 \ --type LoadBalancer ``` as the `--name` parameter will be inferred. If the operator wishes the name to be different, they can supply the name parameter: ``` ks prototype use deployed-service guestbook-ui \ --name fancy-stuff \ --image alpinejay/dns-single-redis-guestbook:1.0 \ --type LoadBalancer ``` Signed-off-by: bryanl <bryanliles@gmail.com> --- cmd/prototype.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cmd/prototype.go b/cmd/prototype.go index 11cd1a52..eb629ba9 100644 --- a/cmd/prototype.go +++ b/cmd/prototype.go @@ -388,6 +388,15 @@ var prototypeUseCmd = &cobra.Command{ return fmt.Errorf("Command has too many arguments (takes a prototype name and a component name)\n\n%s", cmd.UsageString()) } + name, err := flags.GetString("name") + if err != nil { + return err + } + + if name == "" { + flags.Set("name", componentName) + } + params, err := getParameters(proto, flags) if err != nil { return err -- GitLab