mirror of
https://github.com/containers/skopeo.git
synced 2026-07-14 13:48:32 +00:00
Use Errorf() from 'errors' rather than 'fmt' to help with stack traces. Signed-off-by: Nalin Dahyabhai <nalin@redhat.com> Closes: #130 Approved by: rhatdan
39 lines
933 B
Go
39 lines
933 B
Go
package main
|
|
|
|
import (
|
|
"github.com/pkg/errors"
|
|
"github.com/projectatomic/buildah/util"
|
|
"github.com/urfave/cli"
|
|
)
|
|
|
|
var (
|
|
tagDescription = "Adds one or more additional names to locally-stored image"
|
|
tagCommand = cli.Command{
|
|
Name: "tag",
|
|
Usage: "Add an additional name to a local image",
|
|
Description: tagDescription,
|
|
Action: tagCmd,
|
|
ArgsUsage: "IMAGE-NAME [IMAGE-NAME ...]",
|
|
}
|
|
)
|
|
|
|
func tagCmd(c *cli.Context) error {
|
|
args := c.Args()
|
|
if len(args) < 2 {
|
|
return errors.Errorf("image name and at least one new name must be specified")
|
|
}
|
|
store, err := getStore(c)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
img, err := util.FindImage(store, args[0])
|
|
if err != nil {
|
|
return errors.Wrapf(err, "error finding local image %q", args[0])
|
|
}
|
|
err = util.AddImageNames(store, img, args[1:])
|
|
if err != nil {
|
|
return errors.Wrapf(err, "error adding names %v to image %q", args[1:], args[0])
|
|
}
|
|
return nil
|
|
}
|