Simplify default output of "expose" command
Use simple output string such as "rc nginx exposed" to show the result. Users can still use options like "-o yaml" to view detailed result. IP will be printed with detailed result now.
This commit is contained in:
		@@ -191,21 +191,28 @@ func RunExpose(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []str
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// TODO: extract this flag to a central location, when such a location exists.
 | 
					 | 
				
			||||||
	if !cmdutil.GetFlagBool(cmd, "dry-run") {
 | 
					 | 
				
			||||||
	resourceMapper := &resource.Mapper{ObjectTyper: typer, RESTMapper: mapper, ClientMapper: f.ClientMapperForCommand()}
 | 
						resourceMapper := &resource.Mapper{ObjectTyper: typer, RESTMapper: mapper, ClientMapper: f.ClientMapperForCommand()}
 | 
				
			||||||
		info, err := resourceMapper.InfoForObject(object)
 | 
						info, err = resourceMapper.InfoForObject(object)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						// TODO: extract this flag to a central location, when such a location exists.
 | 
				
			||||||
 | 
						if cmdutil.GetFlagBool(cmd, "dry-run") {
 | 
				
			||||||
 | 
							fmt.Fprintln(out, "running in dry-run mode...")
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
		data, err := info.Mapping.Codec.Encode(object)
 | 
							data, err := info.Mapping.Codec.Encode(object)
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return err
 | 
								return err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		_, err = resource.NewHelper(info.Client, info.Mapping).Create(namespace, false, data)
 | 
							object, err = resource.NewHelper(info.Client, info.Mapping).Create(namespace, false, data)
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return err
 | 
								return err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						outputFormat := cmdutil.GetFlagString(cmd, "output")
 | 
				
			||||||
 | 
						if outputFormat != "" {
 | 
				
			||||||
		return f.PrintObject(cmd, object, out)
 | 
							return f.PrintObject(cmd, object, out)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						cmdutil.PrintSuccess(mapper, false, out, info.Mapping.Resource, info.Name, "exposed")
 | 
				
			||||||
 | 
						return nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -242,11 +242,10 @@ func RunLabel(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []stri
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		outputFormat := cmdutil.GetFlagString(cmd, "output")
 | 
							outputFormat := cmdutil.GetFlagString(cmd, "output")
 | 
				
			||||||
		if outputFormat == "" {
 | 
							if outputFormat != "" {
 | 
				
			||||||
			cmdutil.PrintSuccess(mapper, false, out, info.Mapping.Resource, info.Name, "labeled")
 | 
					 | 
				
			||||||
		} else {
 | 
					 | 
				
			||||||
			return f.PrintObject(cmd, outputObj, out)
 | 
								return f.PrintObject(cmd, outputObj, out)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							cmdutil.PrintSuccess(mapper, false, out, info.Mapping.Resource, info.Name, "labeled")
 | 
				
			||||||
		return nil
 | 
							return nil
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user