summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2018-07-27 02:50:43 +0200
committerAtomic Bot <atomic-devel@projectatomic.io>2018-08-01 18:22:58 +0000
commit24da27c3e9606994cc97821c9025565b5a4bf25d (patch)
tree6c03184a8917f7970827b4ddd7d127f28a4e4048 /libpod
parent7c37b25b4d946855ef4e206f4b017a61f393b942 (diff)
downloadpodman-24da27c3e9606994cc97821c9025565b5a4bf25d.tar.gz
podman-24da27c3e9606994cc97821c9025565b5a4bf25d.tar.bz2
podman-24da27c3e9606994cc97821c9025565b5a4bf25d.zip
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
Diffstat (limited to 'libpod')
-rw-r--r--libpod/image/pull.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/libpod/image/pull.go b/libpod/image/pull.go
index 97bd2fd7e..49a834391 100644
--- a/libpod/image/pull.go
+++ b/libpod/image/pull.go
@@ -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)
}