Skip to content

Commit b6dd2a6

Browse files
committed
feat(helm): add --not-in-schema flag
1 parent 447a609 commit b6dd2a6

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

api/types/helmchartargs.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ type HelmChart struct {
9999

100100
// debug enables debug output from the Helm chart inflator generator.
101101
Debug bool `json:"debug,omitempty" yaml:"debug,omitempty"`
102+
103+
// SkipSchemaValidation disables JSON schema validation
104+
SkipSchemaValidation bool `json:"skipSchemaValidation,omitempty" yaml:"skipSchemaValidation,omitempty"`
102105
}
103106

104107
// HelmChartArgs contains arguments to helm.
@@ -194,5 +197,8 @@ func (h HelmChart) AsHelmArgs(absChartHome string) []string {
194197
if h.Debug {
195198
args = append(args, "--debug")
196199
}
200+
if h.SkipSchemaValidation {
201+
args = append(args, "--skip-schema-validation")
202+
}
197203
return args
198204
}

api/types/helmchartargs_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,21 @@ func TestAsHelmArgs(t *testing.T) {
7777
"-f", "values2",
7878
"--debug"})
7979
})
80+
81+
t.Run("use skip-schema-validation", func(t *testing.T) {
82+
p := types.HelmChart{
83+
Name: "chart-name",
84+
Version: "1.0.0",
85+
Repo: "https://helm.releases.hashicorp.com",
86+
ValuesFile: "values",
87+
AdditionalValuesFiles: []string{"values1", "values2"},
88+
SkipSchemaValidation: true,
89+
}
90+
require.Equal(t, p.AsHelmArgs("/home/charts"),
91+
[]string{"template", "--generate-name", "/home/charts/chart-name",
92+
"-f", "values",
93+
"-f", "values1",
94+
"-f", "values2",
95+
"--skip-schema-validation"})
96+
})
8097
}

plugin/builtin/helmchartinflationgenerator/HelmChartInflationGenerator_test.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -993,3 +993,43 @@ debug: true
993993
assert.Contains(t, string(chartYamlContent), "name: test-chart")
994994
assert.Contains(t, string(chartYamlContent), "version: 1.0.0")
995995
}
996+
997+
func TestHelmChartInflationGeneratorWithSkipSchemaValidation(t *testing.T) {
998+
th := kusttest_test.MakeEnhancedHarnessWithTmpRoot(t).
999+
PrepBuiltin("HelmChartInflationGenerator")
1000+
defer th.Reset()
1001+
if err := th.ErrIfNoHelm(); err != nil {
1002+
t.Skip("skipping: " + err.Error())
1003+
}
1004+
copyTestChartsIntoHarness(t, th)
1005+
1006+
// minecraftServer.eula must be one of the following: "true", "TRUE", "false", "FALSE"
1007+
rm := th.LoadAndRunGenerator(`
1008+
apiVersion: builtin
1009+
kind: HelmChartInflationGenerator
1010+
metadata:
1011+
name: myMc
1012+
name: minecraft
1013+
version: 4.23.7
1014+
repo: https://itzg.github.io/minecraft-server-charts
1015+
releaseName: isarns
1016+
valuesInline:
1017+
minecraftServer:
1018+
eula: not-in-schema
1019+
difficulty: hard
1020+
rcon:
1021+
enabled: true
1022+
resources:
1023+
requests:
1024+
cpu: 555m
1025+
memory: 111Mi
1026+
skipSchemaValidation: true
1027+
`)
1028+
1029+
cm, err := rm.Resources()[0].GetFieldValue("metadata.name")
1030+
require.NoError(t, err)
1031+
assert.Equal(t, "isarns-minecraft-rcon", cm)
1032+
cm, err =rm.Resources()[4].GetFieldValue("spec.template.spec.containers[0].env[0].value")
1033+
require.NoError(t, err)
1034+
assert.Equal(t, "not-in-schema", cm)
1035+
}

0 commit comments

Comments
 (0)