diff --git a/src/cmd/package.go b/src/cmd/package.go index 25e063cd2b..f8fac1ef19 100644 --- a/src/cmd/package.go +++ b/src/cmd/package.go @@ -208,8 +208,10 @@ var packageInspectCmd = &cobra.Command{ } defer os.RemoveAll(pkgPaths.Base) + cluster, _ := cluster.NewCluster() inspectOpt := packager2.ZarfInspectOptions{ PackagePaths: pkgPaths, + Cluster: cluster, ListImages: pkgConfig.InspectOpts.ListImages, ViewSBOM: pkgConfig.InspectOpts.ViewSBOM, SBOMOutputDir: pkgConfig.InspectOpts.SBOMOutputDir, diff --git a/src/internal/packager2/inspect.go b/src/internal/packager2/inspect.go index 6ab1b45116..17a39f7942 100644 --- a/src/internal/packager2/inspect.go +++ b/src/internal/packager2/inspect.go @@ -11,19 +11,17 @@ import ( "github.com/defenseunicorns/pkg/helpers/v2" "github.com/zarf-dev/zarf/src/api/v1alpha1" "github.com/zarf-dev/zarf/src/internal/packager/sbom" + "github.com/zarf-dev/zarf/src/pkg/cluster" "github.com/zarf-dev/zarf/src/pkg/layout" ) // ZarfInspectOptions tracks the user-defined preferences during a package inspection. type ZarfInspectOptions struct { - // PackagePaths - PackagePaths *layout.PackagePaths - // View SBOM contents while inspecting the package - ViewSBOM bool - // Location to output an SBOM into after package inspection + PackagePaths *layout.PackagePaths + Cluster *cluster.Cluster + ViewSBOM bool SBOMOutputDir string - // ListImages will list the images in the package - ListImages bool + ListImages bool } // Inspect list the contents of a package. diff --git a/src/pkg/packager/inspect.go b/src/pkg/packager/inspect.go index 7d6a49df4e..ae850498b8 100644 --- a/src/pkg/packager/inspect.go +++ b/src/pkg/packager/inspect.go @@ -24,7 +24,7 @@ func (p *Packager) Inspect(ctx context.Context) error { } p.cfg.Pkg = pkg - if p.cfg.InspectOpts.ListImages && len(p.cfg.Pkg.Components) > 0 { + if p.cfg.InspectOpts.ListImages { imageList := []string{} for _, component := range p.cfg.Pkg.Components { imageList = append(imageList, component.Images...) diff --git a/src/test/e2e/31_checksum_and_signature_test.go b/src/test/e2e/31_checksum_and_signature_test.go index 011b7229d2..4cfba8afa3 100644 --- a/src/test/e2e/31_checksum_and_signature_test.go +++ b/src/test/e2e/31_checksum_and_signature_test.go @@ -27,6 +27,11 @@ func TestChecksumAndSignature(t *testing.T) { stdOut, stdErr, err = e2e.Zarf(t, "package", "inspect", pkgName, publicKeyFlag) require.NoError(t, err, stdOut, stdErr) + /* Test operations during package inspect */ + // Test that we can inspect the yaml of the package without the private key + stdOut, stdErr, err = e2e.Zarf(t, "package", "inspect", pkgName, "--insecure") + require.NoError(t, err, stdOut, stdErr) + /* Test operations during package deploy */ // Test that we get an error when trying to deploy a package without providing the public key stdOut, stdErr, err = e2e.Zarf(t, "package", "deploy", pkgName, "--confirm")