From 8b15c30cf2a7732db91224a5019b7a957d56bb74 Mon Sep 17 00:00:00 2001 From: yxxhero <11087727+yxxhero@users.noreply.github.com> Date: Sat, 15 Feb 2025 00:57:50 +0800 Subject: [PATCH] docs: add skipSchemaValidation to index.md and update related structs (#1935) * docs: add skipSchemaValidation to index.md and update related structs Signed-off-by: yxxhero * feat: add SkipSchemaValidation to config and state handling Signed-off-by: yxxhero --------- Signed-off-by: yxxhero --- docs/index.md | 4 ++++ pkg/app/app.go | 47 ++++++++++++++++++++++-------------------- pkg/app/config.go | 2 ++ pkg/config/apply.go | 2 +- pkg/config/sync.go | 2 +- pkg/config/template.go | 2 +- pkg/state/state.go | 7 +++++-- 7 files changed, 39 insertions(+), 27 deletions(-) diff --git a/docs/index.md b/docs/index.md index 22bf5fbe..5af7f7c0 100644 --- a/docs/index.md +++ b/docs/index.md @@ -193,6 +193,8 @@ helmDefaults: # verify the chart before upgrading (only works with packaged charts not directories) (default false) verify: true keyring: path/to/keyring.gpg + # --skip-schema-validation flag to helm 'install', 'upgrade' and 'lint', starts with helm 3.16.0 (default false) + skipSchemaValidation: false # wait for k8s resources via --wait. (default false) wait: true # if set and --wait enabled, will retry any failed check on resource state subject to the specified number of retries (default 0) @@ -313,6 +315,8 @@ releases: # Override helmDefaults options for verify, wait, waitForJobs, timeout, recreatePods and force. verify: true keyring: path/to/keyring.gpg + # --skip-schema-validation flag to helm 'install', 'upgrade' and 'lint', starts with helm 3.16.0 (default false) + skipSchemaValidation: false wait: true waitRetries: 3 waitForJobs: true diff --git a/pkg/app/app.go b/pkg/app/app.go index 23304dfc..7bed5766 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -1441,6 +1441,7 @@ func (a *App) apply(r *Run, c ApplyConfigProvider) (bool, bool, []error) { DiffArgs: c.DiffArgs(), PostRenderer: c.PostRenderer(), PostRendererArgs: c.PostRendererArgs(), + SkipSchemaValidation: c.SkipSchemaValidation(), SuppressOutputLineRegex: c.SuppressOutputLineRegex(), } @@ -1943,18 +1944,19 @@ Do you really want to sync? subst.Releases = rs opts := &state.SyncOpts{ - Set: c.Set(), - SkipCRDs: c.SkipCRDs(), - Wait: c.Wait(), - WaitRetries: c.WaitRetries(), - WaitForJobs: c.WaitForJobs(), - ReuseValues: c.ReuseValues(), - ResetValues: c.ResetValues(), - PostRenderer: c.PostRenderer(), - PostRendererArgs: c.PostRendererArgs(), - SyncArgs: c.SyncArgs(), - HideNotes: c.HideNotes(), - TakeOwnership: c.TakeOwnership(), + Set: c.Set(), + SkipCRDs: c.SkipCRDs(), + Wait: c.Wait(), + WaitRetries: c.WaitRetries(), + WaitForJobs: c.WaitForJobs(), + ReuseValues: c.ReuseValues(), + ResetValues: c.ResetValues(), + PostRenderer: c.PostRenderer(), + PostRendererArgs: c.PostRendererArgs(), + SyncArgs: c.SyncArgs(), + HideNotes: c.HideNotes(), + TakeOwnership: c.TakeOwnership(), + SkipSchemaValidation: c.SkipSchemaValidation(), } return subst.SyncReleases(&affectedReleases, helm, c.Values(), c.Concurrency(), opts) })) @@ -1982,16 +1984,17 @@ func (a *App) template(r *Run, c TemplateConfigProvider) (bool, []error) { } opts := &state.TemplateOpts{ - Set: c.Set(), - IncludeCRDs: c.IncludeCRDs(), - NoHooks: c.NoHooks(), - OutputDirTemplate: c.OutputDirTemplate(), - SkipCleanup: c.SkipCleanup(), - SkipTests: c.SkipTests(), - PostRenderer: c.PostRenderer(), - PostRendererArgs: c.PostRendererArgs(), - KubeVersion: c.KubeVersion(), - ShowOnly: c.ShowOnly(), + Set: c.Set(), + IncludeCRDs: c.IncludeCRDs(), + NoHooks: c.NoHooks(), + OutputDirTemplate: c.OutputDirTemplate(), + SkipCleanup: c.SkipCleanup(), + SkipTests: c.SkipTests(), + PostRenderer: c.PostRenderer(), + PostRendererArgs: c.PostRendererArgs(), + KubeVersion: c.KubeVersion(), + ShowOnly: c.ShowOnly(), + SkipSchemaValidation: c.SkipSchemaValidation(), } return st.TemplateReleases(helm, c.OutputDir(), c.Values(), args, c.Concurrency(), c.Validate(), opts) }) diff --git a/pkg/app/config.go b/pkg/app/config.go index ecccc0dc..08bb39cd 100644 --- a/pkg/app/config.go +++ b/pkg/app/config.go @@ -103,6 +103,7 @@ type ApplyConfigProvider interface { type SyncConfigProvider interface { Args() string PostRenderer() string + SkipSchemaValidation() bool PostRendererArgs() []string HideNotes() bool TakeOwnership() bool @@ -239,6 +240,7 @@ type TemplateConfigProvider interface { Args() string PostRenderer() string PostRendererArgs() []string + SkipSchemaValidation() bool Values() []string Set() []string diff --git a/pkg/config/apply.go b/pkg/config/apply.go index 1b34a88b..e77592b5 100644 --- a/pkg/config/apply.go +++ b/pkg/config/apply.go @@ -54,7 +54,7 @@ type ApplyOptions struct { WaitRetries int // WaitForJobs is true if the helm command should wait for the jobs to be completed WaitForJobs bool - // Propagate '--skipSchemaValidation' to helmv3 template and helm install + // Propagate '--skip-schema-validation' to helmv3 template and helm install SkipSchemaValidation bool // ReuseValues is true if the helm command should reuse the values ReuseValues bool diff --git a/pkg/config/sync.go b/pkg/config/sync.go index aaea12bb..033f82ed 100644 --- a/pkg/config/sync.go +++ b/pkg/config/sync.go @@ -32,7 +32,7 @@ type SyncOptions struct { PostRenderer string // Propagate '--post-renderer-args' to helmv3 template and helm install PostRendererArgs []string - // Propagate '--skipSchemaValidation' to helmv3 template and helm install + // Propagate '--skip-schema-validation' to helmv3 template and helm install SkipSchemaValidation bool // Cascade '--cascade' to helmv3 delete, available values: background, foreground, or orphan, default: background Cascade string diff --git a/pkg/config/template.go b/pkg/config/template.go index 134cc6aa..90c82691 100644 --- a/pkg/config/template.go +++ b/pkg/config/template.go @@ -38,7 +38,7 @@ type TemplateOptions struct { PostRenderer string // Propagate '--post-renderer-args' to helmv3 template and helm install PostRendererArgs []string - // Propagate '--skipSchemaValidation' to helmv3 template and helm install + // Propagate '--skip-schema-validation' to helmv3 template and helm install SkipSchemaValidation bool // KubeVersion is the kube-version flag KubeVersion string diff --git a/pkg/state/state.go b/pkg/state/state.go index 38215228..b2d9b74b 100644 --- a/pkg/state/state.go +++ b/pkg/state/state.go @@ -161,7 +161,7 @@ type HelmSpec struct { Keyring string `yaml:"keyring,omitempty"` // EnableDNS, when set to true, enable DNS lookups when rendering templates EnableDNS bool `yaml:"enableDNS"` - // Propagate '--skipSchemaValidation' to helmv3 template and helm install + // Propagate '--skip-schema-validation' to helmv3 template and helm install SkipSchemaValidation *bool `yaml:"skipSchemaValidation,omitempty"` // Devel, when set to true, use development versions, too. Equivalent to version '>0.0.0-0' Devel bool `yaml:"devel"` @@ -390,7 +390,7 @@ type ReleaseSpec struct { // Propagate '--post-renderer' to helmv3 template and helm install PostRenderer *string `yaml:"postRenderer,omitempty"` - // Propagate '--skipSchemaValidation' to helmv3 template and helm install + // Propagate '--skip-schema-validation' to helmv3 template and helm install SkipSchemaValidation *bool `yaml:"skipSchemaValidation,omitempty"` // Propagate '--post-renderer-args' to helmv3 template and helm install @@ -1492,6 +1492,8 @@ type TemplateOpts struct { PostRendererArgs []string KubeVersion string ShowOnly []string + // Propagate '--skip-schema-validation' to helmv3 template and helm install + SkipSchemaValidation bool } type TemplateOpt interface{ Apply(*TemplateOpts) } @@ -2837,6 +2839,7 @@ func (st *HelmState) flagsForTemplate(helm helmexec.Interface, release *ReleaseS flags = st.appendApiVersionsFlags(flags, release, kubeVersion) flags = st.appendChartDownloadFlags(flags, release) flags = st.appendShowOnlyFlags(flags, showOnly) + flags = st.appendSkipSchemaValidationFlags(flags, release, opt.SkipSchemaValidation) common, files, err := st.namespaceAndValuesFlags(helm, release, workerIndex) if err != nil {