Skip to content

Commit 4fde6e1

Browse files
authored
Add disableValidation and disableOpenAPIValidation per release (#1373)
`disableOpenAPIValidation: true` might be useful for workaround for broken CRDs that is known to be exist in older OpenShift versions, and `disableValidation: true` is confirmed to allow installing charts like prometheus-operator that tries to install CRDs and CRs in the same chart. Strictly speaking, for the latter case I believe you only need `disableValidation: true` set during the first installation, but for the ease of operation I shall suggest you to always set it. Obviously turning validation mostly(disableOpenAPIValidation) or entirely(disableValidation) result in deferring any real error until sync time. We need completely client-side validation that is able to read CRDs and use it for validating any CRs to catch any error before sync. But it worth an another (big) issue. Fixes #1124
1 parent a5e790c commit 4fde6e1

File tree

1 file changed

+40
-4
lines changed

1 file changed

+40
-4
lines changed

pkg/state/state.go

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,12 @@ type HelmSpec struct {
128128
// CreateNamespace, when set to true (default), --create-namespace is passed to helm3 on install/upgrade (ignored for helm2)
129129
CreateNamespace *bool `yaml:"createNamespace,omitempty"`
130130

131-
TLS bool `yaml:"tls"`
132-
TLSCACert string `yaml:"tlsCACert,omitempty"`
133-
TLSKey string `yaml:"tlsKey,omitempty"`
134-
TLSCert string `yaml:"tlsCert,omitempty"`
131+
TLS bool `yaml:"tls"`
132+
TLSCACert string `yaml:"tlsCACert,omitempty"`
133+
TLSKey string `yaml:"tlsKey,omitempty"`
134+
TLSCert string `yaml:"tlsCert,omitempty"`
135+
DisableValidation *bool `yaml:"disableValidation,omitempty"`
136+
DisableOpenAPIValidation *bool `yaml:"disableOpenAPIValidation,omitempty"`
135137
}
136138

137139
// RepositorySpec that defines values for a helm repo
@@ -174,6 +176,18 @@ type ReleaseSpec struct {
174176
// CreateNamespace, when set to true (default), --create-namespace is passed to helm3 on install (ignored for helm2)
175177
CreateNamespace *bool `yaml:"createNamespace,omitempty"`
176178

179+
// DisableOpenAPIValidation is rarely used to bypass OpenAPI validations only that is used for e.g.
180+
// work-around against broken CRs
181+
// See also:
182+
// - https://github.com/helm/helm/pull/6819
183+
// - https://github.com/roboll/helmfile/issues/1167
184+
DisableOpenAPIValidation *bool `yaml:"disableOpenAPIValidation,omitempty"`
185+
186+
// DisableValidation is rarely used to bypass the whole validation of manifests against the Kubernetes cluster
187+
// so that `helm diff` can be run containing a chart that installs both CRD and CRs on first install.
188+
// FYI, such diff without `--disable-validation` fails on first install because the K8s cluster doesn't have CRDs registered yet.
189+
DisableValidation *bool `yaml:"disableValidation,omitempty"`
190+
177191
// MissingFileHandler is set to either "Error" or "Warn". "Error" instructs helmfile to fail when unable to find a values or secrets file. When "Warn", it prints the file and continues.
178192
// The default value for MissingFileHandler is "Error".
179193
MissingFileHandler *string `yaml:"missingFileHandler,omitempty"`
@@ -1771,6 +1785,28 @@ func (st *HelmState) flagsForDiff(helm helmexec.Interface, release *ReleaseSpec,
17711785
flags = append(flags, "--devel")
17721786
}
17731787

1788+
disableOpenAPIValidation := false
1789+
if release.DisableOpenAPIValidation != nil {
1790+
disableOpenAPIValidation = *release.DisableOpenAPIValidation
1791+
} else if st.HelmDefaults.DisableOpenAPIValidation != nil {
1792+
disableOpenAPIValidation = *st.HelmDefaults.DisableOpenAPIValidation
1793+
}
1794+
1795+
if disableOpenAPIValidation {
1796+
flags = append(flags, "--disable-openapi-validation")
1797+
}
1798+
1799+
disableValidation := false
1800+
if release.DisableValidation != nil {
1801+
disableValidation = *release.DisableValidation
1802+
} else if st.HelmDefaults.DisableValidation != nil {
1803+
disableValidation = *st.HelmDefaults.DisableValidation
1804+
}
1805+
1806+
if disableValidation {
1807+
flags = append(flags, "--disable-validation")
1808+
}
1809+
17741810
flags = st.appendConnectionFlags(flags, release)
17751811

17761812
var err error

0 commit comments

Comments
 (0)