mirror of https://github.com/k3s-io/k3s
commit
196f58b9cb
|
@ -191,21 +191,28 @@ func RunExpose(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []str
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resourceMapper := &resource.Mapper{ObjectTyper: typer, RESTMapper: mapper, ClientMapper: f.ClientMapperForCommand()}
|
||||||
|
info, err = resourceMapper.InfoForObject(object)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
// TODO: extract this flag to a central location, when such a location exists.
|
// TODO: extract this flag to a central location, when such a location exists.
|
||||||
if !cmdutil.GetFlagBool(cmd, "dry-run") {
|
if cmdutil.GetFlagBool(cmd, "dry-run") {
|
||||||
resourceMapper := &resource.Mapper{ObjectTyper: typer, RESTMapper: mapper, ClientMapper: f.ClientMapperForCommand()}
|
fmt.Fprintln(out, "running in dry-run mode...")
|
||||||
info, err := resourceMapper.InfoForObject(object)
|
} else {
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return f.PrintObject(cmd, object, out)
|
outputFormat := cmdutil.GetFlagString(cmd, "output")
|
||||||
|
if outputFormat != "" {
|
||||||
|
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
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue