blob: c99e5d173c18d18ab75d31d53bb5c6f9089019cb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
package main
import (
"github.com/containers/libpod/libpod/adapter"
"github.com/pkg/errors"
"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 ...]",
OnUsageError: usageErrorHandler,
}
)
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")
}
localRuntime, err := adapter.GetRuntime(c)
if err != nil {
return errors.Wrapf(err, "could not create runtime")
}
defer localRuntime.Runtime.Shutdown(false)
newImage, err := localRuntime.NewImageFromLocal(args[0])
if err != nil {
return err
}
for _, tagName := range args[1:] {
if err := newImage.TagImage(tagName); err != nil {
return errors.Wrapf(err, "error adding '%s' to image %q", tagName, newImage.InputName)
}
}
return nil
}
|