Skip to content

Add --not-in-schema Flag to Helm #5869

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions api/types/helmchartargs.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ type HelmChart struct {

// allow for devel release to be used.
Devel bool `json:"devel,omitempty" yaml:"devel,omitempty"`

// SkipSchemaValidation disables JSON schema validation
SkipSchemaValidation bool `json:"skipSchemaValidation,omitempty" yaml:"skipSchemaValidation,omitempty"`
}

// HelmChartArgs contains arguments to helm.
Expand Down Expand Up @@ -200,5 +203,9 @@ func (h HelmChart) AsHelmArgs(absChartHome string) []string {
if h.Devel {
args = append(args, "--devel")
}

if h.SkipSchemaValidation {
args = append(args, "--skip-schema-validation")
}
return args
}
17 changes: 17 additions & 0 deletions api/types/helmchartargs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,21 @@ func TestAsHelmArgs(t *testing.T) {
"-f", "values2",
"--devel"})
})

t.Run("use skip-schema-validation", func(t *testing.T) {
p := types.HelmChart{
Name: "chart-name",
Version: "1.0.0",
Repo: "https://helm.releases.hashicorp.com",
ValuesFile: "values",
AdditionalValuesFiles: []string{"values1", "values2"},
SkipSchemaValidation: true,
}
require.Equal(t, p.AsHelmArgs("/home/charts"),
[]string{"template", "--generate-name", "/home/charts/chart-name",
"-f", "values",
"-f", "values1",
"-f", "values2",
"--skip-schema-validation"})
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -1027,3 +1027,43 @@ devel: true
assert.Contains(t, string(chartYamlContent), "name: sm-operator")
assert.Contains(t, string(chartYamlContent), "version: 0.1.0-Beta")
}

func TestHelmChartInflationGeneratorWithSkipSchemaValidation(t *testing.T) {
th := kusttest_test.MakeEnhancedHarnessWithTmpRoot(t).
PrepBuiltin("HelmChartInflationGenerator")
defer th.Reset()
if err := th.ErrIfNoHelm(); err != nil {
t.Skip("skipping: " + err.Error())
}
copyTestChartsIntoHarness(t, th)

// minecraftServer.eula must be one of the following: "true", "TRUE", "false", "FALSE"
rm := th.LoadAndRunGenerator(`
apiVersion: builtin
kind: HelmChartInflationGenerator
metadata:
name: myMc
name: minecraft
version: 4.23.7
repo: https://itzg.github.io/minecraft-server-charts
releaseName: isarns
valuesInline:
minecraftServer:
eula: not-in-schema
difficulty: hard
rcon:
enabled: true
resources:
requests:
cpu: 555m
memory: 111Mi
skipSchemaValidation: true
`)

cm, err := rm.Resources()[0].GetFieldValue("metadata.name")
require.NoError(t, err)
assert.Equal(t, "isarns-minecraft-rcon", cm)
cm, err =rm.Resources()[4].GetFieldValue("spec.template.spec.containers[0].env[0].value")
require.NoError(t, err)
assert.Equal(t, "not-in-schema", cm)
}