Skip to content

Commit

Permalink
Use the ServiceAccount name defined in the values.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
jayson committed Dec 2, 2024
1 parent 781e93f commit fa2af9c
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pkg/plugins/optional/helm/v1alpha/scaffolds/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func copyFileWithHelmLogic(srcFile, destFile, subDir, projectName string) error
if subDir == "rbac" {
contentStr = strings.Replace(contentStr,
"name: controller-manager",
fmt.Sprintf("name: %s-controller-manager", projectName), -1)
"name: {{ .Values.controllerManager.serviceAccountName }}", -1)
contentStr = strings.Replace(contentStr,
"name: metrics-reader",
fmt.Sprintf("name: %s-metrics-reader", projectName), 1)
Expand All @@ -302,7 +302,7 @@ func copyFileWithHelmLogic(srcFile, destFile, subDir, projectName string) error
"name: metrics-auth-rolebinding",
fmt.Sprintf("name: %s-metrics-auth-rolebinding", projectName), 1)

if strings.Contains(contentStr, "-controller-manager") &&
if strings.Contains(contentStr, ".Values.controllerManager.serviceAccountName") &&
strings.Contains(contentStr, "kind: ServiceAccount") &&
!strings.Contains(contentStr, "RoleBinding") {
// The generated Service Account does not have the annotations field so we must add it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ roleRef:
name: project-v4-with-plugins-leader-election-role
subjects:
- kind: ServiceAccount
name: project-v4-with-plugins-controller-manager
name: {{ .Values.controllerManager.serviceAccountName }}
namespace: {{ .Release.Namespace }}
{{- end -}}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ roleRef:
name: project-v4-with-plugins-metrics-auth-role
subjects:
- kind: ServiceAccount
name: project-v4-with-plugins-controller-manager
name: {{ .Values.controllerManager.serviceAccountName }}
namespace: {{ .Release.Namespace }}
{{- end -}}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ roleRef:
name: project-v4-with-plugins-manager-role
subjects:
- kind: ServiceAccount
name: project-v4-with-plugins-controller-manager
name: {{ .Values.controllerManager.serviceAccountName }}
namespace: {{ .Release.Namespace }}
{{- end -}}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ metadata:
{{ $key }}: {{ $value }}
{{- end }}
{{- end }}
name: project-v4-with-plugins-controller-manager
name: {{ .Values.controllerManager.serviceAccountName }}
namespace: {{ .Release.Namespace }}
{{- end -}}

0 comments on commit fa2af9c

Please sign in to comment.