From d6b8f8766d56e4b958853801930667c96956d6cd 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 f9a0a560485..0fe9fda4506 100644 --- a/pkg/asset/ignition/bootstrap/common.go +++ b/pkg/asset/ignition/bootstrap/common.go @@ -404,16 +404,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)