diff options
Diffstat (limited to 'pkg/varlinkapi/images.go')
-rw-r--r-- | pkg/varlinkapi/images.go | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/pkg/varlinkapi/images.go b/pkg/varlinkapi/images.go index da19483b3..7953c1fc6 100644 --- a/pkg/varlinkapi/images.go +++ b/pkg/varlinkapi/images.go @@ -10,18 +10,19 @@ import ( "time" "github.com/containers/image/docker" + "github.com/containers/image/manifest" "github.com/containers/image/types" + "github.com/containers/libpod/cmd/podman/varlink" + "github.com/containers/libpod/libpod" + "github.com/containers/libpod/libpod/image" + sysreg "github.com/containers/libpod/pkg/registries" + "github.com/containers/libpod/pkg/util" "github.com/docker/go-units" "github.com/opencontainers/image-spec/specs-go/v1" "github.com/opencontainers/runtime-spec/specs-go" "github.com/pkg/errors" "github.com/projectatomic/buildah" "github.com/projectatomic/buildah/imagebuildah" - "github.com/projectatomic/libpod/cmd/podman/varlink" - "github.com/projectatomic/libpod/libpod" - "github.com/projectatomic/libpod/libpod/image" - sysreg "github.com/projectatomic/libpod/pkg/registries" - "github.com/projectatomic/libpod/pkg/util" ) // ListImages lists all the images in the store @@ -126,18 +127,17 @@ func (i *LibpodAPI) BuildImage(call iopodman.VarlinkCall, config iopodman.BuildI if config.Pull_always { pullPolicy = imagebuildah.PullAlways } - - format := "oci" + manifestType := "oci" if config.Image_format != "" { - format = config.Image_format + manifestType = config.Image_format } - if strings.HasPrefix(format, "oci") { - format = imagebuildah.OCIv1ImageFormat - } else if strings.HasPrefix(format, "docker") { - format = imagebuildah.Dockerv2ImageFormat + if strings.HasPrefix(manifestType, "oci") { + manifestType = imagebuildah.OCIv1ImageFormat + } else if strings.HasPrefix(manifestType, "docker") { + manifestType = imagebuildah.Dockerv2ImageFormat } else { - return call.ReplyErrorOccurred(fmt.Sprintf("unrecognized image type %q", format)) + return call.ReplyErrorOccurred(fmt.Sprintf("unrecognized image type %q", manifestType)) } if config.Memory != "" { @@ -187,7 +187,7 @@ func (i *LibpodAPI) BuildImage(call iopodman.VarlinkCall, config iopodman.BuildI AdditionalTags: config.Tags, //Runtime: runtime. //RuntimeArgs: , - OutputFormat: format, + OutputFormat: manifestType, SystemContext: &systemContext, CommonBuildOpts: commonOpts, Squash: config.Squash, @@ -413,17 +413,26 @@ func (i *LibpodAPI) DeleteUnusedImages(call iopodman.VarlinkCall) error { } // Commit ... -func (i *LibpodAPI) Commit(call iopodman.VarlinkCall, name, imageName string, changes []string, author, message string, pause bool) error { +func (i *LibpodAPI) Commit(call iopodman.VarlinkCall, name, imageName string, changes []string, author, message string, pause bool, manifestType string) error { ctr, err := i.Runtime.LookupContainer(name) if err != nil { return call.ReplyContainerNotFound(name) } sc := image.GetSystemContext(i.Runtime.GetConfig().SignaturePolicyPath, "", false) + var mimeType string + switch manifestType { + case "oci", "": + mimeType = buildah.OCIv1ImageManifest + case "docker": + mimeType = manifest.DockerV2Schema2MediaType + default: + return call.ReplyErrorOccurred(fmt.Sprintf("unrecognized image format %q", manifestType)) + } coptions := buildah.CommitOptions{ SignaturePolicyPath: i.Runtime.GetConfig().SignaturePolicyPath, ReportWriter: nil, SystemContext: sc, - PreferredManifestType: buildah.OCIv1ImageManifest, + PreferredManifestType: mimeType, } options := libpod.ContainerCommitOptions{ CommitOptions: coptions, |