Skip to content

Commit

Permalink
Remove an imageName != "" conditional
Browse files Browse the repository at this point in the history
In both callers, this value is always set; and it makes
no clear sense to conditionalize on imageName when the
conditional code does not use imageName at all.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
  • Loading branch information
mtrmac committed Nov 20, 2023
1 parent ff80e40 commit 1988029
Showing 1 changed file with 18 additions and 21 deletions.
39 changes: 18 additions & 21 deletions libpod/storage.go
Expand Up @@ -69,28 +69,25 @@ 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 string, options storage.ContainerOptions) (_ ContainerInfo, retErr error) {
var imageConfig *v1.Image
if imageName != "" {
if containerName == "" {
return ContainerInfo{}, define.ErrEmptyID
}
// Check if we have the specified image.
ref, err := istorage.Transport.NewStoreReference(r.store, nil, imageID)
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()
if containerName == "" {
return ContainerInfo{}, define.ErrEmptyID
}
// Check if we have the specified image.
ref, err := istorage.Transport.NewStoreReference(r.store, nil, imageID)
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
}

// Build metadata to store with the container.
Expand Down

0 comments on commit 1988029

Please sign in to comment.