fix kubectl issue(#52)kubectl run --expose continues after error (missing port)

pull/6/head
zhengjiajin 2017-08-17 14:30:46 +08:00
parent e6e963ea51
commit c11a9fc95d
1 changed files with 3 additions and 5 deletions

View File

@ -176,6 +176,9 @@ func RunRun(f cmdutil.Factory, cmdIn io.Reader, cmdOut, cmdErr io.Writer, cmd *c
if interactive && replicas != 1 {
return cmdutil.UsageErrorf(cmd, "-i/--stdin requires that replicas is 1, found %d", replicas)
}
if cmdutil.GetFlagBool(cmd, "expose") && len(cmdutil.GetFlagString(cmd, "port")) == 0 {
return cmdutil.UsageErrorf(cmd, "--port must be set when exposing a service")
}
namespace, _, err := f.DefaultNamespace()
if err != nil {
@ -537,11 +540,6 @@ func generateService(f cmdutil.Factory, cmd *cobra.Command, args []string, servi
}
names := generator.ParamNames()
port := cmdutil.GetFlagString(cmd, "port")
if len(port) == 0 {
return nil, fmt.Errorf("--port must be set when exposing a service")
}
params := map[string]interface{}{}
for key, value := range paramsIn {
_, isString := value.(string)