From 2e8df93f1c4c2548a0fe70d4128770be3c0756c7 Mon Sep 17 00:00:00 2001 From: yxxhero Date: Fri, 14 Feb 2025 22:05:39 +0800 Subject: [PATCH] feat: add SkipSchemaValidation to config and state handling Signed-off-by: yxxhero --- pkg/app/app.go | 47 ++++++++++++++++++++++++---------------------- pkg/app/config.go | 2 ++ pkg/state/state.go | 3 +++ 3 files changed, 30 insertions(+), 22 deletions(-) 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/state/state.go b/pkg/state/state.go index b4e02ede..b2d9b74b 100644 --- a/pkg/state/state.go +++ b/pkg/state/state.go @@ -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 {