mirror of
https://github.com/genuinetools/reg.git
synced 2024-09-28 11:46:20 -04:00
f3a9b00ec8
Signed-off-by: Jess Frazelle <acidburn@microsoft.com>
42 lines
714 B
Go
42 lines
714 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"sort"
|
|
"strings"
|
|
|
|
"github.com/genuinetools/reg/registry"
|
|
"github.com/urfave/cli"
|
|
)
|
|
|
|
var tagsCommand = cli.Command{
|
|
Name: "tags",
|
|
Usage: "get the tags for a repository",
|
|
Action: func(c *cli.Context) error {
|
|
if len(c.Args()) < 1 {
|
|
return fmt.Errorf("pass the name of the repository")
|
|
}
|
|
|
|
image, err := registry.ParseImage(c.Args().First())
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
// Create the registry client.
|
|
r, err := createRegistryClient(c, image.Domain)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
tags, err := r.Tags(image.Path)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
sort.Strings(tags)
|
|
|
|
// Print the tags.
|
|
fmt.Println(strings.Join(tags, "\n"))
|
|
|
|
return nil
|
|
},
|
|
}
|