Skip to content

Commit 503eb5a

Browse files
authored
Merge pull request #4406 from wjiec/bugfix/helm-sa-name
🐛 fix: (helm/v1alpha1): Use the ServiceAccount name defined in the values.yaml
2 parents 781e93f + 9fb415f commit 503eb5a

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

pkg/plugins/optional/helm/v1alpha/scaffolds/init.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ func copyFileWithHelmLogic(srcFile, destFile, subDir, projectName string) error
290290
if subDir == "rbac" {
291291
contentStr = strings.Replace(contentStr,
292292
"name: controller-manager",
293-
fmt.Sprintf("name: %s-controller-manager", projectName), -1)
293+
"name: {{ .Values.controllerManager.serviceAccountName }}", -1)
294294
contentStr = strings.Replace(contentStr,
295295
"name: metrics-reader",
296296
fmt.Sprintf("name: %s-metrics-reader", projectName), 1)
@@ -302,7 +302,7 @@ func copyFileWithHelmLogic(srcFile, destFile, subDir, projectName string) error
302302
"name: metrics-auth-rolebinding",
303303
fmt.Sprintf("name: %s-metrics-auth-rolebinding", projectName), 1)
304304

305-
if strings.Contains(contentStr, "-controller-manager") &&
305+
if strings.Contains(contentStr, ".Values.controllerManager.serviceAccountName") &&
306306
strings.Contains(contentStr, "kind: ServiceAccount") &&
307307
!strings.Contains(contentStr, "RoleBinding") {
308308
// The generated Service Account does not have the annotations field so we must add it.

testdata/project-v4-with-plugins/dist/chart/templates/rbac/leader_election_role_binding.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ roleRef:
1212
name: project-v4-with-plugins-leader-election-role
1313
subjects:
1414
- kind: ServiceAccount
15-
name: project-v4-with-plugins-controller-manager
15+
name: {{ .Values.controllerManager.serviceAccountName }}
1616
namespace: {{ .Release.Namespace }}
1717
{{- end -}}

testdata/project-v4-with-plugins/dist/chart/templates/rbac/metrics_auth_role_binding.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ roleRef:
1111
name: project-v4-with-plugins-metrics-auth-role
1212
subjects:
1313
- kind: ServiceAccount
14-
name: project-v4-with-plugins-controller-manager
14+
name: {{ .Values.controllerManager.serviceAccountName }}
1515
namespace: {{ .Release.Namespace }}
1616
{{- end -}}

testdata/project-v4-with-plugins/dist/chart/templates/rbac/role_binding.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ roleRef:
1111
name: project-v4-with-plugins-manager-role
1212
subjects:
1313
- kind: ServiceAccount
14-
name: project-v4-with-plugins-controller-manager
14+
name: {{ .Values.controllerManager.serviceAccountName }}
1515
namespace: {{ .Release.Namespace }}
1616
{{- end -}}

testdata/project-v4-with-plugins/dist/chart/templates/rbac/service_account.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ metadata:
1010
{{ $key }}: {{ $value }}
1111
{{- end }}
1212
{{- end }}
13-
name: project-v4-with-plugins-controller-manager
13+
name: {{ .Values.controllerManager.serviceAccountName }}
1414
namespace: {{ .Release.Namespace }}
1515
{{- end -}}

0 commit comments

Comments
 (0)