@@ -2,17 +2,18 @@ package auth
2
2
3
3
import "github.com/gaia-pipeline/gaia"
4
4
5
- // Constructor for creating new UserRoleEndpoints.
5
+ // NewUserRoleEndpoint is a constructor for creating new UserRoleEndpoints.
6
6
func NewUserRoleEndpoint (method string , path string ) * gaia.UserRoleEndpoint {
7
7
return & gaia.UserRoleEndpoint {Path : path , Method : method }
8
8
}
9
9
10
- // Creates a full user role name {category}{role}.
10
+ // FullUserRoleName returns a full user role name in the form {category}{role}.
11
11
func FullUserRoleName (category * gaia.UserRoleCategory , role * gaia.UserRole ) string {
12
12
return category .Name + role .Name
13
13
}
14
14
15
- // Flattens the given user categories into a single slice of {category}{role}s.
15
+ // FlattenUserCategoryRoles flattens the given user categories into a single slice with items in the form off
16
+ // {category}{role}s.
16
17
func FlattenUserCategoryRoles (cats []* gaia.UserRoleCategory ) []string {
17
18
var roles []string
18
19
for _ , category := range cats {
@@ -24,15 +25,15 @@ func FlattenUserCategoryRoles(cats []*gaia.UserRoleCategory) []string {
24
25
}
25
26
26
27
var (
27
- // All the default user categories and roles.
28
+ // DefaultUserRoles contains all the default user categories and roles.
28
29
DefaultUserRoles = []* gaia.UserRoleCategory {
29
30
{
30
31
Name : "Pipeline" ,
31
32
Description : "Managing and initiating pipelines." ,
32
33
Roles : []* gaia.UserRole {
33
34
{
34
35
Name : "Create" ,
35
- ApiEndpoint : []* gaia.UserRoleEndpoint {
36
+ APIEndpoint : []* gaia.UserRoleEndpoint {
36
37
NewUserRoleEndpoint ("POST" , "/api/v1/pipeline" ),
37
38
NewUserRoleEndpoint ("POST" , "/api/v1/pipeline/gitlsremote" ),
38
39
NewUserRoleEndpoint ("GET" , "/api/v1/pipeline/name" ),
42
43
},
43
44
{
44
45
Name : "List" ,
45
- ApiEndpoint : []* gaia.UserRoleEndpoint {
46
+ APIEndpoint : []* gaia.UserRoleEndpoint {
46
47
NewUserRoleEndpoint ("GET" , "/api/v1/pipeline/created" ),
47
48
NewUserRoleEndpoint ("GET" , "/api/v1/pipeline" ),
48
49
NewUserRoleEndpoint ("GET" , "/api/v1/pipeline/latest" ),
@@ -51,28 +52,28 @@ var (
51
52
},
52
53
{
53
54
Name : "Get" ,
54
- ApiEndpoint : []* gaia.UserRoleEndpoint {
55
+ APIEndpoint : []* gaia.UserRoleEndpoint {
55
56
NewUserRoleEndpoint ("GET" , "/api/v1/pipeline/:pipelineid" ),
56
57
},
57
58
Description : "Get created pipelines." ,
58
59
},
59
60
{
60
61
Name : "Update" ,
61
- ApiEndpoint : []* gaia.UserRoleEndpoint {
62
+ APIEndpoint : []* gaia.UserRoleEndpoint {
62
63
NewUserRoleEndpoint ("PUT" , "/api/v1/pipeline/:pipelineid" ),
63
64
},
64
65
Description : "Update created pipelines." ,
65
66
},
66
67
{
67
68
Name : "Delete" ,
68
- ApiEndpoint : []* gaia.UserRoleEndpoint {
69
+ APIEndpoint : []* gaia.UserRoleEndpoint {
69
70
NewUserRoleEndpoint ("DELETE" , "/api/v1/pipeline/:pipelineid" ),
70
71
},
71
72
Description : "Delete created pipelines." ,
72
73
},
73
74
{
74
75
Name : "Start" ,
75
- ApiEndpoint : []* gaia.UserRoleEndpoint {
76
+ APIEndpoint : []* gaia.UserRoleEndpoint {
76
77
NewUserRoleEndpoint ("POST" , "/api/v1/pipeline/:pipelineid/start" ),
77
78
},
78
79
Description : "Start created pipelines." ,
@@ -85,29 +86,29 @@ var (
85
86
Roles : []* gaia.UserRole {
86
87
{
87
88
Name : "Stop" ,
88
- ApiEndpoint : []* gaia.UserRoleEndpoint {
89
+ APIEndpoint : []* gaia.UserRoleEndpoint {
89
90
NewUserRoleEndpoint ("POST" , "/api/v1/pipelinerun/:pipelineid/:runid/stop" ),
90
91
},
91
92
Description : "Stop running pipelines." ,
92
93
},
93
94
{
94
95
Name : "Get" ,
95
- ApiEndpoint : []* gaia.UserRoleEndpoint {
96
+ APIEndpoint : []* gaia.UserRoleEndpoint {
96
97
NewUserRoleEndpoint ("GET" , "/api/v1/pipelinerun/:pipelineid/:runid" ),
97
98
NewUserRoleEndpoint ("GET" , "/api/v1/pipelinerun/:pipelineid/latest" ),
98
99
},
99
100
Description : "Get pipeline runs." ,
100
101
},
101
102
{
102
103
Name : "List" ,
103
- ApiEndpoint : []* gaia.UserRoleEndpoint {
104
+ APIEndpoint : []* gaia.UserRoleEndpoint {
104
105
NewUserRoleEndpoint ("GET" , "pipelinerun/:pipelineid" ),
105
106
},
106
107
Description : "List pipeline runs." ,
107
108
},
108
109
{
109
110
Name : "Logs" ,
110
- ApiEndpoint : []* gaia.UserRoleEndpoint {
111
+ APIEndpoint : []* gaia.UserRoleEndpoint {
111
112
NewUserRoleEndpoint ("GET" , "/api/v1/pipelinerun/:pipelineid/:runid/latest" ),
112
113
},
113
114
Description : "Get logs for pipeline runs." ,
@@ -120,28 +121,28 @@ var (
120
121
Roles : []* gaia.UserRole {
121
122
{
122
123
Name : "List" ,
123
- ApiEndpoint : []* gaia.UserRoleEndpoint {
124
+ APIEndpoint : []* gaia.UserRoleEndpoint {
124
125
NewUserRoleEndpoint ("GET" , "/api/v1/secrets" ),
125
126
},
126
127
Description : "List created secrets." ,
127
128
},
128
129
{
129
130
Name : "Delete" ,
130
- ApiEndpoint : []* gaia.UserRoleEndpoint {
131
+ APIEndpoint : []* gaia.UserRoleEndpoint {
131
132
NewUserRoleEndpoint ("DELETE" , "/api/v1/secret/:key" ),
132
133
},
133
134
Description : "Delete created secrets." ,
134
135
},
135
136
{
136
137
Name : "Create" ,
137
- ApiEndpoint : []* gaia.UserRoleEndpoint {
138
+ APIEndpoint : []* gaia.UserRoleEndpoint {
138
139
NewUserRoleEndpoint ("POST" , "/api/v1/secret" ),
139
140
},
140
141
Description : "Create new secrets." ,
141
142
},
142
143
{
143
144
Name : "Update" ,
144
- ApiEndpoint : []* gaia.UserRoleEndpoint {
145
+ APIEndpoint : []* gaia.UserRoleEndpoint {
145
146
NewUserRoleEndpoint ("PUT" , "/api/v1/secret/update" ),
146
147
},
147
148
Description : "Update created secrets." ,
@@ -154,28 +155,28 @@ var (
154
155
Roles : []* gaia.UserRole {
155
156
{
156
157
Name : "Create" ,
157
- ApiEndpoint : []* gaia.UserRoleEndpoint {
158
+ APIEndpoint : []* gaia.UserRoleEndpoint {
158
159
NewUserRoleEndpoint ("POST" , "/api/v1/user" ),
159
160
},
160
161
Description : "Create new users." ,
161
162
},
162
163
{
163
164
Name : "List" ,
164
- ApiEndpoint : []* gaia.UserRoleEndpoint {
165
+ APIEndpoint : []* gaia.UserRoleEndpoint {
165
166
NewUserRoleEndpoint ("GET" , "/api/v1/users" ),
166
167
},
167
168
Description : "List created users." ,
168
169
},
169
170
{
170
171
Name : "ChangePassword" ,
171
- ApiEndpoint : []* gaia.UserRoleEndpoint {
172
+ APIEndpoint : []* gaia.UserRoleEndpoint {
172
173
NewUserRoleEndpoint ("POST" , "/api/v1/user/password" ),
173
174
},
174
175
Description : "Change created users passwords." ,
175
176
},
176
177
{
177
178
Name : "Delete" ,
178
- ApiEndpoint : []* gaia.UserRoleEndpoint {
179
+ APIEndpoint : []* gaia.UserRoleEndpoint {
179
180
NewUserRoleEndpoint ("DELETE" , "/api/v1/user/:username" ),
180
181
},
181
182
Description : "Delete created users." ,
@@ -188,14 +189,14 @@ var (
188
189
Roles : []* gaia.UserRole {
189
190
{
190
191
Name : "Get" ,
191
- ApiEndpoint : []* gaia.UserRoleEndpoint {
192
+ APIEndpoint : []* gaia.UserRoleEndpoint {
192
193
NewUserRoleEndpoint ("GET" , "/api/v1/user/:username/permissions" ),
193
194
},
194
195
Description : "Get created users permissions." ,
195
196
},
196
197
{
197
198
Name : "Update" ,
198
- ApiEndpoint : []* gaia.UserRoleEndpoint {
199
+ APIEndpoint : []* gaia.UserRoleEndpoint {
199
200
NewUserRoleEndpoint ("PUT" , "/api/v1/user/:username/permissions" ),
200
201
},
201
202
Description : "Update created users permissions." ,
0 commit comments