Skip to content

Commit

Permalink
Merge pull request #563 from ashpect/fix
Browse files Browse the repository at this point in the history
Error when --image-is-bundle-check flag is set to false while using -b flag
  • Loading branch information
joaopapereira authored Aug 25, 2023
2 parents f97a0e4 + adb49bb commit c3b6970
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/imgpkg/cmd/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
13 changes: 13 additions & 0 deletions test/e2e/pull_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{})
Expand Down

0 comments on commit c3b6970

Please sign in to comment.