func printImageStream(stream *imageapi.ImageStream, w io.Writer, withNamespace, wide bool, columnLabels []string) error { tags := "" const numOfTagsShown = 3 var latest util.Time for _, list := range stream.Status.Tags { if len(list.Items) > 0 { if list.Items[0].Created.After(latest.Time) { latest = list.Items[0].Created } } } latestTime := "" if !latest.IsZero() { latestTime = fmt.Sprintf("%s ago", formatRelativeTime(latest.Time)) } list := imageapi.SortStatusTags(stream.Status.Tags) more := false if len(list) > numOfTagsShown { list = list[:numOfTagsShown] more = true } tags = strings.Join(list, ",") if more { tags = fmt.Sprintf("%s + %d more...", tags, len(stream.Status.Tags)-numOfTagsShown) } if withNamespace { if _, err := fmt.Fprintf(w, "%s\t", stream.Namespace); err != nil { return err } } _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", stream.Name, stream.Status.DockerImageRepository, tags, latestTime) return err }
func printImageStream(stream *imageapi.ImageStream, w io.Writer, opts kctl.PrintOptions) error { name := formatResourceName(opts.Kind, stream.Name, opts.WithKind) tags := "" const numOfTagsShown = 3 var latest unversioned.Time for _, list := range stream.Status.Tags { if len(list.Items) > 0 { if list.Items[0].Created.After(latest.Time) { latest = list.Items[0].Created } } } latestTime := "" if !latest.IsZero() { latestTime = fmt.Sprintf("%s ago", formatRelativeTime(latest.Time)) } list := imageapi.SortStatusTags(stream.Status.Tags) more := false if len(list) > numOfTagsShown { list = list[:numOfTagsShown] more = true } tags = strings.Join(list, ",") if more { tags = fmt.Sprintf("%s + %d more...", tags, len(stream.Status.Tags)-numOfTagsShown) } if opts.WithNamespace { if _, err := fmt.Fprintf(w, "%s\t", stream.Namespace); err != nil { return err } } repo := stream.Spec.DockerImageRepository if len(repo) == 0 { repo = stream.Status.DockerImageRepository } if _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s", name, repo, tags, latestTime); err != nil { return err } if err := appendItemLabels(stream.Labels, w, opts.ColumnLabels, opts.ShowLabels); err != nil { return err } return nil }