diff --git a/cmd/mindthegap/importcmd/imagebundle/image_bundle.go b/cmd/mindthegap/importcmd/imagebundle/image_bundle.go index 63eadaae..265c1399 100644 --- a/cmd/mindthegap/importcmd/imagebundle/image_bundle.go +++ b/cmd/mindthegap/importcmd/imagebundle/image_bundle.go @@ -5,6 +5,7 @@ package imagebundle import ( "context" + "errors" "fmt" "os" "path/filepath" @@ -67,6 +68,11 @@ func NewCommand(out output.Output) *cobra.Command { if err != nil { return err } + if cfg == nil { + return errors.New( + "no bundle configuration(s) found: please check that you have specified valid air-gapped bundle(s)", + ) + } out.StartOperation("Starting temporary Docker registry") reg, err := registry.NewRegistry( diff --git a/test/e2e/imagebundle/import_bundle_test.go b/test/e2e/imagebundle/import_bundle_test.go index 5fc7daa8..6b41ed84 100644 --- a/test/e2e/imagebundle/import_bundle_test.go +++ b/test/e2e/imagebundle/import_bundle_test.go @@ -146,4 +146,21 @@ var _ = Describe("Import Bundle", Label("import"), Serial, func() { cmd.Execute(), ).To(MatchError(fmt.Sprintf("did find any matching files for %q", "non-existent-file"))) }) + + It("Bundle file exists, is a tarball, but not an image bundle", func() { + tmpDir := GinkgoT().TempDir() + nonBundleFile := filepath.Join(tmpDir, "image-bundle.tar") + + Expect(archive.ArchiveDirectory("testdata", nonBundleFile)).To(Succeed()) + + cmd := helpers.NewCommand(GinkgoT(), importimagebundle.NewCommand) + + cmd.SetArgs([]string{ + "--image-bundle", nonBundleFile, + }) + + Expect( + cmd.Execute(), + ).To(MatchError("no bundle configuration(s) found: please check that you have specified valid air-gapped bundle(s)")) + }) })