Skip to content

Commit

Permalink
(upgrade_to_v3): simplify code in fluentd logs config migration
Browse files Browse the repository at this point in the history
  • Loading branch information
kasia-kujawa committed Dec 15, 2022
1 parent 92bba78 commit 3e25b18
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func isLogsMigrationNeeded(configV2 *LogsConfig) bool {
configV2.ExcludeUnitRegex != nil {
return true
}

return false
}

Expand Down Expand Up @@ -112,31 +111,26 @@ func setSumologicLogsContainer(fluendLogsContainersV2 *ContainersLogsConfig, sum
}

func isLogRestEmpty(config *LogsConfig) bool {
if config == nil {
return true
} else if config.Rest == nil {
if config == nil || config.Rest == nil {
return true
}
return false
}

func isContainersLogRestEmpty(config *ContainersLogsConfig) bool {
if config == nil {
return true
} else if config.Rest == nil {
if config == nil || config.Rest == nil {
return true
}
return false
}

func isFluentdV3Empty(fluentdV2 *Fluentd) bool {
if fluentdV2 == nil {
return true
} else if fluentdV2.Rest == nil &&
isContainersLogRestEmpty(fluentdV2.Logs.Containers) &&
isLogRestEmpty(fluentdV2.Logs.Systemd) &&
isLogRestEmpty(fluentdV2.Logs.Kubelet) &&
isLogRestEmpty(fluentdV2.Logs.Default) {
if fluentdV2 == nil ||
(fluentdV2.Rest == nil &&
isContainersLogRestEmpty(fluentdV2.Logs.Containers) &&
isLogRestEmpty(fluentdV2.Logs.Systemd) &&
isLogRestEmpty(fluentdV2.Logs.Kubelet) &&
isLogRestEmpty(fluentdV2.Logs.Default)) {
return true
}
return false
Expand All @@ -148,7 +142,6 @@ func setFluentdLogsContainersConfig(containersConfigV2 *ContainersLogsConfig) *C
Rest: containersConfigV2.Rest,
}
}

return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ sumologic:
logs:
enabled: true
metadata:
provider: fluentd
provider: fluentd

0 comments on commit 3e25b18

Please sign in to comment.