The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/3394
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === The verbose list is only available in tabular format
From 812d380aac2546b87286b4d4b572fb8c8636dfaf Mon Sep 17 00:00:00 2001 From: Alberto Donato <[email protected]> Date: Thu, 8 Jun 2017 11:55:54 -0600 Subject: [PATCH] Add an option to list all aliases in "lxc image list" output Signed-off-by: Alberto Donato <[email protected]> --- lxc/image.go | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/lxc/image.go b/lxc/image.go index 4814563c2..8209ca817 100644 --- a/lxc/image.go +++ b/lxc/image.go @@ -38,11 +38,12 @@ func (f *aliasList) Set(value string) error { } type imageCmd struct { - addAliases aliasList - publicImage bool - copyAliases bool - autoUpdate bool - format string + addAliases aliasList + publicImage bool + copyAliases bool + autoUpdate bool + format string + verboseAliases bool } func (c *imageCmd) showByDefault() bool { @@ -110,10 +111,11 @@ lxc image export [<remote>:]<image> [target] lxc image info [<remote>:]<image> Print everything LXD knows about a given image. -lxc image list [<remote>:] [filter] [--format csv|json|table|yaml] +lxc image list [<remote>:] [filter] [--format csv|json|table|yaml] [--aliases] List images in the LXD image store. Filters may be of the <key>=<value> form for property based filtering, or part of the image hash or part of the image alias name. + In tabular output, --aliaes can be passed to list all aliases. lxc image show [<remote>:]<image> Yaml output of the user modifiable properties of an image. @@ -139,6 +141,7 @@ func (c *imageCmd) flags() { gnuflag.BoolVar(&c.autoUpdate, "auto-update", false, i18n.G("Keep the image up to date after initial copy")) gnuflag.Var(&c.addAliases, "alias", i18n.G("New alias to define at target")) gnuflag.StringVar(&c.format, "format", "table", i18n.G("Format (csv|json|table|yaml)")) + gnuflag.BoolVar(&c.verboseAliases, "aliases", false, i18n.G("List all aliases")) } func (c *imageCmd) doImageAlias(config *lxd.Config, args []string) error { @@ -618,15 +621,25 @@ func (c *imageCmd) findDescription(props map[string]string) string { func (c *imageCmd) showImages(images []api.Image, filters []string) error { tableData := func() [][]string { + aliasText := "" data := [][]string{} for _, image := range images { if !c.imageShouldShow(filters, &image) { continue } - shortest := c.shortestAlias(image.Aliases) - if len(image.Aliases) > 1 { - shortest = fmt.Sprintf(i18n.G("%s (%d more)"), shortest, len(image.Aliases)-1) + if c.verboseAliases && c.format == listFormatTable { + aliases := []string{} + for _, alias := range image.Aliases { + aliases = append(aliases, alias.Name) + } + sort.Strings(aliases) + aliasText = strings.Join(aliases, "\n") + } else { + aliasText = c.shortestAlias(image.Aliases) + if len(image.Aliases) > 1 { + aliasText = fmt.Sprintf(i18n.G("%s (%d more)"), aliasText, len(image.Aliases)-1) + } } fp := image.Fingerprint[0:12] public := i18n.G("no") @@ -639,7 +652,7 @@ func (c *imageCmd) showImages(images []api.Image, filters []string) error { const layout = "Jan 2, 2006 at 3:04pm (MST)" uploaded := image.UploadedAt.UTC().Format(layout) size := fmt.Sprintf("%.2fMB", float64(image.Size)/1024.0/1024.0) - data = append(data, []string{shortest, fp, public, description, image.Architecture, size, uploaded}) + data = append(data, []string{aliasText, fp, public, description, image.Architecture, size, uploaded}) } sort.Sort(SortImage(data))
_______________________________________________ lxc-devel mailing list [email protected] http://lists.linuxcontainers.org/listinfo/lxc-devel
