Skip to content

Commit

Permalink
bootstrap/common: use switch to satisfy golint
Browse files Browse the repository at this point in the history
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" {
	^
```
  • Loading branch information
jlebon committed Sep 6, 2024
1 parent db05041 commit fedeaad
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/asset/ignition/bootstrap/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,16 +428,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)
Expand Down

0 comments on commit fedeaad

Please sign in to comment.