diff --git a/cli/internal/helm/charts.go b/cli/internal/helm/charts.go index 9556517f75..27e9194589 100644 --- a/cli/internal/helm/charts.go +++ b/cli/internal/helm/charts.go @@ -8,6 +8,12 @@ import ( "helm.sh/helm/v3/pkg/cli" "repo1.dso.mil/platform-one/big-bang/apps/product-tools/zarf/cli/config" "repo1.dso.mil/platform-one/big-bang/apps/product-tools/zarf/cli/internal/git" + + "strings" + + "helm.sh/helm/v3/pkg/downloader" + "helm.sh/helm/v3/pkg/getter" + "helm.sh/helm/v3/pkg/repo" ) func DownloadChartFromGit(chart config.ZarfChart, destination string) { @@ -41,13 +47,40 @@ func DownloadPublishedChart(chart config.ZarfChart, destination string) { }) logContext.Info("Processing published helm chart") - client := action.NewPull() - client.Settings = cli.New() - client.DestDir = destination - client.Version = chart.Version - client.RepoURL = chart.Url - _, err := client.Run(chart.Name) + + var out strings.Builder + + // Setup the helm pull config + pull := action.NewPull() + pull.Settings = cli.New() + + // Setup the chart downloader + downloader := downloader.ChartDownloader{ + Out: &out, + Verify: downloader.VerifyNever, + Getters: getter.All(pull.Settings), + } + + // @todo: process OCI-based charts + + // Perform simple chart download + chartURL, err := repo.FindChartInRepoURL(chart.Url, chart.Name, chart.Version, pull.CertFile, pull.KeyFile, pull.CaFile, getter.All(pull.Settings)) + if err != nil { + logContext.Fatal("Unable to pull the helm chart") + } + + // Download the file (we don't control what name helm creates here) + saved, _, err := downloader.DownloadTo(chartURL, pull.Version, destination) if err != nil { - logContext.Fatal("Unable to load the helm chart") + logContext.Fatal("Unable to download the helm chart") } + + // Ensure the name is consistent for deployments + destinationTarball := StandardName(destination, chart) + os.Rename(saved, destinationTarball) +} + +// StandardName generates a predictable full path for a helm chart for Zarf +func StandardName(destintation string, chart config.ZarfChart) string { + return destintation + "/" + chart.Name + "-" + chart.Version + ".tgz" } diff --git a/cli/internal/packager/deploy.go b/cli/internal/packager/deploy.go index d150c1ea5d..150ac92f9b 100644 --- a/cli/internal/packager/deploy.go +++ b/cli/internal/packager/deploy.go @@ -12,6 +12,7 @@ import ( "github.com/sirupsen/logrus" "repo1.dso.mil/platform-one/big-bang/apps/product-tools/zarf/cli/config" "repo1.dso.mil/platform-one/big-bang/apps/product-tools/zarf/cli/internal/git" + "repo1.dso.mil/platform-one/big-bang/apps/product-tools/zarf/cli/internal/helm" "repo1.dso.mil/platform-one/big-bang/apps/product-tools/zarf/cli/internal/images" "repo1.dso.mil/platform-one/big-bang/apps/product-tools/zarf/cli/internal/k8s" "repo1.dso.mil/platform-one/big-bang/apps/product-tools/zarf/cli/internal/utils" @@ -160,8 +161,9 @@ func deployLocalAssets(tempPath tempPaths, assets config.ZarfFeature) { if len(assets.Charts) > 0 { logrus.Info("Loading charts for local install") for _, chart := range assets.Charts { - target := "/" + chart.Name + "-" + chart.Version + ".tgz" - utils.CreatePathAndCopy(tempPath.localCharts+target, config.K3sChartPath+target) + sourceTarball := helm.StandardName(tempPath.localCharts, chart) + destinationTarball := helm.StandardName(config.K3sChartPath, chart) + utils.CreatePathAndCopy(sourceTarball, destinationTarball) } }