From d269a83954102b895ab4823edb75d1fdf10bfd63 Mon Sep 17 00:00:00 2001 From: Mohamed Rafraf <81432497+mohamed-rafraf@users.noreply.github.com> Date: Thu, 2 Jan 2025 14:36:37 +0100 Subject: [PATCH] fix decode with tink-kubeconfig envar (#1888) --- .../provider/baremetal/plugins/tinkerbell/driver.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/cloudprovider/provider/baremetal/plugins/tinkerbell/driver.go b/pkg/cloudprovider/provider/baremetal/plugins/tinkerbell/driver.go index 3461497b2..575063852 100644 --- a/pkg/cloudprovider/provider/baremetal/plugins/tinkerbell/driver.go +++ b/pkg/cloudprovider/provider/baremetal/plugins/tinkerbell/driver.go @@ -185,7 +185,14 @@ func GetConfig(driverConfig tinktypes.TinkerbellPluginSpec, valueFromStringOrEnv if err != nil { return nil, fmt.Errorf(`failed to get value of "kubeconfig" field: %w`, err) } + val, err := base64.StdEncoding.DecodeString(config.Kubeconfig) + // We intentionally ignore errors here with an assumption that an unencoded YAML or JSON must have been passed on + // in this case. + if err == nil { + config.Kubeconfig = string(val) + } } + config.ClusterName, err = valueFromStringOrEnvVar(driverConfig.ClusterName, "CLUSTER_NAME") if err != nil { return nil, fmt.Errorf(`failed to get value of "clusterName" field: %w`, err)