@@ -128,7 +128,7 @@ func (impl EnforcerUtilImpl) GetRbacObjectsByEnvIdsAndAppId(envIds []int, appId
128
128
129
129
for _ , env := range envs {
130
130
if _ , ok := objects [env .Id ]; ! ok {
131
- objects [env .Id ] = fmt .Sprintf ("%s/%s" , env .EnvironmentIdentifier , appName )
131
+ objects [env .Id ] = strings . ToLower ( fmt .Sprintf ("%s/%s" , env .EnvironmentIdentifier , appName ) )
132
132
envObjectToName [objects [env.Id ]] = env .Name
133
133
}
134
134
}
@@ -144,7 +144,7 @@ func (impl EnforcerUtilImpl) GetRbacObjectsByAppIds(appIds []int) map[int]string
144
144
}
145
145
for _ , item := range result {
146
146
if _ , ok := objects [item .Id ]; ! ok {
147
- objects [item .Id ] = fmt .Sprintf ("%s/%s" , item .Team .Name , item .AppName )
147
+ objects [item .Id ] = strings . ToLower ( fmt .Sprintf ("%s/%s" , item .Team .Name , item .AppName ) )
148
148
}
149
149
}
150
150
return objects
@@ -174,7 +174,7 @@ func (impl EnforcerUtilImpl) GetRbacObjectsForAllApps(appType helper.AppType) ma
174
174
}
175
175
for _ , item := range result {
176
176
if _ , ok := objects [item .Id ]; ! ok {
177
- objects [item .Id ] = fmt .Sprintf ("%s/%s" , item .Team .Name , strings . ToLower ( item .AppName ))
177
+ objects [item .Id ] = strings . ToLower ( fmt .Sprintf ("%s/%s" , item .Team .Name , item .AppName ))
178
178
}
179
179
}
180
180
return objects
@@ -188,7 +188,7 @@ func (impl EnforcerUtilImpl) GetRbacObjectsForAllAppsWithTeamID(teamID int, appT
188
188
}
189
189
for _ , item := range result {
190
190
if _ , ok := objects [item .Id ]; ! ok {
191
- objects [item .Id ] = fmt .Sprintf ("%s/%s" , item .Team .Name , strings .ToLower (item .AppName ))
191
+ objects [item .Id ] = strings . ToLower ( fmt .Sprintf ("%s/%s" , item .Team .Name , strings .ToLower (item .AppName ) ))
192
192
}
193
193
}
194
194
return objects
@@ -425,16 +425,16 @@ func (impl EnforcerUtilImpl) GetHelmObjectByAppNameAndEnvId(appName string, envI
425
425
}
426
426
}
427
427
if environmentIdentifier2 == "" {
428
- return fmt .Sprintf ("%s/%s/%s" , application .Team .Name , environmentIdentifier , application .AppName ), ""
428
+ return strings . ToLower ( fmt .Sprintf ("%s/%s/%s" , application .Team .Name , environmentIdentifier , application .AppName ) ), ""
429
429
}
430
430
431
431
//TODO - FIX required for futuristic permission for cluster__* all environment for migrated environment identifier only
432
432
/*//here cluster, env, namespace must not have double underscore in names, as we are using that for separator.
433
433
if !strings.HasPrefix(env.EnvironmentIdentifier, fmt.Sprintf("%s__", env.Cluster.ClusterName)) {
434
434
environmentIdentifier = fmt.Sprintf("%s__%s", env.Cluster.ClusterName, env.EnvironmentIdentifier)
435
435
}*/
436
- return fmt .Sprintf ("%s/%s/%s" , application .Team .Name , environmentIdentifier , application .AppName ),
437
- fmt .Sprintf ("%s/%s/%s" , application .Team .Name , environmentIdentifier2 , application .AppName )
436
+ return strings . ToLower ( fmt .Sprintf ("%s/%s/%s" , application .Team .Name , environmentIdentifier , application .AppName ) ),
437
+ strings . ToLower ( fmt .Sprintf ("%s/%s/%s" , application .Team .Name , environmentIdentifier2 , application .AppName ) )
438
438
}
439
439
440
440
func (impl EnforcerUtilImpl ) GetHelmObjectByProjectIdAndEnvId (teamId int , envId int ) (string , string ) {
@@ -517,7 +517,7 @@ func (impl EnforcerUtilImpl) GetAppObjectByCiPipelineIds(ciPipelineIds []int) ma
517
517
}
518
518
for _ , pipeline := range models {
519
519
if _ , ok := objects [pipeline .Id ]; ! ok {
520
- appObject := fmt .Sprintf ("%s/%s" , pipeline .App .Team .Name , pipeline .App .AppName )
520
+ appObject := strings . ToLower ( fmt .Sprintf ("%s/%s" , pipeline .App .Team .Name , pipeline .App .AppName ) )
521
521
objects [pipeline .Id ] = appObject
522
522
}
523
523
}
@@ -533,8 +533,8 @@ func (impl EnforcerUtilImpl) GetAppAndEnvObjectByPipelineIds(cdPipelineIds []int
533
533
}
534
534
for _ , pipeline := range models {
535
535
if _ , ok := objects [pipeline .Id ]; ! ok {
536
- appObject := fmt .Sprintf ("%s/%s" , pipeline .App .Team .Name , pipeline .App .AppName )
537
- envObject := fmt .Sprintf ("%s/%s" , pipeline .Environment .EnvironmentIdentifier , pipeline .App .AppName )
536
+ appObject := strings . ToLower ( fmt .Sprintf ("%s/%s" , pipeline .App .Team .Name , pipeline .App .AppName ) )
537
+ envObject := strings . ToLower ( fmt .Sprintf ("%s/%s" , pipeline .Environment .EnvironmentIdentifier , pipeline .App .AppName ) )
538
538
objects [pipeline .Id ] = []string {appObject , envObject }
539
539
}
540
540
}
@@ -549,7 +549,7 @@ func (impl EnforcerUtilImpl) GetRbacObjectsForAllAppsWithMatchingAppName(appName
549
549
}
550
550
for _ , item := range result {
551
551
if _ , ok := objects [item .Id ]; ! ok {
552
- objects [item .Id ] = fmt .Sprintf ("%s/%s" , item .Team .Name , strings . ToLower ( item .AppName ))
552
+ objects [item .Id ] = strings . ToLower ( fmt .Sprintf ("%s/%s" , item .Team .Name , item .AppName ))
553
553
}
554
554
}
555
555
return objects
@@ -572,8 +572,8 @@ func (impl EnforcerUtilImpl) GetAppAndEnvObjectByPipeline(cdPipelines []*bean.CD
572
572
}
573
573
for _ , pipeline := range cdPipelines {
574
574
if _ , ok := objects [pipeline .Id ]; ! ok {
575
- appObject := fmt .Sprintf ("%s/%s" , teamMap [pipeline .TeamId ], pipeline .AppName )
576
- envObject := fmt .Sprintf ("%s/%s" , pipeline .EnvironmentIdentifier , pipeline .AppName )
575
+ appObject := strings . ToLower ( fmt .Sprintf ("%s/%s" , teamMap [pipeline .TeamId ], pipeline .AppName ) )
576
+ envObject := strings . ToLower ( fmt .Sprintf ("%s/%s" , pipeline .EnvironmentIdentifier , pipeline .AppName ) )
577
577
objects [pipeline .Id ] = []string {appObject , envObject }
578
578
}
579
579
}
@@ -599,8 +599,8 @@ func (impl EnforcerUtilImpl) GetAppAndEnvObjectByDbPipeline(cdPipelines []*pipel
599
599
}
600
600
for _ , pipeline := range cdPipelines {
601
601
if _ , ok := objects [pipeline .Id ]; ! ok {
602
- appObject := fmt .Sprintf ("%s/%s" , teamMap [pipeline .App .TeamId ], pipeline .App .AppName )
603
- envObject := fmt .Sprintf ("%s/%s" , pipeline .Environment .EnvironmentIdentifier , pipeline .App .AppName )
602
+ appObject := strings . ToLower ( fmt .Sprintf ("%s/%s" , teamMap [pipeline .App .TeamId ], pipeline .App .AppName ) )
603
+ envObject := strings . ToLower ( fmt .Sprintf ("%s/%s" , pipeline .Environment .EnvironmentIdentifier , pipeline .App .AppName ) )
604
604
objects [pipeline .Id ] = []string {appObject , envObject }
605
605
}
606
606
}
@@ -681,7 +681,7 @@ func (impl EnforcerUtilImpl) GetAllWorkflowRBACObjectsByAppId(appId int, workflo
681
681
teamName := application .Team .Name
682
682
objects := make (map [int ]string , len (workflowNames ))
683
683
for index , wfName := range workflowNames {
684
- objects [workflowIds [index ]] = fmt .Sprintf ("%s/%s/%s" , teamName , appName , wfName )
684
+ objects [workflowIds [index ]] = strings . ToLower ( fmt .Sprintf ("%s/%s/%s" , teamName , appName , wfName ) )
685
685
}
686
686
return objects
687
687
}
0 commit comments