diff --git a/src/cmd/package.go b/src/cmd/package.go index 6ce03458c6..bd5a6f352c 100644 --- a/src/cmd/package.go +++ b/src/cmd/package.go @@ -202,6 +202,7 @@ var packageInspectCmd = &cobra.Command{ ListImages: pkgConfig.InspectOpts.ListImages, ViewSBOM: pkgConfig.InspectOpts.ViewSBOM, SBOMOutputDir: pkgConfig.InspectOpts.SBOMOutputDir, + PublicKeyPath: pkgConfig.PkgOpts.PublicKeyPath, } if pkgConfig.InspectOpts.ListImages { @@ -293,6 +294,7 @@ var packageRemoveCmd = &cobra.Command{ Cluster: cluster, Filter: filter, SkipSignatureValidation: pkgConfig.PkgOpts.SkipSignatureValidation, + PublicKeyPath: pkgConfig.PkgOpts.PublicKeyPath, } err = packager2.Remove(cmd.Context(), removeOpt) if err != nil { diff --git a/src/internal/packager2/inspect.go b/src/internal/packager2/inspect.go index 4545abe48e..bfad933b3a 100644 --- a/src/internal/packager2/inspect.go +++ b/src/internal/packager2/inspect.go @@ -23,6 +23,7 @@ type ZarfInspectOptions struct { SBOMOutputDir string ListImages bool SkipSignatureValidation bool + PublicKeyPath string } // Inspect list the contents of a package. @@ -66,7 +67,7 @@ func InspectList(ctx context.Context, opt ZarfInspectOptions) ([]string, error) } func getPackageMetadata(ctx context.Context, opt ZarfInspectOptions) (v1alpha1.ZarfPackage, error) { - pkg, err := packageFromSourceOrCluster(ctx, opt.Cluster, opt.Source, opt.SkipSignatureValidation) + pkg, err := packageFromSourceOrCluster(ctx, opt.Cluster, opt.Source, opt.SkipSignatureValidation, opt.PublicKeyPath) if err != nil { return pkg, err } @@ -79,6 +80,7 @@ func handleSBOMOptions(ctx context.Context, pkg v1alpha1.ZarfPackage, opt ZarfIn Source: opt.Source, SkipSignatureValidation: opt.SkipSignatureValidation, Filter: filters.Empty(), + PublicKeyPath: opt.PublicKeyPath, } layout, err := LoadPackage(ctx, loadOpt) if err != nil { diff --git a/src/internal/packager2/load.go b/src/internal/packager2/load.go index 1b61c46c14..c17fcf24b5 100644 --- a/src/internal/packager2/load.go +++ b/src/internal/packager2/load.go @@ -227,7 +227,7 @@ func assembleSplitTar(src, tarPath string) error { return nil } -func packageFromSourceOrCluster(ctx context.Context, cluster *cluster.Cluster, src string, skipSignatureValidation bool) (v1alpha1.ZarfPackage, error) { +func packageFromSourceOrCluster(ctx context.Context, cluster *cluster.Cluster, src string, skipSignatureValidation bool, publicKeyPath string) (v1alpha1.ZarfPackage, error) { _, err := identifySource(src) if err != nil { if cluster == nil { @@ -244,6 +244,7 @@ func packageFromSourceOrCluster(ctx context.Context, cluster *cluster.Cluster, s Source: src, SkipSignatureValidation: skipSignatureValidation, Filter: filters.Empty(), + PublicKeyPath: publicKeyPath, } pkgPaths, err := LoadPackage(ctx, loadOpt) if err != nil { diff --git a/src/internal/packager2/load_test.go b/src/internal/packager2/load_test.go index 208f68ba65..4c09a12260 100644 --- a/src/internal/packager2/load_test.go +++ b/src/internal/packager2/load_test.go @@ -142,10 +142,10 @@ func TestPackageFromSourceOrCluster(t *testing.T) { ctx := testutil.TestContext(t) - _, err := packageFromSourceOrCluster(ctx, nil, "test", false) + _, err := packageFromSourceOrCluster(ctx, nil, "test", false, "") require.EqualError(t, err, "cannot get Zarf package from Kubernetes without configuration") - pkg, err := packageFromSourceOrCluster(ctx, nil, "./testdata/zarf-package-test-amd64-0.0.1.tar.zst", false) + pkg, err := packageFromSourceOrCluster(ctx, nil, "./testdata/zarf-package-test-amd64-0.0.1.tar.zst", false, "") require.NoError(t, err) require.Equal(t, "test", pkg.Metadata.Name) @@ -154,7 +154,7 @@ func TestPackageFromSourceOrCluster(t *testing.T) { } _, err = c.RecordPackageDeployment(ctx, pkg, nil, 1) require.NoError(t, err) - pkg, err = packageFromSourceOrCluster(ctx, c, "test", false) + pkg, err = packageFromSourceOrCluster(ctx, c, "test", false, "") require.NoError(t, err) require.Equal(t, "test", pkg.Metadata.Name) } diff --git a/src/internal/packager2/remove.go b/src/internal/packager2/remove.go index a68a41c112..e20382da2d 100644 --- a/src/internal/packager2/remove.go +++ b/src/internal/packager2/remove.go @@ -28,11 +28,12 @@ type RemoveOptions struct { Cluster *cluster.Cluster Filter filters.ComponentFilterStrategy SkipSignatureValidation bool + PublicKeyPath string } // Remove removes a package that was already deployed onto a cluster, uninstalling all installed helm charts. func Remove(ctx context.Context, opt RemoveOptions) error { - pkg, err := packageFromSourceOrCluster(ctx, opt.Cluster, opt.Source, opt.SkipSignatureValidation) + pkg, err := packageFromSourceOrCluster(ctx, opt.Cluster, opt.Source, opt.SkipSignatureValidation, opt.PublicKeyPath) if err != nil { return err }