From 998af5aa3a11fec3adf68b6282096df3691e4bbc Mon Sep 17 00:00:00 2001 From: Tamal Saha Date: Mon, 11 Mar 2024 10:31:52 -0700 Subject: [PATCH] Add option to use non strict engine for helm addon Signed-off-by: Tamal Saha --- pkg/addonfactory/addonfactory.go | 8 ++++++++ pkg/addonfactory/helm_agentaddon.go | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/addonfactory/addonfactory.go b/pkg/addonfactory/addonfactory.go index 91e8df4e1..56bb24a94 100644 --- a/pkg/addonfactory/addonfactory.go +++ b/pkg/addonfactory/addonfactory.go @@ -37,6 +37,7 @@ type AgentAddonFactory struct { trimCRDDescription bool hostingCluster *clusterv1.ManagedCluster agentInstallNamespace func(addon *addonapiv1alpha1.ManagedClusterAddOn) string + helmEngineStrict bool } // NewAgentAddonFactory builds an addonAgentFactory instance with addon name and fs. @@ -59,6 +60,7 @@ func NewAgentAddonFactory(addonName string, fs embed.FS, dir string) *AgentAddon }, trimCRDDescription: false, scheme: s, + helmEngineStrict: false, } } @@ -115,6 +117,12 @@ func (f *AgentAddonFactory) WithTrimCRDDescription() *AgentAddonFactory { return f } +// WithHelmEngineStrict is to enable script go template rendering for Helm charts to generate manifestWork. +func (f *AgentAddonFactory) WithHelmEngineStrict() *AgentAddonFactory { + f.helmEngineStrict = true + return f +} + // WithConfigGVRs defines the addon supported configuration GroupVersionResource func (f *AgentAddonFactory) WithConfigGVRs(gvrs ...schema.GroupVersionResource) *AgentAddonFactory { f.agentAddonOptions.SupportedConfigGVRs = append(f.agentAddonOptions.SupportedConfigGVRs, gvrs...) diff --git a/pkg/addonfactory/helm_agentaddon.go b/pkg/addonfactory/helm_agentaddon.go index c8e8f9917..bbe4be95b 100644 --- a/pkg/addonfactory/helm_agentaddon.go +++ b/pkg/addonfactory/helm_agentaddon.go @@ -49,6 +49,7 @@ type HelmAgentAddon struct { trimCRDDescription bool hostingCluster *clusterv1.ManagedCluster agentInstallNamespace func(addon *addonapiv1alpha1.ManagedClusterAddOn) string + helmEngineStrict bool } func newHelmAgentAddon(factory *AgentAddonFactory, chart *chart.Chart) *HelmAgentAddon { @@ -60,6 +61,7 @@ func newHelmAgentAddon(factory *AgentAddonFactory, chart *chart.Chart) *HelmAgen trimCRDDescription: factory.trimCRDDescription, hostingCluster: factory.hostingCluster, agentInstallNamespace: factory.agentInstallNamespace, + helmEngineStrict: factory.helmEngineStrict, } } @@ -74,7 +76,7 @@ func (a *HelmAgentAddon) Manifests( } helmEngine := engine.Engine{ - Strict: true, + Strict: a.helmEngineStrict, LintMode: false, }