Use a switch instead of if/if else/.../else

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>

Closes: #1176
Approved by: rhatdan
This commit is contained in:
Miloslav Trmač
2018-07-27 02:50:43 +02:00
committed by Atomic Bot
parent 7c37b25b4d
commit 24da27c3e9

View File

@ -91,7 +91,8 @@ func refNamesFromImageReference(ctx context.Context, srcRef types.ImageReference
archFile := splitArr[len(splitArr)-1]
// supports pulling from docker-archive, oci, and registries
if srcRef.Transport().Name() == DockerArchive {
switch srcRef.Transport().Name() {
case DockerArchive:
tarSource, err := tarfile.NewSourceFromFile(archFile)
if err != nil {
return nil, err
@ -128,7 +129,7 @@ func refNamesFromImageReference(ctx context.Context, srcRef types.ImageReference
pullNames = append(pullNames, pullInfo)
}
}
} else if srcRef.Transport().Name() == OCIArchive {
case OCIArchive:
// retrieve the manifest from index.json to access the image name
manifest, err := ociarchive.LoadManifestDescriptor(srcRef)
if err != nil {
@ -148,7 +149,7 @@ func refNamesFromImageReference(ctx context.Context, srcRef types.ImageReference
}
pullInfo := getPullRefName(srcRef, dest)
pullNames = append(pullNames, pullInfo)
} else if srcRef.Transport().Name() == DirTransport {
case DirTransport:
// supports pull from a directory
image := splitArr[1]
// remove leading "/"
@ -159,7 +160,7 @@ func refNamesFromImageReference(ctx context.Context, srcRef types.ImageReference
}
pullInfo := getPullRefName(srcRef, image)
pullNames = append(pullNames, pullInfo)
} else {
default:
pullInfo := getPullRefName(srcRef, imgName)
pullNames = append(pullNames, pullInfo)
}