File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ package rules
2
+
3
+ import (
4
+ "github.com/octopusdeploy/octopus-permissions-controller/api/v1beta1"
5
+ )
6
+
7
+ type AgentName string
8
+
9
+ type Namespace string
10
+
11
+ type ServiceAccountName string
12
+
13
+ type Scope struct {
14
+ Project string `json:"project"`
15
+ Environment string `json:"environment"`
16
+ Tenant string `json:"tenant"`
17
+ Step string `json:"step"`
18
+ }
19
+
20
+ type Rule struct {
21
+ Permissions v1beta1.WorkloadServiceAccountPermissions `json:"permissions"`
22
+ }
23
+
24
+ type Engine interface {
25
+ GetServiceAccountForScope (scope Scope , agentName AgentName ) (ServiceAccountName , error )
26
+ AddScopeRuleset (scope Scope , rule Rule , targetNamespace Namespace ) error
27
+ RemoveScopeRuleset (scope Scope , rule Rule , targetNamespace Namespace ) error
28
+ }
29
+
30
+ type InMemoryEngine struct {
31
+ rules map [AgentName ]map [Scope ]ServiceAccountName
32
+ // client kubernetes.Interface
33
+ }
34
+
35
+ func (i InMemoryEngine ) GetServiceAccountForScope (scope Scope , agentName AgentName ) (ServiceAccountName , error ) {
36
+ if agentRules , ok := i .rules [agentName ]; ok {
37
+ if sa , ok := agentRules [scope ]; ok {
38
+ return sa , nil
39
+ }
40
+ }
41
+ return "" , nil
42
+ }
43
+
44
+ func (i InMemoryEngine ) AddScopeRuleset (scope Scope , rule Rule , targetNamespace Namespace ) error {
45
+ // TODO: Implement me
46
+ return nil
47
+ }
You can’t perform that action at this time.
0 commit comments