Skip to content

Commit

Permalink
Localize helm additionValuesFiles
Browse files Browse the repository at this point in the history
  • Loading branch information
annasong20 committed Feb 1, 2023
1 parent a55d9a1 commit ac4fb55
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
4 changes: 4 additions & 0 deletions api/internal/localizer/builtinplugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ func (lbp *localizeBuiltinPlugins) Filter(plugins []*yaml.RNode) ([]*yaml.RNode,
Gvk: resid.Gvk{Version: konfig.BuiltinPluginApiVersion, Kind: builtinhelpers.HelmChartInflationGenerator.String()},
Path: "valuesFile",
},
types.FieldSpec{
Gvk: resid.Gvk{Version: konfig.BuiltinPluginApiVersion, Kind: builtinhelpers.HelmChartInflationGenerator.String()},
Path: "additionalValuesFiles",
},
types.FieldSpec{
Gvk: resid.Gvk{Version: konfig.BuiltinPluginApiVersion, Kind: builtinhelpers.PatchTransformer.String()},
Path: "path",
Expand Down
8 changes: 8 additions & 0 deletions api/internal/localizer/localizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,14 @@ func (lc *localizer) localizeHelmCharts(kust *types.Kustomization) error {
return errors.WrapPrefixf(err, "unable to localize helmCharts entry %d valuesFile", i)
}
kust.HelmCharts[i].ValuesFile = locFile

for j, valuesFile := range chart.AdditionalValuesFiles {
locFile, err = lc.localizeFile(valuesFile)
if err != nil {
return errors.WrapPrefixf(err, "unable to localize helmCharts entry %d additionalValuesFiles", i)
}
kust.HelmCharts[i].AdditionalValuesFiles[j] = locFile
}
}
if kust.HelmGlobals != nil {
locDir, err := lc.copyChartHomeEntry(kust.HelmGlobals.ChartHome)
Expand Down
14 changes: 13 additions & 1 deletion api/internal/localizer/localizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1273,8 +1273,13 @@ func TestLocalizeHelmCharts(t *testing.T) {
- includeCRDs: true
name: localize-valuesFile
valuesFile: file
- additionalValuesFiles:
- another
- third
`,
"file": valuesFile,
"another": valuesFile,
"third": valuesFile,
"charts/nothing-to-localize/values.yaml": valuesFile,
"charts/localize-valuesFile/values.yaml": valuesFile,
},
Expand Down Expand Up @@ -1513,14 +1518,21 @@ releaseName: moria
repo: https://itzg.github.io/minecraft-server-charts
version: 3.1.3
`,
"explicit.yaml": `apiVersion: builtin
"explicit.yaml": `additionalValuesFiles:
- time.yaml
- life.yaml
- light.yaml
apiVersion: builtin
chartHome: home
kind: HelmChartInflationGenerator
metadata:
name: explicit-references
name: mapleStory
valuesFile: mapleValues.yaml
`,
"time.yaml": valuesFile,
"life.yaml": valuesFile,
"light.yaml": valuesFile,
"mapleValues.yaml": valuesFile,
"home/mapleStory/values.yaml": valuesFile,
"charts/minecraft/values.yaml": valuesFile,
Expand Down

0 comments on commit ac4fb55

Please sign in to comment.