From dce4d45006a5460b788eb1f25b7bf3d57e954859 Mon Sep 17 00:00:00 2001 From: ashpect Date: Fri, 11 Aug 2023 13:50:04 +0530 Subject: [PATCH] Fix issue 544 --- pkg/imgpkg/cmd/pull.go | 6 ++++-- pkg/imgpkg/v1/pull.go | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pkg/imgpkg/cmd/pull.go b/pkg/imgpkg/cmd/pull.go index 97cde176b..2bfd7fc71 100644 --- a/pkg/imgpkg/cmd/pull.go +++ b/pkg/imgpkg/cmd/pull.go @@ -91,14 +91,16 @@ func (po *PullOptions) Run() error { } if errors.Is(err, &v1.ErrIsBundle{}) { - if len(po.ImageFlags.Image) == 0 { + if pullOpts.IsBundle { if po.ImageIsBundleCheck { return fmt.Errorf("Expected bundle flag when pulling a bundle (hint: Use -b instead of -i for bundles)") + } else { + return fmt.Errorf("Expected image flag when wanting to pull a bundle as OCI image (hint: Use -i instead of -b)") } } else { return fmt.Errorf("Expected bundle flag when pulling a bundle (hint: Use -b instead of -i for bundles)") } - } else if len(po.ImageFlags.Image) == 0 && errors.Is(err, &v1.ErrIsNotBundle{}) { + } else if pullOpts.IsBundle && errors.Is(err, &v1.ErrIsNotBundle{}) { return fmt.Errorf("Expected bundle image but found plain image (hint: Did you use -i instead of -b?)") } diff --git a/pkg/imgpkg/v1/pull.go b/pkg/imgpkg/v1/pull.go index 7a8f4ba0c..14e729191 100644 --- a/pkg/imgpkg/v1/pull.go +++ b/pkg/imgpkg/v1/pull.go @@ -102,7 +102,10 @@ func PullWithRegistry(imageRef string, outputPath string, pullOptions PullOpts, } switch { - case isBundle && pullOptions.AsImage: // Trying to pull the OCI Image of a Bundle + case isBundle && pullOptions.AsImage && pullOptions.IsBundle: // Trying to pull a Bundle as an OCI Image with flag -b + return PullStatus{}, &ErrIsBundle{} + + case isBundle && pullOptions.AsImage && !pullOptions.IsBundle: // Trying to pull the OCI Image of a Bundle with flag i st, err := pullImage(imageRef, outputPath, pullOptions, reg) if err != nil { return PullStatus{}, err