From b4d9f959edddcf80c69777aec50ee30cdc3988e2 Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Wed, 17 Jul 2024 11:48:01 -0400 Subject: [PATCH] bootstrap/common: use switch to satisfy golint golint was complaining about: ``` pkg/asset/ignition/bootstrap/common.go:406:2: ifElseChain: rewrite if-else to switch statement (gocritic) if parentDir == "bin" || parentDir == "dispatcher.d" || parentDir == "system-generators" { ^ ``` --- pkg/asset/ignition/bootstrap/common.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/asset/ignition/bootstrap/common.go b/pkg/asset/ignition/bootstrap/common.go index 13182760d8..fa18d2e4fa 100644 --- a/pkg/asset/ignition/bootstrap/common.go +++ b/pkg/asset/ignition/bootstrap/common.go @@ -438,16 +438,17 @@ func AddStorageFiles(config *igntypes.Config, base string, uri string, templateD var mode int appendToFile := false - if parentDir == "bin" || parentDir == "dispatcher.d" || parentDir == "system-generators" { + switch { + case parentDir == "bin", parentDir == "dispatcher.d", parentDir == "system-generators": mode = 0555 - } else if filename == "motd" || filename == "containers.conf" { + case filename == "motd", filename == "containers.conf": mode = 0644 appendToFile = true - } else if filename == "registries.conf" { + case filename == "registries.conf": // Having the mode be private breaks rpm-ostree, xref // https://github.com/openshift/installer/pull/6789 mode = 0644 - } else { + default: mode = 0600 } ign := ignition.FileFromBytes(strings.TrimSuffix(base, ".template"), "root", mode, data)