Skip to content

Commit 57a3056

Browse files
committed
feat(helm): add --not-in-schema flag
1 parent f9ab532 commit 57a3056

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

api/types/helmchartargs.go

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

103103
// allow for devel release to be used.
104104
Devel bool `json:"devel,omitempty" yaml:"devel,omitempty"`
105+
106+
// SkipSchemaValidation disables JSON schema validation
107+
SkipSchemaValidation bool `json:"skipSchemaValidation,omitempty" yaml:"skipSchemaValidation,omitempty"`
105108
}
106109

107110
// HelmChartArgs contains arguments to helm.
@@ -200,5 +203,9 @@ func (h HelmChart) AsHelmArgs(absChartHome string) []string {
200203
if h.Devel {
201204
args = append(args, "--devel")
202205
}
206+
207+
if h.SkipSchemaValidation {
208+
args = append(args, "--skip-schema-validation")
209+
}
203210
return args
204211
}

api/types/helmchartargs_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,21 @@ func TestAsHelmArgs(t *testing.T) {
101101
"-f", "values2",
102102
"--devel"})
103103
})
104+
105+
t.Run("use skip-schema-validation", func(t *testing.T) {
106+
p := types.HelmChart{
107+
Name: "chart-name",
108+
Version: "1.0.0",
109+
Repo: "https://helm.releases.hashicorp.com",
110+
ValuesFile: "values",
111+
AdditionalValuesFiles: []string{"values1", "values2"},
112+
SkipSchemaValidation: true,
113+
}
114+
require.Equal(t, p.AsHelmArgs("/home/charts"),
115+
[]string{"template", "--generate-name", "/home/charts/chart-name",
116+
"-f", "values",
117+
"-f", "values1",
118+
"-f", "values2",
119+
"--skip-schema-validation"})
120+
})
104121
}

plugin/builtin/helmchartinflationgenerator/HelmChartInflationGenerator_test.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,3 +1027,43 @@ devel: true
10271027
assert.Contains(t, string(chartYamlContent), "name: sm-operator")
10281028
assert.Contains(t, string(chartYamlContent), "version: 0.1.0-Beta")
10291029
}
1030+
1031+
func TestHelmChartInflationGeneratorWithSkipSchemaValidation(t *testing.T) {
1032+
th := kusttest_test.MakeEnhancedHarnessWithTmpRoot(t).
1033+
PrepBuiltin("HelmChartInflationGenerator")
1034+
defer th.Reset()
1035+
if err := th.ErrIfNoHelm(); err != nil {
1036+
t.Skip("skipping: " + err.Error())
1037+
}
1038+
copyTestChartsIntoHarness(t, th)
1039+
1040+
// minecraftServer.eula must be one of the following: "true", "TRUE", "false", "FALSE"
1041+
rm := th.LoadAndRunGenerator(`
1042+
apiVersion: builtin
1043+
kind: HelmChartInflationGenerator
1044+
metadata:
1045+
name: myMc
1046+
name: minecraft
1047+
version: 4.23.7
1048+
repo: https://itzg.github.io/minecraft-server-charts
1049+
releaseName: isarns
1050+
valuesInline:
1051+
minecraftServer:
1052+
eula: not-in-schema
1053+
difficulty: hard
1054+
rcon:
1055+
enabled: true
1056+
resources:
1057+
requests:
1058+
cpu: 555m
1059+
memory: 111Mi
1060+
skipSchemaValidation: true
1061+
`)
1062+
1063+
cm, err := rm.Resources()[0].GetFieldValue("metadata.name")
1064+
require.NoError(t, err)
1065+
assert.Equal(t, "isarns-minecraft-rcon", cm)
1066+
cm, err =rm.Resources()[4].GetFieldValue("spec.template.spec.containers[0].env[0].value")
1067+
require.NoError(t, err)
1068+
assert.Equal(t, "not-in-schema", cm)
1069+
}

0 commit comments

Comments
 (0)