mirror of
https://github.com/containers/podman.git
synced 2025-07-24 07:58:04 +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
|
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.
|
// 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) {
|
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
|
var imageConfig *v1.Image
|
||||||
if imageName != "" {
|
if imageID != "" {
|
||||||
var ref types.ImageReference
|
|
||||||
if containerName == "" {
|
if containerName == "" {
|
||||||
return ContainerInfo{}, define.ErrEmptyID
|
return ContainerInfo{}, define.ErrEmptyID
|
||||||
}
|
}
|
||||||
// Check if we have the specified image.
|
// Check if we have the specified image.
|
||||||
ref, err := istorage.Transport.ParseStoreReference(r.store, imageID)
|
ref, err := istorage.Transport.NewStoreReference(r.store, nil, imageID)
|
||||||
if err != nil {
|
|
||||||
return ContainerInfo{}, err
|
|
||||||
}
|
|
||||||
_, img, err := istorage.ResolveReference(ref)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ContainerInfo{}, err
|
return ContainerInfo{}, err
|
||||||
}
|
}
|
||||||
@ -96,12 +92,6 @@ func (r *storageService) CreateContainerStorage(ctx context.Context, systemConte
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return ContainerInfo{}, err
|
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.
|
// Build metadata to store with the container.
|
||||||
|
Reference in New Issue
Block a user