From a1fedf09250349bde494da3b9297658e279b3a21 Mon Sep 17 00:00:00 2001 From: Tamal Saha Date: Sun, 29 Oct 2023 07:33:03 -0700 Subject: [PATCH] Add GetBootstrapPresets Signed-off-by: Tamal Saha --- hub/helm.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/hub/helm.go b/hub/helm.go index c7d83107b..f11b20a8a 100644 --- a/hub/helm.go +++ b/hub/helm.go @@ -123,7 +123,7 @@ func FluxCDHelmRepository(kc client.Client) kmapi.TypedObjectReference { } } -func FeatureVersion(kc client.Client, featureName string) string { +func GetBootstrapPresets(kc client.Client) (*shared.BootstrapPresets, bool) { if kc != nil { var ccp chartsapi.ClusterChartPreset err := kc.Get(context.TODO(), client.ObjectKey{Name: BootstrapPresetsName}, &ccp) @@ -131,12 +131,20 @@ func FeatureVersion(kc client.Client, featureName string) string { var preset shared.BootstrapPresets err := json.Unmarshal(ccp.Spec.Values.Raw, &preset) if err == nil { - hr := preset.Helm.Releases[featureName] - if hr != nil { - return hr.Version - } + return &preset, true } } } + return nil, false +} + +func FeatureVersion(kc client.Client, featureName string) string { + preset, found := GetBootstrapPresets(kc) + if found { + hr := preset.Helm.Releases[featureName] + if hr != nil { + return hr.Version + } + } return "" }