Skip to content

Commit 1cecfd4

Browse files
committed
Add annotations to roles.
Signed-off-by: Monis Khan <[email protected]>
1 parent 8e57c4b commit 1cecfd4

File tree

19 files changed

+374
-66
lines changed

19 files changed

+374
-66
lines changed

pkg/api/constants/constants.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package constants
2+
3+
// annotation keys
4+
const (
5+
// OpenShiftDisplayName is a common, optional annotation that stores the name displayed by a UI when referencing a resource.
6+
OpenShiftDisplayName = "openshift.io/display-name"
7+
8+
// OpenShiftDescription is a common, optional annotation that stores the description for a resource.
9+
OpenShiftDescription = "openshift.io/description"
10+
)

pkg/cmd/admin/project/new_project.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
1212
errorsutil "k8s.io/kubernetes/pkg/util/errors"
1313

14+
"github.com/openshift/origin/pkg/api/constants"
1415
"github.com/openshift/origin/pkg/client"
1516
"github.com/openshift/origin/pkg/cmd/admin/policy"
1617
"github.com/openshift/origin/pkg/cmd/server/bootstrappolicy"
@@ -99,8 +100,8 @@ func (o *NewProjectOptions) Run(useNodeSelector bool) error {
99100
project := &projectapi.Project{}
100101
project.Name = o.ProjectName
101102
project.Annotations = make(map[string]string)
102-
project.Annotations[projectapi.ProjectDescription] = o.Description
103-
project.Annotations[projectapi.ProjectDisplayName] = o.DisplayName
103+
project.Annotations[constants.OpenShiftDescription] = o.Description
104+
project.Annotations[constants.OpenShiftDisplayName] = o.DisplayName
104105
if useNodeSelector {
105106
project.Annotations[projectapi.ProjectNodeSelector] = o.NodeSelector
106107
}

pkg/cmd/cli/cmd/projects.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
clientcmdapi "k8s.io/kubernetes/pkg/client/unversioned/clientcmd/api"
1212
kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
1313

14+
"github.com/openshift/origin/pkg/api/constants"
1415
"github.com/openshift/origin/pkg/client"
1516
cliconfig "github.com/openshift/origin/pkg/cmd/cli/config"
1617
"github.com/openshift/origin/pkg/cmd/templates"
@@ -160,7 +161,7 @@ func (o ProjectsOptions) RunProjects() error {
160161
sort.Sort(SortByProjectName(projects))
161162
for _, project := range projects {
162163
count = count + 1
163-
displayName := project.Annotations["openshift.io/display-name"]
164+
displayName := project.Annotations[constants.OpenShiftDisplayName]
164165
linebreak := "\n"
165166
if len(displayName) == 0 {
166167
displayName = project.Annotations["displayName"]

pkg/cmd/cli/describe/describer.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"k8s.io/kubernetes/pkg/runtime"
2222
"k8s.io/kubernetes/pkg/util/sets"
2323

24+
"github.com/openshift/origin/pkg/api/constants"
2425
authorizationapi "github.com/openshift/origin/pkg/authorization/api"
2526
buildapi "github.com/openshift/origin/pkg/build/api"
2627
"github.com/openshift/origin/pkg/client"
@@ -827,8 +828,8 @@ func (d *ProjectDescriber) Describe(namespace, name string, settings kctl.Descri
827828

828829
return tabbedString(func(out *tabwriter.Writer) error {
829830
formatMeta(out, project.ObjectMeta)
830-
formatString(out, "Display Name", project.Annotations[projectapi.ProjectDisplayName])
831-
formatString(out, "Description", project.Annotations[projectapi.ProjectDescription])
831+
formatString(out, "Display Name", project.Annotations[constants.OpenShiftDisplayName])
832+
formatString(out, "Description", project.Annotations[constants.OpenShiftDescription])
832833
formatString(out, "Status", project.Status.Phase)
833834
formatString(out, "Node Selector", nodeSelector)
834835
if len(resourceQuotaList.Items) == 0 {

pkg/cmd/cli/describe/printer.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
kctl "k8s.io/kubernetes/pkg/kubectl"
1515
"k8s.io/kubernetes/pkg/util/sets"
1616

17+
"github.com/openshift/origin/pkg/api/constants"
1718
authorizationapi "github.com/openshift/origin/pkg/authorization/api"
1819
buildapi "github.com/openshift/origin/pkg/build/api"
1920
deployapi "github.com/openshift/origin/pkg/deploy/api"
@@ -471,7 +472,7 @@ func printImageStreamList(streams *imageapi.ImageStreamList, w io.Writer, opts k
471472

472473
func printProject(project *projectapi.Project, w io.Writer, opts kctl.PrintOptions) error {
473474
name := formatResourceName(opts.Kind, project.Name, opts.WithKind)
474-
_, err := fmt.Fprintf(w, "%s\t%s\t%s", name, project.Annotations[projectapi.ProjectDisplayName], project.Status.Phase)
475+
_, err := fmt.Fprintf(w, "%s\t%s\t%s", name, project.Annotations[constants.OpenShiftDisplayName], project.Status.Phase)
475476
if err := appendItemLabels(project.Labels, w, opts.ColumnLabels, opts.ShowLabels); err != nil {
476477
return err
477478
}

pkg/cmd/cli/describe/projectstatus_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"k8s.io/kubernetes/pkg/runtime"
1111
utilerrors "k8s.io/kubernetes/pkg/util/errors"
1212

13+
"github.com/openshift/origin/pkg/api/constants"
1314
"github.com/openshift/origin/pkg/client/testclient"
1415
projectapi "github.com/openshift/origin/pkg/project/api"
1516
)
@@ -40,7 +41,7 @@ func TestProjectStatus(t *testing.T) {
4041
Name: "example",
4142
Namespace: "",
4243
Annotations: map[string]string{
43-
projectapi.ProjectDisplayName: "Test",
44+
constants.OpenShiftDisplayName: "Test",
4445
},
4546
},
4647
},

pkg/cmd/server/bootstrappolicy/infra_sa_policy.go

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ func init() {
131131
authorizationapi.ClusterRole{
132132
ObjectMeta: kapi.ObjectMeta{
133133
Name: BuildControllerRoleName,
134+
Annotations: map[string]string{
135+
roleSystemOnly: roleIsSystemOnly,
136+
},
134137
},
135138
Rules: []authorizationapi.PolicyRule{
136139
// BuildControllerFactory.buildLW
@@ -178,6 +181,9 @@ func init() {
178181
authorizationapi.ClusterRole{
179182
ObjectMeta: kapi.ObjectMeta{
180183
Name: DeploymentConfigControllerRoleName,
184+
Annotations: map[string]string{
185+
roleSystemOnly: roleIsSystemOnly,
186+
},
181187
},
182188
Rules: []authorizationapi.PolicyRule{
183189
// DeploymentControllerFactory.deploymentLW
@@ -212,6 +218,9 @@ func init() {
212218
authorizationapi.ClusterRole{
213219
ObjectMeta: kapi.ObjectMeta{
214220
Name: DeploymentControllerRoleName,
221+
Annotations: map[string]string{
222+
roleSystemOnly: roleIsSystemOnly,
223+
},
215224
},
216225
Rules: []authorizationapi.PolicyRule{
217226
{
@@ -253,6 +262,9 @@ func init() {
253262
authorizationapi.ClusterRole{
254263
ObjectMeta: kapi.ObjectMeta{
255264
Name: ReplicationControllerRoleName,
265+
Annotations: map[string]string{
266+
roleSystemOnly: roleIsSystemOnly,
267+
},
256268
},
257269
Rules: []authorizationapi.PolicyRule{
258270
// ReplicationManager.rcController.ListWatch
@@ -298,6 +310,9 @@ func init() {
298310
authorizationapi.ClusterRole{
299311
ObjectMeta: kapi.ObjectMeta{
300312
Name: ReplicaSetControllerRoleName,
313+
Annotations: map[string]string{
314+
roleSystemOnly: roleIsSystemOnly,
315+
},
301316
},
302317
Rules: []authorizationapi.PolicyRule{
303318
{
@@ -330,6 +345,9 @@ func init() {
330345
authorizationapi.ClusterRole{
331346
ObjectMeta: kapi.ObjectMeta{
332347
Name: JobControllerRoleName,
348+
Annotations: map[string]string{
349+
roleSystemOnly: roleIsSystemOnly,
350+
},
333351
},
334352
Rules: []authorizationapi.PolicyRule{
335353
// JobController.jobController.ListWatch
@@ -381,6 +399,9 @@ func init() {
381399
authorizationapi.ClusterRole{
382400
ObjectMeta: kapi.ObjectMeta{
383401
Name: HPAControllerRoleName,
402+
Annotations: map[string]string{
403+
roleSystemOnly: roleIsSystemOnly,
404+
},
384405
},
385406
Rules: []authorizationapi.PolicyRule{
386407
// HPA Controller
@@ -431,6 +452,9 @@ func init() {
431452
authorizationapi.ClusterRole{
432453
ObjectMeta: kapi.ObjectMeta{
433454
Name: PersistentVolumeRecyclerControllerRoleName,
455+
Annotations: map[string]string{
456+
roleSystemOnly: roleIsSystemOnly,
457+
},
434458
},
435459
Rules: []authorizationapi.PolicyRule{
436460
// PersistentVolumeRecycler.volumeController.ListWatch
@@ -490,6 +514,9 @@ func init() {
490514
authorizationapi.ClusterRole{
491515
ObjectMeta: kapi.ObjectMeta{
492516
Name: PersistentVolumeAttachDetachControllerRoleName,
517+
Annotations: map[string]string{
518+
roleSystemOnly: roleIsSystemOnly,
519+
},
493520
},
494521
Rules: []authorizationapi.PolicyRule{
495522
// shared informer on PVs
@@ -539,6 +566,9 @@ func init() {
539566
authorizationapi.ClusterRole{
540567
ObjectMeta: kapi.ObjectMeta{
541568
Name: PersistentVolumeBinderControllerRoleName,
569+
Annotations: map[string]string{
570+
roleSystemOnly: roleIsSystemOnly,
571+
},
542572
},
543573
Rules: []authorizationapi.PolicyRule{
544574
// PersistentVolumeBinder.volumeController.ListWatch
@@ -620,6 +650,9 @@ func init() {
620650
authorizationapi.ClusterRole{
621651
ObjectMeta: kapi.ObjectMeta{
622652
Name: PersistentVolumeProvisionerControllerRoleName,
653+
Annotations: map[string]string{
654+
roleSystemOnly: roleIsSystemOnly,
655+
},
623656
},
624657
Rules: []authorizationapi.PolicyRule{
625658
// PersistentVolumeProvisioner.volumeController.ListWatch
@@ -664,6 +697,9 @@ func init() {
664697
authorizationapi.ClusterRole{
665698
ObjectMeta: kapi.ObjectMeta{
666699
Name: DaemonSetControllerRoleName,
700+
Annotations: map[string]string{
701+
roleSystemOnly: roleIsSystemOnly,
702+
},
667703
},
668704
Rules: []authorizationapi.PolicyRule{
669705
// DaemonSetsController.dsStore.ListWatch
@@ -715,6 +751,9 @@ func init() {
715751
authorizationapi.ClusterRole{
716752
ObjectMeta: kapi.ObjectMeta{
717753
Name: DisruptionControllerRoleName,
754+
Annotations: map[string]string{
755+
roleSystemOnly: roleIsSystemOnly,
756+
},
718757
},
719758
Rules: []authorizationapi.PolicyRule{
720759
// DisruptionBudgetController.dStore.ListWatch
@@ -759,6 +798,9 @@ func init() {
759798
authorizationapi.ClusterRole{
760799
ObjectMeta: kapi.ObjectMeta{
761800
Name: NamespaceControllerRoleName,
801+
Annotations: map[string]string{
802+
roleSystemOnly: roleIsSystemOnly,
803+
},
762804
},
763805
Rules: []authorizationapi.PolicyRule{
764806
// Watching/deleting namespaces
@@ -792,6 +834,9 @@ func init() {
792834
authorizationapi.ClusterRole{
793835
ObjectMeta: kapi.ObjectMeta{
794836
Name: GCControllerRoleName,
837+
Annotations: map[string]string{
838+
roleSystemOnly: roleIsSystemOnly,
839+
},
795840
},
796841
Rules: []authorizationapi.PolicyRule{
797842
// GCController.podStore.ListWatch
@@ -824,6 +869,9 @@ func init() {
824869
authorizationapi.ClusterRole{
825870
ObjectMeta: kapi.ObjectMeta{
826871
Name: ServiceLoadBalancerControllerRoleName,
872+
Annotations: map[string]string{
873+
roleSystemOnly: roleIsSystemOnly,
874+
},
827875
},
828876
Rules: []authorizationapi.PolicyRule{
829877
// ServiceController.cache.ListWatch
@@ -867,6 +915,9 @@ func init() {
867915
authorizationapi.ClusterRole{
868916
ObjectMeta: kapi.ObjectMeta{
869917
Name: PetSetControllerRoleName,
918+
Annotations: map[string]string{
919+
roleSystemOnly: roleIsSystemOnly,
920+
},
870921
},
871922
Rules: []authorizationapi.PolicyRule{
872923
// StatefulSetController.podCache.ListWatch
@@ -924,6 +975,9 @@ func init() {
924975
authorizationapi.ClusterRole{
925976
ObjectMeta: kapi.ObjectMeta{
926977
Name: UnidlingControllerRoleName,
978+
Annotations: map[string]string{
979+
roleSystemOnly: roleIsSystemOnly,
980+
},
927981
},
928982
Rules: []authorizationapi.PolicyRule{
929983
{
@@ -973,6 +1027,9 @@ func init() {
9731027
authorizationapi.ClusterRole{
9741028
ObjectMeta: kapi.ObjectMeta{
9751029
Name: ServiceServingCertControllerRoleName,
1030+
Annotations: map[string]string{
1031+
roleSystemOnly: roleIsSystemOnly,
1032+
},
9761033
},
9771034
Rules: []authorizationapi.PolicyRule{
9781035
{
@@ -997,6 +1054,9 @@ func init() {
9971054
authorizationapi.ClusterRole{
9981055
ObjectMeta: kapi.ObjectMeta{
9991056
Name: EndpointControllerRoleName,
1057+
Annotations: map[string]string{
1058+
roleSystemOnly: roleIsSystemOnly,
1059+
},
10001060
},
10011061
Rules: []authorizationapi.PolicyRule{
10021062
// Watching services and pods
@@ -1029,6 +1089,9 @@ func init() {
10291089
authorizationapi.ClusterRole{
10301090
ObjectMeta: kapi.ObjectMeta{
10311091
Name: ServiceIngressIPControllerRoleName,
1092+
Annotations: map[string]string{
1093+
roleSystemOnly: roleIsSystemOnly,
1094+
},
10321095
},
10331096
Rules: []authorizationapi.PolicyRule{
10341097
// Listing and watching services

0 commit comments

Comments
 (0)