Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 fix: (helm/v1alpha1) add missing name prefix and namespace to leader-election-role and leader-election-rolebinding #4357

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions pkg/plugins/optional/helm/v1alpha/scaffolds/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,20 @@ func copyFileWithHelmLogic(srcFile, destFile, subDir, projectName string) error
contentStr = strings.Replace(contentStr,
"name: metrics-reader",
fmt.Sprintf("name: %s-metrics-reader", projectName), 1)
contentStr = strings.Replace(contentStr,
"name: leader-election-role",
fmt.Sprintf("name: %s-leader-election-role", projectName), -1)
contentStr = strings.Replace(contentStr,
"name: leader-election-rolebinding",
fmt.Sprintf("name: %s-leader-election-rolebinding", projectName), 1)

// The generated files do not include the namespace
if strings.Contains(contentStr, "leader-election-rolebinding") ||
strings.Contains(contentStr, "leader-election-role") {
namespace := `
namespace: {{ .Release.Namespace }}`
contentStr = strings.Replace(contentStr, "metadata:", "metadata:"+namespace, 1)
}
}

// Conditionally handle CRD patches and annotations for CRDs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ kind: Role
metadata:
labels:
{{- include "chart.labels" . | nindent 4 }}
name: leader-election-role
namespace: {{ .Release.Namespace }}
name: project-v4-with-plugins-leader-election-role
rules:
- apiGroups:
- ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ kind: RoleBinding
metadata:
labels:
{{- include "chart.labels" . | nindent 4 }}
name: leader-election-rolebinding
namespace: {{ .Release.Namespace }}
name: project-v4-with-plugins-leader-election-rolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: leader-election-role
name: project-v4-with-plugins-leader-election-role
subjects:
- kind: ServiceAccount
name: project-v4-with-plugins-controller-manager
Expand Down
Loading