From 872c669241333110b2dbe2dffe20591531a6f556 Mon Sep 17 00:00:00 2001 From: ashpect Date: Sun, 20 Aug 2023 20:55:06 +0530 Subject: [PATCH 1/2] Fix #544 Signed-off-by: ashpect --- pkg/imgpkg/cmd/pull.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/imgpkg/cmd/pull.go b/pkg/imgpkg/cmd/pull.go index 97cde176b..63c3e0d07 100644 --- a/pkg/imgpkg/cmd/pull.go +++ b/pkg/imgpkg/cmd/pull.go @@ -130,5 +130,9 @@ func (po *PullOptions) validate() error { if po.BundleRecursiveFlags.Recursive && len(po.ImageFlags.Image) > 0 { return fmt.Errorf("Cannot use --recursive (-r) flag when pulling a bundle") } + + if !po.ImageIsBundleCheck && len(po.BundleFlags.Bundle) != 0 { + return fmt.Errorf("Cannot set --image-is-bundle-check while using -b flag") + } return nil } From adb49bbf2eed6dbe9c530f7dba3496add2885fa2 Mon Sep 17 00:00:00 2001 From: ashpect Date: Fri, 25 Aug 2023 00:57:31 +0530 Subject: [PATCH 2/2] add test for fix for #544 Signed-off-by: ashpect --- test/e2e/pull_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/e2e/pull_test.go b/test/e2e/pull_test.go index c106bb552..43ff1a9c7 100644 --- a/test/e2e/pull_test.go +++ b/test/e2e/pull_test.go @@ -262,6 +262,19 @@ func TestPullImageOfBundle(t *testing.T) { assert.Contains(t, out.String(), "Expected bundle flag when pulling a bundle (hint: Use -b instead of -i for bundles)") }) + t.Run("when --image-is-bundle-check=false is provided while using the -b flag it fails", func(t *testing.T) { + pullDir := env.Assets.CreateTempFolder("pull-bundle-image") + out := bytes.NewBufferString("") + _, err := imgpkg.RunWithOpts([]string{"pull", "--tty", "-b", randomBundle.RefDigest, "-o", pullDir, "--image-is-bundle-check=false"}, helpers.RunOpts{ + AllowError: true, + StderrWriter: out, + StdoutWriter: out, + }) + + require.Error(t, err) + assert.Contains(t, out.String(), "Cannot set --image-is-bundle-check while using -b flag") + }) + t.Run("when --image-is-bundle-check=false is provided downloads the OCI Image of the bundle", func(t *testing.T) { pullDir := env.Assets.CreateTempFolder("pull-bundle-image") imgpkg.RunWithOpts([]string{"pull", "--tty", "-i", randomBundle.RefDigest, "-o", pullDir, "--image-is-bundle-check=false"}, helpers.RunOpts{})