Skip to content

Commit bcba24e

Browse files
authored
Add --disable-validation for disabling validation against K8s cluster entirely (#228)
`--disable-openapi-validation` seems to not work against charts like prometheus-operator because it results in "missing kind" errors due to that it tries to install CRD and CR on first install. That is different than OpenAPI schema validation, which seems rather for detecting invalid fields. The addition of `--disable-validation` disables the manifests validation against the targeted K8s cluster(again, since Helm 3 `helm template --validate` runs validation against the live cluster so it is relevant), so that we can make use of helm-diff even for cases `--disable-openapi-validation` doesn not work. Resolves #183
1 parent 49e5318 commit bcba24e

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

cmd/helm3.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ func (d *diffCmd) template(isUpgrade bool) ([]byte, error) {
126126
flags = append(flags, "--set-file", fileValue)
127127
}
128128

129-
flags = append(flags, "--validate")
129+
if !d.disableValidation {
130+
flags = append(flags, "--validate")
131+
}
130132

131133
if isUpgrade {
132134
flags = append(flags, "--is-upgrade")

cmd/upgrade.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ type diffCmd struct {
2020
client helm.Interface
2121
detailedExitCode bool
2222
devel bool
23+
disableValidation bool
2324
disableOpenAPIValidation bool
2425
namespace string // namespace to assume the release to be installed into. Defaults to the current kube config namespace.
2526
valueFiles valueFiles
@@ -110,6 +111,7 @@ func newChartCommand() *cobra.Command {
110111
f.BoolVar(&diff.devel, "devel", false, "use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored.")
111112
f.StringArrayVar(&diff.suppressedKinds, "suppress", []string{}, "allows suppression of the values listed in the diff output")
112113
f.IntVarP(&diff.outputContext, "context", "C", -1, "output NUM lines of context around changes")
114+
f.BoolVar(&diff.disableValidation, "disable-validation", false, "disables rendered templates validation against the Kubernetes cluster you are currently pointing to. This is the same validation performed on an install")
113115
f.BoolVar(&diff.disableOpenAPIValidation, "disable-openapi-validation", false, "disables rendered templates validation against the Kubernetes OpenAPI Schema")
114116
f.StringVar(&diff.postRenderer, "post-renderer", "", "the path to an executable to be used for post rendering. If it exists in $PATH, the binary will be used, otherwise it will try to look for the executable at the given path")
115117
f.StringVar(&diff.output, "output", "diff", "Possible values: diff, simple, json, template. When set to \"template\", use the env var HELM_DIFF_TPL to specify the template.")

0 commit comments

Comments
 (0)