From fbdc30d0444892559005e5a6de89fd25bb495626 Mon Sep 17 00:00:00 2001 From: Tobias Wolf Date: Tue, 23 Jan 2024 16:36:06 +0100 Subject: [PATCH] Add wrapper in `clusteraddon_controller.go` Signed-off-by: Tobias Wolf --- internal/controller/clusteraddon_controller.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/controller/clusteraddon_controller.go b/internal/controller/clusteraddon_controller.go index 6128c88a..38136e56 100644 --- a/internal/controller/clusteraddon_controller.go +++ b/internal/controller/clusteraddon_controller.go @@ -269,12 +269,12 @@ func (r *ClusterAddonReconciler) templateAndApplyClusterAddonHelmChart(ctx conte clusterAddonChart := in.clusterAddonChartPath var shouldRequeue bool - buildTemplate, err := buildTemplateFromClusterAddonValues(ctx, in.clusterAddonValuesPath, in.cluster, r.Client) + clusterAddonTemplate, err := buildTemplateFromClusterAddonValues(ctx, in.clusterAddonValuesPath, in.cluster, r.Client) if err != nil { return false, fmt.Errorf("failed to build template from cluster addon values: %w", err) } - helmTemplate, err := helmTemplateWithValues(in.restConfig, clusterAddonChart, "cluster-addon", clusterAddonNamespace, buildTemplate) + helmTemplate, err := helmTemplateWithClusterAddonTemplate(in.restConfig, clusterAddonChart, clusterAddonTemplate) if err != nil { return false, fmt.Errorf("failed to template helm chart: %w", err) } @@ -346,6 +346,10 @@ func buildTemplateFromClusterAddonValues(ctx context.Context, addonValuePath str return values, nil } +func helmTemplateWithClusterAddonTemplate(restConfig *rest.Config, clusterAddonChart string, clusterAddonTemplate string) ([]byte, error) { + return helmTemplateWithValues(restConfig, clusterAddonChart, "cluster-addon", clusterAddonNamespace, clusterAddonTemplate) +} + // initializeBuiltins takes a map of keys to object references, attempts to get the referenced objects, and returns a map of keys to the actual objects. // These objects are a map[string]interface{} so that they can be used as values in the template. func initializeBuiltins(ctx context.Context, c client.Client, referenceMap map[string]corev1.ObjectReference, cluster *clusterv1.Cluster) (map[string]interface{}, error) {