From 24da27c3e9606994cc97821c9025565b5a4bf25d Mon Sep 17 00:00:00 2001 From: Miloslav Trmač Date: Fri, 27 Jul 2018 02:50:43 +0200 Subject: Use a switch instead of if/if else/.../else MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Should not change behavior. Signed-off-by: Miloslav Trmač Closes: #1176 Approved by: rhatdan --- libpod/image/pull.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'libpod/image') 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) } -- cgit v1.2.3-54-g00ecf