mirror of https://github.com/k3s-io/k3s
Print namespace when asked for job.
Also print multiple containers if there happen to be multiple.pull/6/head
parent
7c5b8f6a58
commit
b4ca15dfce
|
@ -724,13 +724,20 @@ func printReplicationControllerList(list *api.ReplicationControllerList, w io.Wr
|
|||
}
|
||||
|
||||
func printJob(job *experimental.Job, w io.Writer, withNamespace bool, wide bool, showAll bool, columnLabels []string) error {
|
||||
name := job.Name
|
||||
namespace := job.Namespace
|
||||
containers := job.Spec.Template.Spec.Containers
|
||||
var firstContainer api.Container
|
||||
if len(containers) > 0 {
|
||||
firstContainer = containers[0]
|
||||
firstContainer, containers = containers[0], containers[1:]
|
||||
}
|
||||
if withNamespace {
|
||||
if _, err := fmt.Fprintf(w, "%s\t", namespace); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
_, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%d\n",
|
||||
job.Name,
|
||||
name,
|
||||
firstContainer.Name,
|
||||
firstContainer.Image,
|
||||
labels.FormatLabels(job.Spec.Selector),
|
||||
|
@ -738,6 +745,24 @@ func printJob(job *experimental.Job, w io.Writer, withNamespace bool, wide bool,
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := fmt.Fprint(w, appendLabels(job.Labels, columnLabels)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Lay out all the other containers on separate lines.
|
||||
extraLinePrefix := "\t"
|
||||
if withNamespace {
|
||||
extraLinePrefix = "\t\t"
|
||||
}
|
||||
for _, container := range containers {
|
||||
_, err := fmt.Fprintf(w, "%s%s\t%s\t%s\t%s", extraLinePrefix, container.Name, container.Image, "", "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := fmt.Fprint(w, appendLabelTabs(columnLabels)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue