Skip to content

Commit

Permalink
Relocate environment variable use to the agent-specific code path
Browse files Browse the repository at this point in the history
  • Loading branch information
nflynt committed Aug 7, 2023
1 parent 795c94b commit 139ce3c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 3 additions & 1 deletion cmd/agent/main.go
Expand Up @@ -81,7 +81,9 @@ func main() {
}
err = bindingErr
} else if os.Getenv("AD_GUID_CLEANUP") == "true" {
err = clean.UnmigrateAdGUIDUsers(nil, false, false)
dryrun := os.Getenv("DRY_RUN") == "true"
deleteMissingUsers := os.Getenv("AD_DELETE_MISSING_GUID_USERS") == "true"
err = clean.UnmigrateAdGUIDUsers(nil, dryrun, deleteMissingUsers)
} else {
err = run(ctx)
}
Expand Down
10 changes: 4 additions & 6 deletions pkg/agent/clean/active_directory.go
Expand Up @@ -299,13 +299,11 @@ func UnmigrateAdGUIDUsersOnce(sc *config.ScaledContext) error {
// UnmigrateAdGUIDUsers will cycle through all users, ctrb, ptrb, tokens and migrate them to an
// appropriate DN-based PrincipalID.
func UnmigrateAdGUIDUsers(clientConfig *restclient.Config, dryRun bool, deleteMissingUsers bool) error {
if dryRun || os.Getenv("DRY_RUN") == "true" {
logrus.Infof("[%v] DRY_RUN is true, no objects will be deleted/modified", migrateAdUserOperation)
dryRun = true
if dryRun {
logrus.Infof("[%v] dryRun is true, no objects will be deleted/modified", migrateAdUserOperation)
deleteMissingUsers = false
} else if deleteMissingUsers || os.Getenv("AD_DELETE_MISSING_GUID_USERS") == "true" {
logrus.Infof("[%v] AD_DELETE_MISSING_GUID_USERS is true, GUID-based users not present in Active Directory will be deleted", migrateAdUserOperation)
deleteMissingUsers = true
} else if deleteMissingUsers {
logrus.Infof("[%v] deleteMissingUsers is true, GUID-based users not present in Active Directory will be deleted", migrateAdUserOperation)
}

sc, adConfig, err := prepareClientContexts(clientConfig)
Expand Down

0 comments on commit 139ce3c

Please sign in to comment.