@@ -18,46 +18,57 @@ limitations under the License.
1818import (
1919 "bufio"
2020 "errors"
21- log "github.com/Sirupsen/logrus"
2221 "os"
2322 "strings"
23+
24+ log "github.com/Sirupsen/logrus"
2425)
2526
26- const RESTORE_PERM = "Restore"
27- const SHOW_SECRETS_PERM = "ShowSecrets"
28- const RELOAD_PERM = "Reload"
29- const SHOW_CONFIG_PERM = "ShowConfig"
27+ // MISC
28+ const APPLY_POLICY_PERM = "ApplyPolicy"
3029const DF_CLUSTER_PERM = "DfCluster"
31- const SHOW_CLUSTER_PERM = "ShowCluster"
32- const CREATE_CLUSTER_PERM = "CreateCluster"
33- const TEST_CLUSTER_PERM = "TestCluster"
34- const DELETE_CLUSTER_PERM = "DeleteCluster"
35- const SHOW_BACKUP_PERM = "ShowBackup"
36- const CREATE_BACKUP_PERM = "CreateBackup"
37- const DELETE_BACKUP_PERM = "DeleteBackup"
3830const LABEL_PERM = "Label"
3931const LOAD_PERM = "Load"
40- const CREATE_POLICY_PERM = "CreatePolicy"
41- const DELETE_POLICY_PERM = "DeletePolicy"
42- const SHOW_POLICY_PERM = "ShowPolicy"
43- const APPLY_POLICY_PERM = "ApplyPolicy"
44- const SHOW_PVC_PERM = "ShowPVC"
45- const CREATE_UPGRADE_PERM = "CreateUpgrade"
46- const SHOW_UPGRADE_PERM = "ShowUpgrade"
47- const DELETE_UPGRADE_PERM = "DeleteUpgrade"
32+ const RELOAD_PERM = "Reload"
33+ const RESTORE_PERM = "Restore"
34+ const STATUS_PERM = "Status"
35+ const TEST_CLUSTER_PERM = "TestCluster"
4836const USER_PERM = "User"
49- const CREATE_USER_PERM = "CreateUser"
50- const DELETE_USER_PERM = "DeleteUser"
5137const VERSION_PERM = "Version"
52- const CREATE_INGEST_PERM = "CreateIngest"
53- const SHOW_INGEST_PERM = "ShowIngest"
54- const DELETE_INGEST_PERM = "DeleteIngest"
38+
39+ // CREATE
40+ const CREATE_BACKUP_PERM = "CreateBackup"
41+ const CREATE_CLUSTER_PERM = "CreateCluster"
5542const CREATE_FAILOVER_PERM = "CreateFailover"
56- const STATUS_PERM = "Status "
43+ const CREATE_INGEST_PERM = "CreateIngest "
5744const CREATE_PGBOUNCER_PERM = "CreatePgbouncer"
58- const DELETE_PGBOUNCER_PERM = "DeletePgbouncer"
5945const CREATE_PGPOOL_PERM = "CreatePgpool"
46+ const CREATE_POLICY_PERM = "CreatePolicy"
47+ const CREATE_SCHEDULE_PERM = "CreateSchedule"
48+ const CREATE_UPGRADE_PERM = "CreateUpgrade"
49+ const CREATE_USER_PERM = "CreateUser"
50+
51+ // DELETE
52+ const DELETE_BACKUP_PERM = "DeleteBackup"
53+ const DELETE_CLUSTER_PERM = "DeleteCluster"
54+ const DELETE_INGEST_PERM = "DeleteIngest"
55+ const DELETE_PGBOUNCER_PERM = "DeletePgbouncer"
6056const DELETE_PGPOOL_PERM = "DeletePgpool"
57+ const DELETE_POLICY_PERM = "DeletePolicy"
58+ const DELETE_SCHEDULE_PERM = "DeleteSchedule"
59+ const DELETE_UPGRADE_PERM = "DeleteUpgrade"
60+ const DELETE_USER_PERM = "DeleteUser"
61+
62+ // SHOW
63+ const SHOW_BACKUP_PERM = "ShowBackup"
64+ const SHOW_CLUSTER_PERM = "ShowCluster"
65+ const SHOW_CONFIG_PERM = "ShowConfig"
66+ const SHOW_INGEST_PERM = "ShowIngest"
67+ const SHOW_POLICY_PERM = "ShowPolicy"
68+ const SHOW_PVC_PERM = "ShowPVC"
69+ const SHOW_SCHEDULE_PERM = "ShowSchedule"
70+ const SHOW_SECRETS_PERM = "ShowSecrets"
71+ const SHOW_UPGRADE_PERM = "ShowUpgrade"
6172
6273var RoleMap map [string ]map [string ]string
6374var PermMap map [string ]string
@@ -68,42 +79,49 @@ func InitializePerms() {
6879 PermMap = make (map [string ]string )
6980 RoleMap = make (map [string ]map [string ]string )
7081
71- PermMap [SHOW_SECRETS_PERM ] = "yes"
82+ // MISC
83+ PermMap [APPLY_POLICY_PERM ] = "yes"
84+ PermMap [DF_CLUSTER_PERM ] = "yes"
85+ PermMap [LABEL_PERM ] = "yes"
86+ PermMap [LOAD_PERM ] = "yes"
7287 PermMap [RELOAD_PERM ] = "yes"
73- PermMap [SHOW_CONFIG_PERM ] = "yes"
88+ PermMap [RESTORE_PERM ] = "yes"
7489 PermMap [STATUS_PERM ] = "yes"
75- PermMap [DF_CLUSTER_PERM ] = "yes"
76- PermMap [SHOW_CLUSTER_PERM ] = "yes"
77- PermMap [CREATE_CLUSTER_PERM ] = "yes"
78- PermMap [DELETE_CLUSTER_PERM ] = "yes"
7990 PermMap [TEST_CLUSTER_PERM ] = "yes"
80- PermMap [SHOW_BACKUP_PERM ] = "yes"
91+ PermMap [USER_PERM ] = "yes"
92+ PermMap [VERSION_PERM ] = "yes"
93+ // Create
8194 PermMap [CREATE_BACKUP_PERM ] = "yes"
82- PermMap [DELETE_BACKUP_PERM ] = "yes"
83- PermMap [LABEL_PERM ] = "yes"
84- PermMap [LOAD_PERM ] = "yes"
95+ PermMap [CREATE_CLUSTER_PERM ] = "yes"
96+ PermMap [CREATE_FAILOVER_PERM ] = "yes"
97+ PermMap [CREATE_INGEST_PERM ] = "yes"
98+ PermMap [CREATE_PGBOUNCER_PERM ] = "yes"
99+ PermMap [CREATE_PGPOOL_PERM ] = "yes"
85100 PermMap [CREATE_POLICY_PERM ] = "yes"
86- PermMap [DELETE_POLICY_PERM ] = "yes"
87- PermMap [SHOW_POLICY_PERM ] = "yes"
88- PermMap [APPLY_POLICY_PERM ] = "yes"
89- PermMap [SHOW_PVC_PERM ] = "yes"
101+ PermMap [CREATE_SCHEDULE_PERM ] = "yes"
90102 PermMap [CREATE_UPGRADE_PERM ] = "yes"
91- PermMap [SHOW_UPGRADE_PERM ] = "yes"
92- PermMap [DELETE_UPGRADE_PERM ] = "yes"
93- PermMap [USER_PERM ] = "yes"
94103 PermMap [CREATE_USER_PERM ] = "yes"
95- PermMap [DELETE_USER_PERM ] = "yes"
96- PermMap [VERSION_PERM ] = "yes"
97- PermMap [CREATE_INGEST_PERM ] = "yes"
98- PermMap [SHOW_INGEST_PERM ] = "yes"
104+ // Delete
105+ PermMap [DELETE_BACKUP_PERM ] = "yes"
106+ PermMap [DELETE_CLUSTER_PERM ] = "yes"
99107 PermMap [DELETE_INGEST_PERM ] = "yes"
100- PermMap [CREATE_FAILOVER_PERM ] = "yes"
101- PermMap [RESTORE_PERM ] = "yes"
102- PermMap [CREATE_PGBOUNCER_PERM ] = "yes"
103108 PermMap [DELETE_PGBOUNCER_PERM ] = "yes"
104- PermMap [CREATE_PGPOOL_PERM ] = "yes"
105109 PermMap [DELETE_PGPOOL_PERM ] = "yes"
106- log .Infof ("loading PermMap with %d Permissions" , len (PermMap ))
110+ PermMap [DELETE_POLICY_PERM ] = "yes"
111+ PermMap [DELETE_SCHEDULE_PERM ] = "yes"
112+ PermMap [DELETE_UPGRADE_PERM ] = "yes"
113+ PermMap [DELETE_USER_PERM ] = "yes"
114+ // Show
115+ PermMap [SHOW_BACKUP_PERM ] = "yes"
116+ PermMap [SHOW_CLUSTER_PERM ] = "yes"
117+ PermMap [SHOW_CONFIG_PERM ] = "yes"
118+ PermMap [SHOW_INGEST_PERM ] = "yes"
119+ PermMap [SHOW_POLICY_PERM ] = "yes"
120+ PermMap [SHOW_PVC_PERM ] = "yes"
121+ PermMap [SHOW_SCHEDULE_PERM ] = "yes"
122+ PermMap [SHOW_SECRETS_PERM ] = "yes"
123+ PermMap [SHOW_UPGRADE_PERM ] = "yes"
124+ log .Infof ("loading PermMap with %d Permissions\n " , len (PermMap ))
107125
108126 readRoles ()
109127}
0 commit comments