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 /libpod | |
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 'libpod')
-rw-r--r-- | libpod/common/common.go | 20 | ||||
-rw-r--r-- | libpod/common/docker_registry_options.go | 3 | ||||
-rw-r--r-- | libpod/runtime_img.go | 16 |
3 files changed, 23 insertions, 16 deletions
diff --git a/libpod/common/common.go b/libpod/common/common.go index 8a7fbcd5e..6af3cd232 100644 --- a/libpod/common/common.go +++ b/libpod/common/common.go @@ -16,31 +16,33 @@ var ( ) // GetCopyOptions constructs a new containers/image/copy.Options{} struct from the given parameters -func GetCopyOptions(reportWriter io.Writer, signaturePolicyPath string, srcDockerRegistry, destDockerRegistry *DockerRegistryOptions, signing SigningOptions, authFile string) *cp.Options { +func GetCopyOptions(reportWriter io.Writer, signaturePolicyPath string, srcDockerRegistry, destDockerRegistry *DockerRegistryOptions, signing SigningOptions, authFile, manifestType string, forceCompress bool) *cp.Options { if srcDockerRegistry == nil { srcDockerRegistry = &DockerRegistryOptions{} } if destDockerRegistry == nil { destDockerRegistry = &DockerRegistryOptions{} } - srcContext := srcDockerRegistry.GetSystemContext(signaturePolicyPath, authFile) - destContext := destDockerRegistry.GetSystemContext(signaturePolicyPath, authFile) + srcContext := srcDockerRegistry.GetSystemContext(signaturePolicyPath, authFile, forceCompress) + destContext := destDockerRegistry.GetSystemContext(signaturePolicyPath, authFile, forceCompress) return &cp.Options{ - RemoveSignatures: signing.RemoveSignatures, - SignBy: signing.SignBy, - ReportWriter: reportWriter, - SourceCtx: srcContext, - DestinationCtx: destContext, + RemoveSignatures: signing.RemoveSignatures, + SignBy: signing.SignBy, + ReportWriter: reportWriter, + SourceCtx: srcContext, + DestinationCtx: destContext, + ForceManifestMIMEType: manifestType, } } // GetSystemContext Constructs a new containers/image/types.SystemContext{} struct from the given signaturePolicy path -func GetSystemContext(signaturePolicyPath, authFilePath string) *types.SystemContext { +func GetSystemContext(signaturePolicyPath, authFilePath string, forceCompress bool) *types.SystemContext { sc := &types.SystemContext{} if signaturePolicyPath != "" { sc.SignaturePolicyPath = signaturePolicyPath } sc.AuthFilePath = authFilePath + sc.DirForceCompress = forceCompress return sc } diff --git a/libpod/common/docker_registry_options.go b/libpod/common/docker_registry_options.go index 24fa5c03e..f79ae0c54 100644 --- a/libpod/common/docker_registry_options.go +++ b/libpod/common/docker_registry_options.go @@ -22,13 +22,14 @@ type DockerRegistryOptions struct { // GetSystemContext constructs a new system context from the given signaturePolicy path and the // values in the DockerRegistryOptions -func (o DockerRegistryOptions) GetSystemContext(signaturePolicyPath, authFile string) *types.SystemContext { +func (o DockerRegistryOptions) GetSystemContext(signaturePolicyPath, authFile string, forceCompress bool) *types.SystemContext { sc := &types.SystemContext{ SignaturePolicyPath: signaturePolicyPath, DockerAuthConfig: o.DockerRegistryCreds, DockerCertPath: o.DockerCertPath, DockerInsecureSkipTLSVerify: o.DockerInsecureSkipTLSVerify, AuthFilePath: authFile, + DirForceCompress: forceCompress, } return sc } diff --git a/libpod/runtime_img.go b/libpod/runtime_img.go index d5da35c42..6107c2fdb 100644 --- a/libpod/runtime_img.go +++ b/libpod/runtime_img.go @@ -78,6 +78,10 @@ type CopyOptions struct { Reference string // ImageConfig is the Image spec for the image created when a tar archive is imported ImageConfig ociv1.Image + // ManifestMIMEType is the manifest type of the image when saving to a directory + ManifestMIMEType string + // ForceCompress compresses the image layers when saving to a directory using the dir transport if true + ForceCompress bool } // Image API @@ -643,7 +647,7 @@ func (r *Runtime) PullImage(imgName string, options CopyOptions) (string, error) signaturePolicyPath = options.SignaturePolicyPath } - sc := common.GetSystemContext(signaturePolicyPath, options.AuthFile) + sc := common.GetSystemContext(signaturePolicyPath, options.AuthFile, false) srcRef, err := alltransports.ParseImageName(imgName) if err != nil { @@ -664,7 +668,7 @@ func (r *Runtime) PullImage(imgName string, options CopyOptions) (string, error) } defer policyContext.Destroy() - copyOptions := common.GetCopyOptions(options.Writer, signaturePolicyPath, &options.DockerRegistryOptions, nil, options.SigningOptions, options.AuthFile) + copyOptions := common.GetCopyOptions(options.Writer, signaturePolicyPath, &options.DockerRegistryOptions, nil, options.SigningOptions, options.AuthFile, "", false) for _, imageInfo := range pullStructs { // Print the following statement only when pulling from a docker or atomic registry @@ -721,7 +725,7 @@ func (r *Runtime) PushImage(source string, destination string, options CopyOptio signaturePolicyPath = options.SignaturePolicyPath } - sc := common.GetSystemContext(signaturePolicyPath, options.AuthFile) + sc := common.GetSystemContext(signaturePolicyPath, options.AuthFile, options.ForceCompress) policyContext, err := getPolicyContext(sc) if err != nil { @@ -735,7 +739,7 @@ func (r *Runtime) PushImage(source string, destination string, options CopyOptio return errors.Wrapf(err, "error getting source imageReference for %q", source) } - copyOptions := common.GetCopyOptions(options.Writer, signaturePolicyPath, nil, &options.DockerRegistryOptions, options.SigningOptions, options.AuthFile) + copyOptions := common.GetCopyOptions(options.Writer, signaturePolicyPath, nil, &options.DockerRegistryOptions, options.SigningOptions, options.AuthFile, options.ManifestMIMEType, options.ForceCompress) // Copy the image to the remote destination err = cp.Image(policyContext, dest, src, copyOptions) @@ -1004,7 +1008,7 @@ func (r *Runtime) ImportImage(path string, options CopyOptions) error { } var reference = options.Reference - sc := common.GetSystemContext("", "") + sc := common.GetSystemContext("", "", false) // if reference not given, get the image digest if reference == "" { @@ -1020,7 +1024,7 @@ func (r *Runtime) ImportImage(path string, options CopyOptions) error { } defer policyContext.Destroy() - copyOptions := common.GetCopyOptions(os.Stdout, "", nil, nil, common.SigningOptions{}, "") + copyOptions := common.GetCopyOptions(os.Stdout, "", nil, nil, common.SigningOptions{}, "", "", false) dest, err := is.Transport.ParseStoreReference(r.store, reference) if err != nil { |