Skip to content

Commit e1a44f8

Browse files
(rbac) fix: improve role comment clarity by replacing {{ .ProjectName }} with rendered project name
1 parent c90c7ac commit e1a44f8

File tree

7 files changed

+11
-9
lines changed

7 files changed

+11
-9
lines changed

docs/book/src/cronjob-tutorial/testdata/project/config/rbac/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ resources:
2020
- metrics_reader_role.yaml
2121
# For each CRD, "Admin", "Editor" and "Viewer" roles are scaffolded by
2222
# default, aiding admins in cluster management. Those roles are
23-
# not used by the {{ .ProjectName }} itself. You can comment the following lines
23+
# not used by the project itself. You can comment the following lines
2424
# if you do not want those helpers be installed with your Project.
2525
- cronjob_admin_role.yaml
2626
- cronjob_editor_role.yaml

docs/book/src/getting-started/testdata/project/config/rbac/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ resources:
2020
- metrics_reader_role.yaml
2121
# For each CRD, "Admin", "Editor" and "Viewer" roles are scaffolded by
2222
# default, aiding admins in cluster management. Those roles are
23-
# not used by the {{ .ProjectName }} itself. You can comment the following lines
23+
# not used by the project itself. You can comment the following lines
2424
# if you do not want those helpers be installed with your Project.
2525
- memcached_admin_role.yaml
2626
- memcached_editor_role.yaml

docs/book/src/multiversion-tutorial/testdata/project/config/rbac/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ resources:
2020
- metrics_reader_role.yaml
2121
# For each CRD, "Admin", "Editor" and "Viewer" roles are scaffolded by
2222
# default, aiding admins in cluster management. Those roles are
23-
# not used by the {{ .ProjectName }} itself. You can comment the following lines
23+
# not used by the project itself. You can comment the following lines
2424
# if you do not want those helpers be installed with your Project.
2525
- cronjob_admin_role.yaml
2626
- cronjob_editor_role.yaml

pkg/plugins/common/kustomize/v2/scaffolds/api.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,12 @@ func (s *apiScaffolder) Scaffold() error {
100100
}
101101
}
102102

103+
comment := fmt.Sprintf(adminEditViewRulesCommentFragment, s.config.GetProjectName())
104+
103105
// Add scaffolded CRD Admin, Editor and Viewer roles in config/rbac/kustomization.yaml
104106
rbacKustomizeFilePath := "config/rbac/kustomization.yaml"
105107
err = pluginutil.AppendCodeIfNotExist(rbacKustomizeFilePath,
106-
adminEditViewRulesCommentFragment)
108+
comment)
107109
if err != nil {
108110
log.Errorf("Unable to append the admin/edit/view roles comment in the file "+
109111
"%s.", rbacKustomizeFilePath)
@@ -112,7 +114,7 @@ func (s *apiScaffolder) Scaffold() error {
112114
if s.config.IsMultiGroup() && s.resource.Group != "" {
113115
crdName = strings.ToLower(s.resource.Group) + "_" + crdName
114116
}
115-
err = pluginutil.InsertCodeIfNotExist(rbacKustomizeFilePath, adminEditViewRulesCommentFragment,
117+
err = pluginutil.InsertCodeIfNotExist(rbacKustomizeFilePath, comment,
116118
fmt.Sprintf("\n- %[1]s_admin_role.yaml\n- %[1]s_editor_role.yaml\n- %[1]s_viewer_role.yaml", crdName))
117119
if err != nil {
118120
log.Errorf("Unable to add Admin, Editor and Viewer roles in the file "+
@@ -134,5 +136,5 @@ func (s *apiScaffolder) Scaffold() error {
134136

135137
const adminEditViewRulesCommentFragment = `# For each CRD, "Admin", "Editor" and "Viewer" roles are scaffolded by
136138
# default, aiding admins in cluster management. Those roles are
137-
# not used by the {{ .ProjectName }} itself. You can comment the following lines
139+
# not used by the %s itself. You can comment the following lines
138140
# if you do not want those helpers be installed with your Project.`

testdata/project-v4-multigroup/config/rbac/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ resources:
2020
- metrics_reader_role.yaml
2121
# For each CRD, "Admin", "Editor" and "Viewer" roles are scaffolded by
2222
# default, aiding admins in cluster management. Those roles are
23-
# not used by the {{ .ProjectName }} itself. You can comment the following lines
23+
# not used by the project-v4-multigroup itself. You can comment the following lines
2424
# if you do not want those helpers be installed with your Project.
2525
- example.com_wordpress_admin_role.yaml
2626
- example.com_wordpress_editor_role.yaml

testdata/project-v4-with-plugins/config/rbac/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ resources:
2020
- metrics_reader_role.yaml
2121
# For each CRD, "Admin", "Editor" and "Viewer" roles are scaffolded by
2222
# default, aiding admins in cluster management. Those roles are
23-
# not used by the {{ .ProjectName }} itself. You can comment the following lines
23+
# not used by the project-v4-with-plugins itself. You can comment the following lines
2424
# if you do not want those helpers be installed with your Project.
2525
- wordpress_admin_role.yaml
2626
- wordpress_editor_role.yaml

testdata/project-v4/config/rbac/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ resources:
2020
- metrics_reader_role.yaml
2121
# For each CRD, "Admin", "Editor" and "Viewer" roles are scaffolded by
2222
# default, aiding admins in cluster management. Those roles are
23-
# not used by the {{ .ProjectName }} itself. You can comment the following lines
23+
# not used by the project-v4 itself. You can comment the following lines
2424
# if you do not want those helpers be installed with your Project.
2525
- admiral_admin_role.yaml
2626
- admiral_editor_role.yaml

0 commit comments

Comments
 (0)