mirror of
https://github.com/containers/podman.git
synced 2025-06-24 19:42:56 +08:00
Merge pull request #20726 from mtrmac/CreateContainerStorage
Clean up storageService.CreateContainerStorage
This commit is contained in:
@ -66,21 +66,17 @@ func (metadata *RuntimeContainerMetadata) SetMountLabel(mountLabel string) {
|
||||
metadata.MountLabel = mountLabel
|
||||
}
|
||||
|
||||
// CreateContainerStorage creates the storage end of things. We already have the container spec created
|
||||
// CreateContainerStorage creates the storage end of things. We already have the container spec created.
|
||||
// imageID and imageName must both be either empty or non-empty.
|
||||
// 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 string, options storage.ContainerOptions) (_ ContainerInfo, retErr error) {
|
||||
var imageConfig *v1.Image
|
||||
if imageName != "" {
|
||||
var ref types.ImageReference
|
||||
if imageID != "" {
|
||||
if containerName == "" {
|
||||
return ContainerInfo{}, define.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.ResolveReference(ref)
|
||||
ref, err := istorage.Transport.NewStoreReference(r.store, nil, imageID)
|
||||
if err != nil {
|
||||
return ContainerInfo{}, err
|
||||
}
|
||||
@ -96,12 +92,6 @@ func (r *storageService) CreateContainerStorage(ctx context.Context, systemConte
|
||||
if err != nil {
|
||||
return ContainerInfo{}, err
|
||||
}
|
||||
|
||||
// Update the image name and ID.
|
||||
if imageName == "" && len(img.Names) > 0 {
|
||||
imageName = img.Names[0]
|
||||
}
|
||||
imageID = img.ID
|
||||
}
|
||||
|
||||
// Build metadata to store with the container.
|
||||
|
Reference in New Issue
Block a user