Skip to content

Commit

Permalink
🔨 fix blackWhiteList feature
Browse files Browse the repository at this point in the history
Sans ce changement les nouveaux projects ne sont jamais créés si au moins un projet est présent dans le blacklist et que la fonctionnalité whitelist n'est pas activée
  • Loading branch information
pape committed Oct 24, 2024
1 parent efa5cbd commit 1688468
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions internal/services/provisionner.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,25 +71,23 @@ func GenerateProjects(context []*types.Project, blackWhiteList *types.BlackWhite

for _, auth := range context {

// if whitelist boolean set we search namespace in configmap whitelist
if utils.Config.Whitelist { // if configmap with whitelist exist and not empty
if blackWhiteList.Whitelist[0] != "" && utils.Include(blackWhiteList.Whitelist, auth.Namespace()) {
utils.Log.Info().Msgf("Project %s is whitelisted", auth.Namespace())
generateProject(auth)
} else {
utils.Log.Error().Msgf("Cannot find project %s in whitelist", auth.Namespace())
}
} else if blackWhiteList.Blacklist[0] != "" { // if configmap with blacklist exist and not empty
if utils.Include(blackWhiteList.Blacklist, auth.Namespace()) {
utils.Log.Info().Msgf("delete project %s in blacklist", auth.Namespace())
deleteProject(auth)
} else {
utils.Log.Info().Msgf("Cannot find project %s in blacklist", auth.Namespace())
}
} else { // if configmap not exist and bool whitelist is false
switch {
//delete CR project of blacklisted projects
case blackWhiteList.Blacklist[0] != "" && utils.Include(blackWhiteList.Blacklist, auth.Namespace()):
utils.Log.Info().Msgf("delete project %s in blacklist", auth.Namespace())
deleteProject(auth)
continue
//generate whitelisted projects if whitelist feature is activated
case utils.Config.Whitelist == true && utils.Include(blackWhiteList.Whitelist, auth.Namespace()):
utils.Log.Info().Msgf("Project %s is whitelisted", auth.Namespace())
generateProject(auth)
//do not generate project if whitelist feature is activated and project not present on whitelisted projects
case utils.Config.Whitelist == true && !utils.Include(blackWhiteList.Whitelist, auth.Namespace()):
utils.Log.Error().Msgf("Cannot find project %s in whitelist", auth.Namespace())
//generatet project in others cases
default:
generateProject(auth)
}

}
}

Expand Down

0 comments on commit 1688468

Please sign in to comment.