@@ -19,6 +19,9 @@ type AgentRBACManifests struct {
19
19
RoleBindings []rbac.RoleBinding
20
20
}
21
21
22
+ const agentNamespace = "jetstack-secure"
23
+ const agentSubjectName = "agent"
24
+
22
25
//func GenerateAgentRBACManifests(dataGatherers []agent.DataGatherer, konwnNamespaces []string) AgentRBACManifests {
23
26
func GenerateAgentRBACManifests (dataGatherers []agent.DataGatherer ) AgentRBACManifests {
24
27
// create a new AgentRBACManifest struct
@@ -30,9 +33,8 @@ func GenerateAgentRBACManifests(dataGatherers []agent.DataGatherer) AgentRBACMan
30
33
}
31
34
32
35
dyConfig := dg .Config .(* k8s.ConfigDynamic )
33
- metadataName := fmt .Sprintf ("jetstack-secure- agent-%s-reader" , dyConfig .GroupVersionResource .Resource )
36
+ metadataName := fmt .Sprintf ("%s- agent-%s-reader" , agentNamespace , dyConfig .GroupVersionResource .Resource )
34
37
35
- // always do this...
36
38
AgentRBACManifests .ClusterRoles = append (AgentRBACManifests .ClusterRoles , rbac.ClusterRole {
37
39
TypeMeta : metav1.TypeMeta {
38
40
Kind : "ClusterRole" ,
@@ -52,7 +54,6 @@ func GenerateAgentRBACManifests(dataGatherers []agent.DataGatherer) AgentRBACMan
52
54
53
55
// if dyConfig.IncludeNamespaces has more than 0 items in it
54
56
// then, for each namespace create a rbac.RoleBinding in that namespace
55
- // AgentRBACManifests.RoleBindings = append(...)
56
57
if len (dyConfig .IncludeNamespaces ) != 0 {
57
58
for _ , ns := range dyConfig .IncludeNamespaces {
58
59
AgentRBACManifests .RoleBindings = append (AgentRBACManifests .RoleBindings , rbac.RoleBinding {
@@ -69,8 +70,8 @@ func GenerateAgentRBACManifests(dataGatherers []agent.DataGatherer) AgentRBACMan
69
70
Subjects : []rbac.Subject {
70
71
{
71
72
Kind : "ServiceAccount" ,
72
- Name : "agent" ,
73
- Namespace : "jetstack-secure" ,
73
+ Name : agentSubjectName ,
74
+ Namespace : agentNamespace ,
74
75
},
75
76
},
76
77
@@ -96,8 +97,8 @@ func GenerateAgentRBACManifests(dataGatherers []agent.DataGatherer) AgentRBACMan
96
97
Subjects : []rbac.Subject {
97
98
{
98
99
Kind : "ServiceAccount" ,
99
- Name : "agent" ,
100
- Namespace : "jetstack-secure" ,
100
+ Name : agentSubjectName ,
101
+ Namespace : agentNamespace ,
101
102
},
102
103
},
103
104
0 commit comments