Skip to content

Commit

Permalink
🐛 fix: add missing name prefix and namespace to leader-election-role …
Browse files Browse the repository at this point in the history
…and leader-election-rolebinding
  • Loading branch information
monteiro-renato committed Nov 21, 2024
1 parent 45925f3 commit dbaccfb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
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,7 +4,8 @@ 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
Expand Down

0 comments on commit dbaccfb

Please sign in to comment.