From 16884687bd322c854754eedc61a1ae6692732d7f Mon Sep 17 00:00:00 2001 From: pape Date: Thu, 24 Oct 2024 10:54:05 +0200 Subject: [PATCH] :hammer: fix blackWhiteList feature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- internal/services/provisionner.go | 32 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/internal/services/provisionner.go b/internal/services/provisionner.go index 14f90eed..a15d910b 100644 --- a/internal/services/provisionner.go +++ b/internal/services/provisionner.go @@ -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) } - } }