Skip to content
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

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

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
6 changes: 6 additions & 0 deletions api/types/helmchartargs.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ type HelmChart struct {

// debug enables debug output from the Helm chart inflator generator.
Debug bool `json:"debug,omitempty" yaml:"debug,omitempty"`

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

// HelmChartArgs contains arguments to helm.
Expand Down Expand Up @@ -194,5 +197,8 @@ func (h HelmChart) AsHelmArgs(absChartHome string) []string {
if h.Debug {
args = append(args, "--debug")
}
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 @@ -77,4 +77,21 @@ func TestAsHelmArgs(t *testing.T) {
"-f", "values2",
"--debug"})
})

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 @@ -993,3 +993,43 @@ debug: true
assert.Contains(t, string(chartYamlContent), "name: test-chart")
assert.Contains(t, string(chartYamlContent), "version: 1.0.0")
}

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)
}