Skip to content

Commit

Permalink
Refactor function
Browse files Browse the repository at this point in the history
  • Loading branch information
mrodm committed Sep 20, 2024
1 parent dbddcd2 commit b8eeaa5
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions internal/install/application_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,29 +163,34 @@ func selectElasticAgentImageName(version, agentBaseImage string) string {
return elasticAgentWolfiImageName
}

disableWolfiImages := false
valueEnv, ok := os.LookupEnv(disableElasticAgentWolfiEnvVar)
if ok && strings.ToLower(valueEnv) != "false" {
disableWolfiImages = true
}
shouldUseWolfiImage := shouldUseWolfiImages(v)

shouldUseWolfiImages := !disableWolfiImages && !v.LessThan(elasticAgentWolfiVersion)
switch agentBaseImage {
case "systemd":
return selectElasticAgentSystemDImageName(v)
case "complete":
if shouldUseWolfiImages {
if shouldUseWolfiImage {
return elasticAgentCompleteWolfiImageName
}
return selectElasticAgentCompleteImageName(v)
default:
if shouldUseWolfiImages {
if shouldUseWolfiImage {
return elasticAgentWolfiImageName
}
return selectElasticAgentCompleteImageName(v)
}
}

func shouldUseWolfiImages(version *semver.Version) bool {
disableWolfiImages := false
valueEnv, ok := os.LookupEnv(disableElasticAgentWolfiEnvVar)
if ok && strings.ToLower(valueEnv) != "false" {
disableWolfiImages = true
}

return !disableWolfiImages && !version.LessThan(elasticAgentWolfiVersion)
}

func selectElasticAgentCompleteImageName(version *semver.Version) string {
switch {
case !version.LessThan(elasticAgentCompleteOwnNamespaceVersion):
Expand Down

0 comments on commit b8eeaa5

Please sign in to comment.