Skip to content

Commit

Permalink
fix: Make sure that both DELETE_LOCAL_DATA and DELETE_EMPTY_DIR_DATA …
Browse files Browse the repository at this point in the history
…are supported
  • Loading branch information
TwiN committed Jul 20, 2022
1 parent 2c3bdc0 commit 0c1da21
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,15 @@ func Initialize() error {
if ignoreDaemonSets := strings.ToLower(os.Getenv(EnvIgnoreDaemonSets)); len(ignoreDaemonSets) == 0 || ignoreDaemonSets == "true" {
cfg.IgnoreDaemonSets = true
}
if deleteLocalData := strings.ToLower(os.Getenv(EnvDeleteLocalData)); len(deleteLocalData) == 0 || deleteLocalData == "true" {
// if the deprecated EnvDeleteLocalData is set, we need to set EnvDeleteEmptyDirData to its value
if deleteLocalData := strings.ToLower(os.Getenv(EnvDeleteLocalData)); len(deleteLocalData) > 0 {
log.Println("NOTICE: Environment variable '" + EnvDeleteLocalData + "' has been deprecated in favor of '" + EnvDeleteEmptyDirData + "'.")
log.Println("NOTICE: Make sure to update your configuration, as said deprecated environment variable will be removed in a future release.")
cfg.DeleteEmptyDirData = true
if len(os.Getenv(EnvDeleteEmptyDirData)) == 0 {
_ = os.Setenv(EnvDeleteEmptyDirData, deleteLocalData)
} else {
log.Println("WARNING: Both '" + EnvDeleteLocalData + "' and '" + EnvDeleteEmptyDirData + "' are set. The former is deprecated, and will be ignored.")
}
}
if deleteEmptyDirData := strings.ToLower(os.Getenv(EnvDeleteEmptyDirData)); len(deleteEmptyDirData) == 0 || deleteEmptyDirData == "true" {
cfg.DeleteEmptyDirData = true
Expand Down

0 comments on commit 0c1da21

Please sign in to comment.