summaryrefslogtreecommitdiff
path: root/libpod/image/utils.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-03-08 15:45:52 -0600
committerAtomic Bot <atomic-devel@projectatomic.io>2018-03-14 20:21:31 +0000
commitb85b217f55993955da9ad0cae7735747b2f24390 (patch)
tree3e633600e50bf3bedc9bdc59abe789fa01f55601 /libpod/image/utils.go
parentbc358eb396aa87f3122f0449945efc03ed64bfd2 (diff)
downloadpodman-b85b217f55993955da9ad0cae7735747b2f24390.tar.gz
podman-b85b217f55993955da9ad0cae7735747b2f24390.tar.bz2
podman-b85b217f55993955da9ad0cae7735747b2f24390.zip
Stage3 Image Library
This represents the stage3 implementation for the image library. At this point, we are moving the image-centric functions to pkg/image including migration of args and object-oriented references. This is a not a one-for-one migration of funcs and some funcs will need to continue to reside in runtime_img as they are overly specific to libpod and probably not useful to others. Signed-off-by: baude <bbaude@redhat.com> Closes: #484 Approved by: baude
Diffstat (limited to 'libpod/image/utils.go')
-rw-r--r--libpod/image/utils.go52
1 files changed, 49 insertions, 3 deletions
diff --git a/libpod/image/utils.go b/libpod/image/utils.go
index f312c8e4d..adc795e3a 100644
--- a/libpod/image/utils.go
+++ b/libpod/image/utils.go
@@ -1,9 +1,16 @@
package image
import (
+ "io"
+
+ cp "github.com/containers/image/copy"
"github.com/containers/image/docker/reference"
"github.com/containers/storage"
"github.com/pkg/errors"
+
+ "github.com/containers/image/signature"
+ "github.com/containers/image/types"
+ "strings"
)
func getTags(nameInput string) (reference.NamedTagged, bool, error) {
@@ -18,17 +25,17 @@ func getTags(nameInput string) (reference.NamedTagged, bool, error) {
// findImageInRepotags takes an imageParts struct and searches images' repotags for
// a match on name:tag
-func findImageInRepotags(search imageParts, images []*storage.Image) (*storage.Image, error) {
+func findImageInRepotags(search imageParts, images []*Image) (*storage.Image, error) {
var results []*storage.Image
for _, image := range images {
- for _, name := range image.Names {
+ for _, name := range image.Names() {
d, err := decompose(name)
// if we get an error, ignore and keep going
if err != nil {
continue
}
if d.name == search.name && d.tag == search.tag {
- results = append(results, image)
+ results = append(results, image.image)
break
}
}
@@ -40,3 +47,42 @@ func findImageInRepotags(search imageParts, images []*storage.Image) (*storage.I
}
return results[0], nil
}
+
+// 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, manifestType string, forceCompress bool) *cp.Options {
+ if srcDockerRegistry == nil {
+ srcDockerRegistry = &DockerRegistryOptions{}
+ }
+ if destDockerRegistry == nil {
+ destDockerRegistry = &DockerRegistryOptions{}
+ }
+ 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,
+ ForceManifestMIMEType: manifestType,
+ }
+}
+
+// getPolicyContext sets up, intializes and returns a new context for the specified policy
+func getPolicyContext(ctx *types.SystemContext) (*signature.PolicyContext, error) {
+ policy, err := signature.DefaultPolicy(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ policyContext, err := signature.NewPolicyContext(policy)
+ if err != nil {
+ return nil, err
+ }
+ return policyContext, nil
+}
+
+// hasTransport determines if the image string contains '://', returns bool
+func hasTransport(image string) bool {
+ return strings.Contains(image, "://")
+}