fix: give helm a scratch directory instead of $HOME

Helm resolves its cache, config and data homes from `$HOME`, but dokku runs `scheduler-k3s:initialize` as root and every other subcommand as the dokku user, so those paths are not always readable by the user a command ends up as. Helm treats a repositories file it cannot read as a fatal error rather than an absent one, which made chart resolution fail outright even though dokku never reads an entry from that file. Each call now points helm at a private scratch directory that is removed once the chart has been located.
This commit is contained in:
Jose Diaz-Gonzalez committed 2026-09-18 17:45:43 -04:00
1 parent cf5487c2df
commit 47f1ca90a9
3 files changed
+152 -4

No files matched your search

+6 -2
View File
@@ -15,7 +15,6 @@ import (
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/chart"
"helm.sh/helm/v3/pkg/chart/loader"
"helm.sh/helm/v3/pkg/cli"
"helm.sh/helm/v3/pkg/release"
"helm.sh/helm/v3/pkg/storage/driver"
)
@@ -108,7 +107,12 @@ func CommandPreview(appName string, diffContext int, showSecrets bool, showSecre
}
func loadChartForPreview(chartPath string) (*chart.Chart, error) {
settings := cli.New()
settings, cleanup, err := newHelmSettings()
if err != nil {
return nil, err
}
defer cleanup()
opts := action.ChartPathOptions{}
located, err := opts.LocateChart(chartPath, settings)
if err != nil {