mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 21:17:23 +00:00
Merge pull request #14607 from erictune/jobs-get-fix
kubectl get jobs printing fix
This commit is contained in:
commit
cae6b7cf61
@ -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 {
|
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
|
containers := job.Spec.Template.Spec.Containers
|
||||||
var firstContainer api.Container
|
var firstContainer api.Container
|
||||||
if len(containers) > 0 {
|
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",
|
_, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%d\n",
|
||||||
job.Name,
|
name,
|
||||||
firstContainer.Name,
|
firstContainer.Name,
|
||||||
firstContainer.Image,
|
firstContainer.Image,
|
||||||
labels.FormatLabels(job.Spec.Selector),
|
labels.FormatLabels(job.Spec.Selector),
|
||||||
@ -738,6 +745,24 @@ func printJob(job *experimental.Job, w io.Writer, withNamespace bool, wide bool,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user