summaryrefslogtreecommitdiff
path: root/libpod/storage.go
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2018-04-26 17:21:48 +0200
committerAtomic Bot <atomic-devel@projectatomic.io>2018-06-15 14:53:18 +0000
commit7bdfb4f9b361aca4f4f3337907feb3ca414d36e4 (patch)
treeaff63093af49df79820e72a5a68f07e6fe70b863 /libpod/storage.go
parent4b4de5dc21f034f5f678114dbf6d51f047c96a59 (diff)
downloadpodman-7bdfb4f9b361aca4f4f3337907feb3ca414d36e4.tar.gz
podman-7bdfb4f9b361aca4f4f3337907feb3ca414d36e4.tar.bz2
podman-7bdfb4f9b361aca4f4f3337907feb3ca414d36e4.zip
podman: accept option --rootfs to use exploded images
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> Closes: #871 Approved by: mheon
Diffstat (limited to 'libpod/storage.go')
-rw-r--r--libpod/storage.go64
1 files changed, 32 insertions, 32 deletions
diff --git a/libpod/storage.go b/libpod/storage.go
index c0391326c..c5581d53c 100644
--- a/libpod/storage.go
+++ b/libpod/storage.go
@@ -60,40 +60,40 @@ func (metadata *RuntimeContainerMetadata) SetMountLabel(mountLabel string) {
// CreateContainerStorage creates the storage end of things. We already have the container spec created
// TO-DO We should be passing in an Image object in the future.
func (r *storageService) CreateContainerStorage(ctx context.Context, systemContext *types.SystemContext, imageName, imageID, containerName, containerID, mountLabel string, options *storage.ContainerOptions) (ContainerInfo, error) {
- var ref types.ImageReference
- if imageName == "" && imageID == "" {
- return ContainerInfo{}, ErrEmptyID
- }
- if containerName == "" {
- return ContainerInfo{}, ErrEmptyID
- }
- // Check if we have the specified image.
- ref, err := istorage.Transport.ParseStoreReference(r.store, imageID)
- if err != nil {
- return ContainerInfo{}, err
- }
- img, err := istorage.Transport.GetStoreImage(r.store, ref)
- if err != nil {
- return ContainerInfo{}, err
- }
- // Pull out a copy of the image's configuration.
- image, err := ref.NewImage(ctx, systemContext)
- if err != nil {
- return ContainerInfo{}, err
- }
- defer image.Close()
+ var imageConfig *v1.Image
+ if imageName != "" {
+ var ref types.ImageReference
+ if containerName == "" {
+ return ContainerInfo{}, ErrEmptyID
+ }
+ // Check if we have the specified image.
+ ref, err := istorage.Transport.ParseStoreReference(r.store, imageID)
+ if err != nil {
+ return ContainerInfo{}, err
+ }
+ img, err := istorage.Transport.GetStoreImage(r.store, ref)
+ if err != nil {
+ return ContainerInfo{}, err
+ }
+ // Pull out a copy of the image's configuration.
+ image, err := ref.NewImage(ctx, systemContext)
+ if err != nil {
+ return ContainerInfo{}, err
+ }
+ defer image.Close()
- // Get OCI configuration of image
- imageConfig, err := image.OCIConfig(ctx)
- if err != nil {
- return ContainerInfo{}, err
- }
+ // Get OCI configuration of image
+ imageConfig, err = image.OCIConfig(ctx)
+ if err != nil {
+ return ContainerInfo{}, err
+ }
- // Update the image name and ID.
- if imageName == "" && len(img.Names) > 0 {
- imageName = img.Names[0]
+ // Update the image name and ID.
+ if imageName == "" && len(img.Names) > 0 {
+ imageName = img.Names[0]
+ }
+ imageID = img.ID
}
- imageID = img.ID
// Build metadata to store with the container.
metadata := RuntimeContainerMetadata{
@@ -119,7 +119,7 @@ func (r *storageService) CreateContainerStorage(ctx context.Context, systemConte
},
}
}
- container, err := r.store.CreateContainer(containerID, names, img.ID, "", string(mdata), options)
+ container, err := r.store.CreateContainer(containerID, names, imageID, "", string(mdata), options)
if err != nil {
logrus.Debugf("failed to create container %s(%s): %v", metadata.ContainerName, containerID, err)