Skip to content

Commit

Permalink
Merge pull request #4357 from monteiro-renato/patch-1
Browse files Browse the repository at this point in the history
🐛 fix: (helm/v1alpha1) add missing name prefix and namespace to leader-election-role and leader-election-rolebinding
  • Loading branch information
k8s-ci-robot authored Nov 22, 2024
2 parents 1ab2d91 + 26f526a commit 9bb9b91
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 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,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

0 comments on commit 9bb9b91

Please sign in to comment.