diff options
author | umohnani8 <umohnani@redhat.com> | 2017-12-12 13:33:10 -0500 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2017-12-14 18:37:17 +0000 |
commit | 1e7d880b561318aa2ad89d7583addad1904e5a36 (patch) | |
tree | 7773e3d409c410ae9bb3a210e106dddc28e302b5 /cmd | |
parent | bf0d35904752c2ac5c607c4a82237f074c862744 (diff) | |
download | podman-1e7d880b561318aa2ad89d7583addad1904e5a36.tar.gz podman-1e7d880b561318aa2ad89d7583addad1904e5a36.tar.bz2 podman-1e7d880b561318aa2ad89d7583addad1904e5a36.zip |
Add manifest type conversion to kpod push
User can select from 3 manifest types: oci, v2s1, or v2s2
e.g kpod push --format v2s2 alpine dir:my-directory
Added "compress" flag to enable compression when true
Signed-off-by: umohnani8 <umohnani@redhat.com>
Closes: #126
Approved by: rhatdan
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/kpod/login.go | 2 | ||||
-rw-r--r-- | cmd/kpod/logout.go | 2 | ||||
-rw-r--r-- | cmd/kpod/push.go | 43 |
3 files changed, 41 insertions, 6 deletions
diff --git a/cmd/kpod/login.go b/cmd/kpod/login.go index df74a2fdf..8984d069c 100644 --- a/cmd/kpod/login.go +++ b/cmd/kpod/login.go @@ -56,7 +56,7 @@ func loginCmd(c *cli.Context) error { server = args[0] } - sc := common.GetSystemContext("", c.String("authfile")) + sc := common.GetSystemContext("", c.String("authfile"), false) // username of user logged in to server (if one exists) userFromAuthFile := config.GetUserLoggedIn(sc, server) diff --git a/cmd/kpod/logout.go b/cmd/kpod/logout.go index 9d1d52e32..cae8ddfb2 100644 --- a/cmd/kpod/logout.go +++ b/cmd/kpod/logout.go @@ -46,7 +46,7 @@ func logoutCmd(c *cli.Context) error { server = args[0] } - sc := common.GetSystemContext("", c.String("authfile")) + sc := common.GetSystemContext("", c.String("authfile"), false) if c.Bool("all") { if err := config.RemoveAllAuthentication(sc); err != nil { diff --git a/cmd/kpod/push.go b/cmd/kpod/push.go index 4f1218a08..d3d42e0ee 100644 --- a/cmd/kpod/push.go +++ b/cmd/kpod/push.go @@ -4,9 +4,12 @@ import ( "fmt" "io" "os" + "strings" + "github.com/containers/image/manifest" "github.com/containers/image/types" "github.com/containers/storage/pkg/archive" + imgspecv1 "github.com/opencontainers/image-spec/specs-go/v1" "github.com/pkg/errors" "github.com/projectatomic/libpod/libpod" "github.com/projectatomic/libpod/libpod/common" @@ -29,6 +32,14 @@ var ( Name: "cert-dir", Usage: "`pathname` of a directory containing TLS certificates and keys", }, + cli.BoolFlag{ + Name: "compress", + Usage: "compress tarball image layers when pushing to a directory using the 'dir' transport. (default is same compression type as source)", + }, + cli.StringFlag{ + Name: "format, f", + Usage: "manifest type (oci, v2s1, or v2s2) to use when pushing an image using the 'dir:' transport (default is manifest type of source)", + }, cli.BoolTFlag{ Name: "tls-verify", Usage: "require HTTPS and verify certificates when contacting registries (default: true)", @@ -75,8 +86,16 @@ func pushCmd(c *cli.Context) error { if err := validateFlags(c, pushFlags); err != nil { return err } - srcName := c.Args().Get(0) - destName := c.Args().Get(1) + srcName := args[0] + destName := args[1] + + // --compress and --format can only be used for the "dir" transport + splitArg := strings.SplitN(destName, ":", 2) + if c.IsSet("compress") || c.IsSet("format") { + if splitArg[0] != libpod.DirTransport { + return errors.Errorf("--compress and --format can be set only when pushing to a directory using the 'dir' transport") + } + } registryCredsString := c.String("creds") certPath := c.String("cert-dir") @@ -112,6 +131,20 @@ func pushCmd(c *cli.Context) error { writer = os.Stdout } + var manifestType string + if c.IsSet("format") { + switch c.String("format") { + case "oci": + manifestType = imgspecv1.MediaTypeImageManifest + case "v2s1": + manifestType = manifest.DockerV2Schema1SignedMediaType + case "v2s2", "docker": + manifestType = manifest.DockerV2Schema2MediaType + default: + return fmt.Errorf("unknown format %q. Choose on of the supported formats: 'oci', 'v2s1', or 'v2s2'", c.String("format")) + } + } + options := libpod.CopyOptions{ Compression: archive.Uncompressed, SignaturePolicyPath: c.String("signature-policy"), @@ -124,8 +157,10 @@ func pushCmd(c *cli.Context) error { RemoveSignatures: removeSignatures, SignBy: signBy, }, - AuthFile: c.String("authfile"), - Writer: writer, + AuthFile: c.String("authfile"), + Writer: writer, + ManifestMIMEType: manifestType, + ForceCompress: c.Bool("compress"), } return runtime.PushImage(srcName, destName, options) |