From 444142c7c10fb5068e1786bcef37599c78177fd1 Mon Sep 17 00:00:00 2001 From: Miloslav Trmač Date: Sat, 28 Jul 2018 07:26:14 +0200 Subject: Remove the signaturePolicyPath parameter from getCopyOptions and DRO.GetSystemContext MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use the parent types.SystemContext data instead. Should not change behavior. Signed-off-by: Miloslav Trmač Closes: #1176 Approved by: rhatdan --- libpod/image/docker_registry_options.go | 9 +++++---- libpod/image/image.go | 4 ++-- libpod/image/pull.go | 2 +- libpod/image/utils.go | 6 +++--- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/libpod/image/docker_registry_options.go b/libpod/image/docker_registry_options.go index e6eea01dd..34abdba45 100644 --- a/libpod/image/docker_registry_options.go +++ b/libpod/image/docker_registry_options.go @@ -23,11 +23,9 @@ type DockerRegistryOptions struct { DockerInsecureSkipTLSVerify bool } -// GetSystemContext constructs a new system context from a parent context, the given signaturePolicy path, and the -// values in the DockerRegistryOptions -func (o DockerRegistryOptions) GetSystemContext(parent *types.SystemContext, signaturePolicyPath, authFile string, forceCompress bool, additionalDockerArchiveTags []reference.NamedTagged) *types.SystemContext { +// GetSystemContext constructs a new system context from a parent context. the values in the DockerRegistryOptions, and other parameters. +func (o DockerRegistryOptions) GetSystemContext(parent *types.SystemContext, authFile string, forceCompress bool, additionalDockerArchiveTags []reference.NamedTagged) *types.SystemContext { sc := &types.SystemContext{ - SignaturePolicyPath: signaturePolicyPath, DockerAuthConfig: o.DockerRegistryCreds, DockerCertPath: o.DockerCertPath, DockerInsecureSkipTLSVerify: o.DockerInsecureSkipTLSVerify, @@ -35,6 +33,9 @@ func (o DockerRegistryOptions) GetSystemContext(parent *types.SystemContext, sig DirForceCompress: forceCompress, DockerArchiveAdditionalTags: additionalDockerArchiveTags, } + if parent != nil { + sc.SignaturePolicyPath = parent.SignaturePolicyPath + } return sc } diff --git a/libpod/image/image.go b/libpod/image/image.go index 47a91cc7f..293f0b944 100644 --- a/libpod/image/image.go +++ b/libpod/image/image.go @@ -551,7 +551,7 @@ func (i *Image) PushImageToReference(ctx context.Context, dest types.ImageRefere if err != nil { return err } - copyOptions := getCopyOptions(sc, writer, signaturePolicyPath, nil, dockerRegistryOptions, signingOptions, authFile, manifestMIMEType, forceCompress, additionalDockerArchiveTags) + copyOptions := getCopyOptions(sc, writer, nil, dockerRegistryOptions, signingOptions, authFile, manifestMIMEType, forceCompress, additionalDockerArchiveTags) if dest.Transport().Name() == DockerTransport { imgRef := dest.DockerReference() if imgRef == nil { // This should never happen; such references can’t be created. @@ -906,7 +906,7 @@ func (ir *Runtime) Import(ctx context.Context, path, reference string, writer io return nil, err } defer policyContext.Destroy() - copyOptions := getCopyOptions(sc, writer, "", nil, nil, signingOptions, "", "", false, nil) + copyOptions := getCopyOptions(sc, writer, nil, nil, signingOptions, "", "", false, nil) dest, err := is.Transport.ParseStoreReference(ir.store, reference) if err != nil { errors.Wrapf(err, "error getting image reference for %q", reference) diff --git a/libpod/image/pull.go b/libpod/image/pull.go index 1334761e6..55e58df76 100644 --- a/libpod/image/pull.go +++ b/libpod/image/pull.go @@ -232,7 +232,7 @@ func (ir *Runtime) pullImage(ctx context.Context, inputName string, writer io.Wr } var images []string for _, imageInfo := range goal.refPairs { - copyOptions := getCopyOptions(sc, writer, signaturePolicyPath, dockerOptions, nil, signingOptions, authfile, "", false, nil) + copyOptions := getCopyOptions(sc, writer, dockerOptions, nil, signingOptions, authfile, "", false, nil) if imageInfo.srcRef.Transport().Name() == DockerTransport { imgRef := imageInfo.srcRef.DockerReference() if imgRef == nil { // This should never happen; such references can’t be created. diff --git a/libpod/image/utils.go b/libpod/image/utils.go index f005c3795..27c386efd 100644 --- a/libpod/image/utils.go +++ b/libpod/image/utils.go @@ -43,15 +43,15 @@ func findImageInRepotags(search imageParts, images []*Image) (*storage.Image, er } // getCopyOptions constructs a new containers/image/copy.Options{} struct from the given parameters, inheriting some from sc. -func getCopyOptions(sc *types.SystemContext, reportWriter io.Writer, signaturePolicyPath string, srcDockerRegistry, destDockerRegistry *DockerRegistryOptions, signing SigningOptions, authFile, manifestType string, forceCompress bool, additionalDockerArchiveTags []reference.NamedTagged) *cp.Options { +func getCopyOptions(sc *types.SystemContext, reportWriter io.Writer, srcDockerRegistry, destDockerRegistry *DockerRegistryOptions, signing SigningOptions, authFile, manifestType string, forceCompress bool, additionalDockerArchiveTags []reference.NamedTagged) *cp.Options { if srcDockerRegistry == nil { srcDockerRegistry = &DockerRegistryOptions{} } if destDockerRegistry == nil { destDockerRegistry = &DockerRegistryOptions{} } - srcContext := srcDockerRegistry.GetSystemContext(sc, signaturePolicyPath, authFile, forceCompress, additionalDockerArchiveTags) - destContext := destDockerRegistry.GetSystemContext(sc, signaturePolicyPath, authFile, forceCompress, additionalDockerArchiveTags) + srcContext := srcDockerRegistry.GetSystemContext(sc, authFile, forceCompress, additionalDockerArchiveTags) + destContext := destDockerRegistry.GetSystemContext(sc, authFile, forceCompress, additionalDockerArchiveTags) return &cp.Options{ RemoveSignatures: signing.RemoveSignatures, SignBy: signing.SignBy, -- cgit v1.2.3-54-g00ecf