diff --git a/api/internal/builtins/HelmChartInflationGenerator.go b/api/internal/builtins/HelmChartInflationGenerator.go index b19d291bfa..6f671d2191 100644 --- a/api/internal/builtins/HelmChartInflationGenerator.go +++ b/api/internal/builtins/HelmChartInflationGenerator.go @@ -99,15 +99,6 @@ func (p *HelmChartInflationGeneratorPlugin) validateArgs() (err error) { if err = p.errIfIllegalValuesMerge(); err != nil { return err } - - // ConfigHome is not loaded by the plugin, and can be located anywhere. - if p.ConfigHome == "" { - if err = p.establishTmpDir(); err != nil { - return errors.Wrap( - err, "unable to create tmp dir for HELM_CONFIG_HOME") - } - p.ConfigHome = filepath.Join(p.tmpDir, "helm") - } return nil } @@ -139,18 +130,23 @@ func (p *HelmChartInflationGeneratorPlugin) runHelmCommand( cmd := exec.Command(p.h.GeneralConfig().HelmConfig.Command, args...) cmd.Stdout = stdout cmd.Stderr = stderr - env := []string{ - fmt.Sprintf("HELM_CONFIG_HOME=%s", p.ConfigHome), - fmt.Sprintf("HELM_CACHE_HOME=%s/.cache", p.ConfigHome), - fmt.Sprintf("HELM_DATA_HOME=%s/.data", p.ConfigHome)} - cmd.Env = append(os.Environ(), env...) + + // if the user has specifically set the confighome command then + // go ahead and use it. + if p.ConfigHome != "" { + env := []string{ + fmt.Sprintf("HELM_CONFIG_HOME=%s", p.ConfigHome), + fmt.Sprintf("HELM_CACHE_HOME=%s/.cache", p.ConfigHome), + fmt.Sprintf("HELM_DATA_HOME=%s/.data", p.ConfigHome)} + cmd.Env = append(os.Environ(), env...) + } err := cmd.Run() if err != nil { helm := p.h.GeneralConfig().HelmConfig.Command err = errors.Wrap( fmt.Errorf( - "unable to run: '%s %s' with env=%s (is '%s' installed?)", - helm, strings.Join(args, " "), env, helm), + "unable to run: '%s %s' (is '%s' installed?)", + helm, strings.Join(args, " "), helm), stderr.String(), ) } @@ -292,9 +288,15 @@ func (p *HelmChartInflationGeneratorPlugin) pullCommand() []string { args := []string{ "pull", "--untar", - "--untardir", p.absChartHome(), - "--repo", p.Repo, - p.Name} + "--untardir", p.absChartHome()} + + // OCI pull combine the repo and the chart name into one URL + if strings.HasPrefix(p.Repo, "oci://") { + chartLocation := p.Repo + "/" + p.Name + args = append(args, chartLocation) + } else { + args = append(args, "--repo", p.Repo, p.Name) + } if p.Version != "" { args = append(args, "--version", p.Version) } diff --git a/plugin/builtin/helmchartinflationgenerator/HelmChartInflationGenerator.go b/plugin/builtin/helmchartinflationgenerator/HelmChartInflationGenerator.go index 5d41b3dcde..259c454b73 100644 --- a/plugin/builtin/helmchartinflationgenerator/HelmChartInflationGenerator.go +++ b/plugin/builtin/helmchartinflationgenerator/HelmChartInflationGenerator.go @@ -297,9 +297,15 @@ func (p *HelmChartInflationGeneratorPlugin) pullCommand() []string { args := []string{ "pull", "--untar", - "--untardir", p.absChartHome(), - "--repo", p.Repo, - p.Name} + "--untardir", p.absChartHome()} + + // OCI pull combine the repo and the chart name into one URL + if strings.HasPrefix(p.Repo, "oci://") { + chartUrl := p.Repo + "/" + p.Name + args = append(args, chartUrl) + } else { + args = append(args, "--repo", p.Repo, p.Name) + } if p.Version != "" { args = append(args, "--version", p.Version) } diff --git a/plugin/builtin/helmchartinflationgenerator/HelmChartInflationGenerator_test.go b/plugin/builtin/helmchartinflationgenerator/HelmChartInflationGenerator_test.go index 0c2b4932c5..eeb0bf9f10 100644 --- a/plugin/builtin/helmchartinflationgenerator/HelmChartInflationGenerator_test.go +++ b/plugin/builtin/helmchartinflationgenerator/HelmChartInflationGenerator_test.go @@ -579,3 +579,25 @@ valuesInline: `) th.AssertActualEqualsExpected(rm, "") } + +func TestHelmChartInflationGeneratorOciRegistry(t *testing.T) { + th := kusttest_test.MakeEnhancedHarnessWithTmpRoot(t). + PrepBuiltin("HelmChartInflationGenerator") + defer th.Reset() + if err := th.ErrIfNoHelm(); err != nil { + t.Skip("skipping: " + err.Error()) + } + + rm := th.LoadAndRunGenerator(` +apiVersion: builtin +kind: HelmChartInflationGenerator +metadata: + name: ocichart +name: chart1 +version: 0.1.0 +repo: oci://us-central1-docker.pkg.dev/mikebz-ex1/charts +valuesInline: + nameOverride: foobar +`) + th.AssertActualEqualsExpected(rm, "") +}