From 63197c504db8dbe5a2d4219f134fcd52e133483d Mon Sep 17 00:00:00 2001 From: Mo Mesgin Date: Thu, 10 Oct 2024 13:07:58 -0700 Subject: [PATCH 1/2] reset vsphere credentials when generate secret is off --- shell/utils/v-sphere.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/shell/utils/v-sphere.ts b/shell/utils/v-sphere.ts index e37ca189d75..b50f8801db8 100644 --- a/shell/utils/v-sphere.ts +++ b/shell/utils/v-sphere.ts @@ -101,6 +101,13 @@ class VSphereUtils { const { userValues, combined } = this.findChartValues(rke2Component, 'rancher-vsphere-cpi') || {}; if (!combined?.vCenter?.credentialsSecret?.generate) { + if (userValues?.vCenter?.username) { + userValues.vCenter.username = ''; + } + if (userValues?.vCenter?.password) { + userValues.vCenter.password = ''; + } + return; } @@ -167,6 +174,13 @@ class VSphereUtils { const { userValues, combined } = this.findChartValues(rke2Component, 'rancher-vsphere-csi') || {}; if (!combined?.vCenter?.configSecret?.generate) { + if (userValues?.vCenter?.username) { + userValues.vCenter.username = ''; + } + if (userValues?.vCenter?.password) { + userValues.vCenter.password = ''; + } + return; } From d5f24482bcf032847bca9c676588a3a429e99ed8 Mon Sep 17 00:00:00 2001 From: Mo Mesgin Date: Thu, 10 Oct 2024 14:55:23 -0700 Subject: [PATCH 2/2] remove extra characters from vsphere csi configTemplateString --- shell/utils/v-sphere.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/utils/v-sphere.ts b/shell/utils/v-sphere.ts index b50f8801db8..fb41bec036e 100644 --- a/shell/utils/v-sphere.ts +++ b/shell/utils/v-sphere.ts @@ -195,7 +195,7 @@ class VSphereUtils { // This is a copy of https://github.com/rancher/vsphere-charts/blob/a5c99d716df960dc50cf417d9ecffad6b55ca0ad/charts/rancher-vsphere-csi/values.yaml#L12-L21 // Which makes it's way into the secret via https://github.com/rancher/vsphere-charts/blob/main/charts/rancher-vsphere-csi/templates/secret.yaml#L8 - let configTemplateString = ' |\n [Global]\n cluster-id = {{ required \".Values.vCenter.clusterId must be provided\" (default .Values.vCenter.clusterId .Values.global.cattle.clusterId) | quote }}\n user = {{ .Values.vCenter.username | quote }}\n password = {{ .Values.vCenter.password | quote }}\n port = {{ .Values.vCenter.port | quote }}\n insecure-flag = {{ .Values.vCenter.insecureFlag | quote }}\n\n [VirtualCenter {{ .Values.vCenter.host | quote }}]\n datacenters = {{ .Values.vCenter.datacenters | quote }}'; + let configTemplateString = ' [Global]\n cluster-id = {{ required \".Values.vCenter.clusterId must be provided\" (default .Values.vCenter.clusterId .Values.global.cattle.clusterId) | quote }}\n user = {{ .Values.vCenter.username | quote }}\n password = {{ .Values.vCenter.password | quote }}\n port = {{ .Values.vCenter.port | quote }}\n insecure-flag = {{ .Values.vCenter.insecureFlag | quote }}\n\n [VirtualCenter {{ .Values.vCenter.host | quote }}]\n datacenters = {{ .Values.vCenter.datacenters | quote }}'; configTemplateString = configTemplateString.replace('{{ required \".Values.vCenter.clusterId must be provided\" (default .Values.vCenter.clusterId .Values.global.cattle.clusterId) | quote }}', `"{{clusterId}}"`); configTemplateString = configTemplateString.replace('{{ .Values.vCenter.username | quote }}', `"${ username }"`);