-
Notifications
You must be signed in to change notification settings - Fork 1k
Expand file tree
/
Copy pathpkg_showtag.go
More file actions
38 lines (34 loc) · 1.02 KB
/
pkg_showtag.go
File metadata and controls
38 lines (34 loc) · 1.02 KB
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
package main
import (
"fmt"
"github.com/linuxkit/linuxkit/src/cmd/linuxkit/pkglib"
"github.com/spf13/cobra"
)
func pkgShowTagCmd() *cobra.Command {
var canonical bool
cmd := &cobra.Command{
Use: "show-tag",
Short: "show the tag for packages based on its source directory",
Long: `Show the tag for one or more packages based on their source directories.
'path' specifies the path to the package source directory.
`,
Args: cobra.MinimumNArgs(1),
Example: "linuxkit pkg show-tag path/to/package [path/to/another/package] [path/to/yet/another/package]",
RunE: func(cmd *cobra.Command, args []string) error {
pkgs, err := pkglib.NewFromConfig(pkglibConfig, args...)
if err != nil {
return err
}
for _, p := range pkgs {
tag := p.Tag()
if canonical {
tag = p.FullTag()
}
fmt.Println(tag)
}
return nil
},
}
cmd.Flags().BoolVar(&canonical, "canonical", false, "Show canonical name, e.g. docker.io/linuxkit/foo:1234, instead of the default, e.g. linuxkit/foo:1234")
return cmd
}