summaryrefslogtreecommitdiff
path: root/cmd/podman/manifest
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman/manifest')
-rw-r--r--cmd/podman/manifest/annotate.go56
-rw-r--r--cmd/podman/manifest/manifest.go11
-rw-r--r--cmd/podman/manifest/push.go66
-rw-r--r--cmd/podman/manifest/remove.go47
4 files changed, 177 insertions, 3 deletions
diff --git a/cmd/podman/manifest/annotate.go b/cmd/podman/manifest/annotate.go
new file mode 100644
index 000000000..82ee1ffda
--- /dev/null
+++ b/cmd/podman/manifest/annotate.go
@@ -0,0 +1,56 @@
+package manifest
+
+import (
+ "context"
+ "fmt"
+
+ "github.com/containers/libpod/cmd/podman/registry"
+ "github.com/containers/libpod/pkg/domain/entities"
+ "github.com/pkg/errors"
+ "github.com/spf13/cobra"
+)
+
+var (
+ manifestAnnotateOpts = entities.ManifestAnnotateOptions{}
+ annotateCmd = &cobra.Command{
+ Use: "annotate [flags] LIST IMAGE",
+ Short: "Add or update information about an entry in a manifest list or image index",
+ Long: "Adds or updates information about an entry in a manifest list or image index.",
+ RunE: annotate,
+ Example: `podman manifest annotate --annotation left=right mylist:v1.11 image:v1.11-amd64`,
+ Args: cobra.ExactArgs(2),
+ }
+)
+
+func init() {
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode},
+ Command: annotateCmd,
+ Parent: manifestCmd,
+ })
+ flags := annotateCmd.Flags()
+ flags.StringSliceVar(&manifestAnnotateOpts.Annotation, "annotation", nil, "set an `annotation` for the specified image")
+ flags.StringVar(&manifestAnnotateOpts.Arch, "arch", "", "override the `architecture` of the specified image")
+ flags.StringSliceVar(&manifestAnnotateOpts.Features, "features", nil, "override the `features` of the specified image")
+ flags.StringVar(&manifestAnnotateOpts.OS, "os", "", "override the `OS` of the specified image")
+ flags.StringSliceVar(&manifestAnnotateOpts.OSFeatures, "os-features", nil, "override the OS `features` of the specified image")
+ flags.StringVar(&manifestAnnotateOpts.OSVersion, "os-version", "", "override the OS `version` of the specified image")
+ flags.StringVar(&manifestAnnotateOpts.Variant, "variant", "", "override the `variant` of the specified image")
+}
+
+func annotate(cmd *cobra.Command, args []string) error {
+ listImageSpec := args[0]
+ instanceSpec := args[1]
+ if listImageSpec == "" {
+ return errors.Errorf(`invalid image name "%s"`, listImageSpec)
+ }
+ if instanceSpec == "" {
+ return errors.Errorf(`invalid image digest "%s"`, instanceSpec)
+ }
+ updatedListID, err := registry.ImageEngine().ManifestAnnotate(context.Background(), args, manifestAnnotateOpts)
+ if err != nil {
+ return errors.Wrapf(err, "error removing from manifest list %s", listImageSpec)
+ }
+ fmt.Printf("%s\n", updatedListID)
+ return nil
+}
diff --git a/cmd/podman/manifest/manifest.go b/cmd/podman/manifest/manifest.go
index b9ac7ea68..d7f042a56 100644
--- a/cmd/podman/manifest/manifest.go
+++ b/cmd/podman/manifest/manifest.go
@@ -2,6 +2,7 @@ package manifest
import (
"github.com/containers/libpod/cmd/podman/registry"
+ "github.com/containers/libpod/cmd/podman/validate"
"github.com/containers/libpod/pkg/domain/entities"
"github.com/spf13/cobra"
)
@@ -13,9 +14,13 @@ var (
Short: "Manipulate manifest lists and image indexes",
Long: manifestDescription,
TraverseChildren: true,
- RunE: registry.SubCommandExists,
- Example: `podman manifest create localhost/list
- podman manifest inspect localhost/list`,
+ RunE: validate.SubCommandExists,
+ Example: `podman manifest add mylist:v1.11 image:v1.11-amd64
+ podman manifest create localhost/list
+ podman manifest inspect localhost/list
+ podman manifest annotate --annotation left=right mylist:v1.11 image:v1.11-amd64
+ podman manifest push mylist:v1.11 quay.io/myimagelist
+ podman manifest remove mylist:v1.11 sha256:15352d97781ffdf357bf3459c037be3efac4133dc9070c2dce7eca7c05c3e736`,
}
)
diff --git a/cmd/podman/manifest/push.go b/cmd/podman/manifest/push.go
new file mode 100644
index 000000000..49c76f40b
--- /dev/null
+++ b/cmd/podman/manifest/push.go
@@ -0,0 +1,66 @@
+package manifest
+
+import (
+ "context"
+
+ "github.com/containers/common/pkg/auth"
+ "github.com/containers/libpod/cmd/podman/registry"
+ "github.com/containers/libpod/pkg/domain/entities"
+ "github.com/pkg/errors"
+ "github.com/spf13/cobra"
+)
+
+var (
+ manifestPushOpts = entities.ManifestPushOptions{}
+ pushCmd = &cobra.Command{
+ Use: "push [flags] SOURCE DESTINATION",
+ Short: "Push a manifest list or image index to a registry",
+ Long: "Pushes manifest lists and image indexes to registries.",
+ RunE: push,
+ Example: `podman manifest push mylist:v1.11 quay.io/myimagelist`,
+ Args: cobra.ExactArgs(2),
+ }
+)
+
+func init() {
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
+ Command: pushCmd,
+ Parent: manifestCmd,
+ })
+ flags := pushCmd.Flags()
+ flags.BoolVar(&manifestPushOpts.Purge, "purge", false, "remove the manifest list if push succeeds")
+ flags.BoolVar(&manifestPushOpts.All, "all", false, "also push the images in the list")
+ flags.StringVar(&manifestPushOpts.Authfile, "authfile", auth.GetDefaultAuthFile(), "path of the authentication file. Use REGISTRY_AUTH_FILE environment variable to override")
+ flags.StringVar(&manifestPushOpts.CertDir, "cert-dir", "", "use certificates at the specified path to access the registry")
+ flags.StringVar(&manifestPushOpts.Creds, "creds", "", "use `[username[:password]]` for accessing the registry")
+ flags.StringVar(&manifestPushOpts.DigestFile, "digestfile", "", "after copying the image, write the digest of the resulting digest to the file")
+ flags.StringVarP(&manifestPushOpts.Format, "format", "f", "", "manifest type (oci or v2s2) to attempt to use when pushing the manifest list (default is manifest type of source)")
+ flags.BoolVarP(&manifestPushOpts.RemoveSignatures, "remove-signatures", "", false, "don't copy signatures when pushing images")
+ flags.StringVar(&manifestPushOpts.SignBy, "sign-by", "", "sign the image using a GPG key with the specified `FINGERPRINT`")
+ flags.BoolVar(&manifestPushOpts.TlsVerify, "tls-verify", true, "require HTTPS and verify certificates when accessing the registry")
+ flags.BoolVarP(&manifestPushOpts.Quiet, "quiet", "q", false, "don't output progress information when pushing lists")
+ if registry.IsRemote() {
+ _ = flags.MarkHidden("authfile")
+ _ = flags.MarkHidden("cert-dir")
+ _ = flags.MarkHidden("tls-verify")
+ }
+}
+
+func push(cmd *cobra.Command, args []string) error {
+ if err := auth.CheckAuthFile(manifestPushOpts.Authfile); err != nil {
+ return err
+ }
+ listImageSpec := args[0]
+ destSpec := args[1]
+ if listImageSpec == "" {
+ return errors.Errorf(`invalid image name "%s"`, listImageSpec)
+ }
+ if destSpec == "" {
+ return errors.Errorf(`invalid destination "%s"`, destSpec)
+ }
+ if err := registry.ImageEngine().ManifestPush(context.Background(), args, manifestPushOpts); err != nil {
+ return errors.Wrapf(err, "error pushing manifest %s to %s", listImageSpec, destSpec)
+ }
+ return nil
+}
diff --git a/cmd/podman/manifest/remove.go b/cmd/podman/manifest/remove.go
new file mode 100644
index 000000000..4d345efc0
--- /dev/null
+++ b/cmd/podman/manifest/remove.go
@@ -0,0 +1,47 @@
+package manifest
+
+import (
+ "context"
+ "fmt"
+
+ "github.com/containers/libpod/cmd/podman/registry"
+ "github.com/containers/libpod/pkg/domain/entities"
+ "github.com/pkg/errors"
+ "github.com/spf13/cobra"
+)
+
+var (
+ removeCmd = &cobra.Command{
+ Use: "remove [flags] LIST IMAGE",
+ Short: "Remove an entry from a manifest list or image index",
+ Long: "Removes an image from a manifest list or image index.",
+ RunE: remove,
+ Example: `podman manifest remove mylist:v1.11 sha256:15352d97781ffdf357bf3459c037be3efac4133dc9070c2dce7eca7c05c3e736`,
+ Args: cobra.ExactArgs(2),
+ }
+)
+
+func init() {
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
+ Command: removeCmd,
+ Parent: manifestCmd,
+ })
+}
+
+func remove(cmd *cobra.Command, args []string) error {
+ listImageSpec := args[0]
+ instanceSpec := args[1]
+ if listImageSpec == "" {
+ return errors.Errorf(`invalid image name "%s"`, listImageSpec)
+ }
+ if instanceSpec == "" {
+ return errors.Errorf(`invalid image digest "%s"`, instanceSpec)
+ }
+ updatedListID, err := registry.ImageEngine().ManifestRemove(context.Background(), args)
+ if err != nil {
+ return errors.Wrapf(err, "error removing from manifest list %s", listImageSpec)
+ }
+ fmt.Printf("%s\n", updatedListID)
+ return nil
+}