forked from kubesphere/kubesphere
-
Notifications
You must be signed in to change notification settings - Fork 0
/
role.go
89 lines (78 loc) · 4.66 KB
/
role.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
Copyright 2020 The KubeSphere Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package devops
// define the id of global permission items
type GlobalPermissionIds struct {
Administer bool `json:"hudson.model.Hudson.Administer"`
GlobalRead bool `json:"hudson.model.Hudson.Read"`
CredentialCreate bool `json:"com.cloudbees.plugins.credentials.CredentialsProvider.Create"`
CredentialUpdate bool `json:"com.cloudbees.plugins.credentials.CredentialsProvider.Update"`
CredentialView bool `json:"com.cloudbees.plugins.credentials.CredentialsProvider.View"`
CredentialDelete bool `json:"com.cloudbees.plugins.credentials.CredentialsProvider.Delete"`
CredentialManageDomains bool `json:"com.cloudbees.plugins.credentials.CredentialsProvider.ManageDomains"`
SlaveCreate bool `json:"hudson.model.Computer.Create"`
SlaveConfigure bool `json:"hudson.model.Computer.Configure"`
SlaveDelete bool `json:"hudson.model.Computer.Delete"`
SlaveBuild bool `json:"hudson.model.Computer.Build"`
SlaveConnect bool `json:"hudson.model.Computer.Connect"`
SlaveDisconnect bool `json:"hudson.model.Computer.Disconnect"`
ItemBuild bool `json:"hudson.model.Item.Build"`
ItemCreate bool `json:"hudson.model.Item.Create"`
ItemRead bool `json:"hudson.model.Item.Read"`
ItemConfigure bool `json:"hudson.model.Item.Configure"`
ItemCancel bool `json:"hudson.model.Item.Cancel"`
ItemMove bool `json:"hudson.model.Item.Move"`
ItemDiscover bool `json:"hudson.model.Item.Discover"`
ItemWorkspace bool `json:"hudson.model.Item.Workspace"`
ItemDelete bool `json:"hudson.model.Item.Delete"`
RunUpdate bool `json:"hudson.model.Run.Update"`
RunDelete bool `json:"hudson.model.Run.Delete"`
ViewCreate bool `json:"hudson.model.View.Create"`
ViewConfigure bool `json:"hudson.model.View.Configure"`
ViewRead bool `json:"hudson.model.View.Read"`
ViewDelete bool `json:"hudson.model.View.Delete"`
SCMTag bool `json:"hudson.scm.SCM.Tag"`
}
// define the id of project permission items
type ProjectPermissionIds struct {
CredentialCreate bool `json:"com.cloudbees.plugins.credentials.CredentialsProvider.Create"`
CredentialUpdate bool `json:"com.cloudbees.plugins.credentials.CredentialsProvider.Update"`
CredentialView bool `json:"com.cloudbees.plugins.credentials.CredentialsProvider.View"`
CredentialDelete bool `json:"com.cloudbees.plugins.credentials.CredentialsProvider.Delete"`
CredentialManageDomains bool `json:"com.cloudbees.plugins.credentials.CredentialsProvider.ManageDomains"`
ItemBuild bool `json:"hudson.model.Item.Build"`
ItemCreate bool `json:"hudson.model.Item.Create"`
ItemRead bool `json:"hudson.model.Item.Read"`
ItemConfigure bool `json:"hudson.model.Item.Configure"`
ItemCancel bool `json:"hudson.model.Item.Cancel"`
ItemMove bool `json:"hudson.model.Item.Move"`
ItemDiscover bool `json:"hudson.model.Item.Discover"`
ItemWorkspace bool `json:"hudson.model.Item.Workspace"`
ItemDelete bool `json:"hudson.model.Item.Delete"`
RunUpdate bool `json:"hudson.model.Run.Update"`
RunDelete bool `json:"hudson.model.Run.Delete"`
RunReplay bool `json:"hudson.model.Run.Replay"`
SCMTag bool `json:"hudson.scm.SCM.Tag"`
}
// describe the interface of DevOps to operator role
type RoleOperator interface {
AddGlobalRole(roleName string, ids GlobalPermissionIds, overwrite bool) error
GetGlobalRole(roleName string) (string, error)
AddProjectRole(roleName string, pattern string, ids ProjectPermissionIds, overwrite bool) error
DeleteProjectRoles(roleName ...string) error
AssignProjectRole(roleName string, sid string) error
UnAssignProjectRole(roleName string, sid string) error
AssignGlobalRole(roleName string, sid string) error
UnAssignGlobalRole(roleName string, sid string) error
DeleteUserInProject(sid string) error
}