diff --git a/cmd/podman/common/build.go b/cmd/podman/common/build.go index c3d7224805e..c54b048dfee 100644 --- a/cmd/podman/common/build.go +++ b/cmd/podman/common/build.go @@ -731,7 +731,7 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *Buil // otherwise it returns true func useLayers() string { layers := os.Getenv("BUILDAH_LAYERS") - if strings.ToLower(layers) == "false" || layers == "0" { + if strings.EqualFold(layers, "false") || layers == "0" { return "false" } return "true" diff --git a/libpod/runtime_volume_common.go b/libpod/runtime_volume_common.go index 74e005a6215..fe5db5285fb 100644 --- a/libpod/runtime_volume_common.go +++ b/libpod/runtime_volume_common.go @@ -92,7 +92,7 @@ func (r *Runtime) newVolume(ctx context.Context, noCreatePluginVolume bool, opti for key, val := range volume.config.Options { switch strings.ToLower(key) { case "device": - if strings.ToLower(volume.config.Options["type"]) == define.TypeBind { + if strings.EqualFold(volume.config.Options["type"], define.TypeBind) { if err := fileutils.Exists(val); err != nil { return nil, fmt.Errorf("invalid volume option %s for driver 'local': %w", key, err) } diff --git a/pkg/domain/filters/volumes.go b/pkg/domain/filters/volumes.go index 7b859ed764a..dc620d40625 100644 --- a/pkg/domain/filters/volumes.go +++ b/pkg/domain/filters/volumes.go @@ -120,7 +120,7 @@ func createAnonymousFilterVolumeFunction(filterValues []string) (libpod.VolumeFi return func(v *libpod.Volume) bool { for _, val := range filterValues { anon := v.Anonymous() - invert := strings.ToLower(val) == "false" || val == "0" + invert := strings.EqualFold(val, "false") || val == "0" if invert { anon = !anon } diff --git a/pkg/domain/infra/abi/apply.go b/pkg/domain/infra/abi/apply.go index 067201a6a4d..5899c2db0d9 100644 --- a/pkg/domain/infra/abi/apply.go +++ b/pkg/domain/infra/abi/apply.go @@ -121,7 +121,7 @@ func setUpClusterClient(kconfig k8sAPI.Config, applyOptions entities.ApplyOption caCertPool := x509.NewCertPool() // Be insecure if user sets ca-cert-file flag to insecure - if strings.ToLower(caCertFile) == "insecure" { + if strings.EqualFold(caCertFile, "insecure") { insecureSkipVerify = true } else if caCertFile == "" { caCertFile = kconfig.Clusters[0].Cluster.CertificateAuthority diff --git a/pkg/machine/shim/host.go b/pkg/machine/shim/host.go index c4a21d04979..e8df716f99e 100644 --- a/pkg/machine/shim/host.go +++ b/pkg/machine/shim/host.go @@ -1021,5 +1021,5 @@ func promptUpdateSystemConn() (bool, error) { if err != nil { return false, err } - return strings.ToLower(answer)[0] == 'y', nil + return len(answer) > 0 && (answer[0] == 'y' || answer[0] == 'Y'), nil } diff --git a/pkg/specgen/generate/config_linux.go b/pkg/specgen/generate/config_linux.go index 277fab223a8..85700fdc887 100644 --- a/pkg/specgen/generate/config_linux.go +++ b/pkg/specgen/generate/config_linux.go @@ -171,7 +171,7 @@ func supportAmbientCapabilities() bool { func shouldMask(mask string, unmask []string) bool { for _, m := range unmask { - if strings.ToLower(m) == "all" { + if strings.EqualFold(m, "all") { return false } for m1 := range strings.SplitSeq(m, ":") { diff --git a/pkg/util/utils.go b/pkg/util/utils.go index e75de8ca542..1cf35f50809 100644 --- a/pkg/util/utils.go +++ b/pkg/util/utils.go @@ -1215,7 +1215,7 @@ func ParseRestartPolicy(policy string) (string, uint, error) { case 1: // No retries specified policyType = splitRestart[0] - if strings.ToLower(splitRestart[0]) == "never" { + if strings.EqualFold(splitRestart[0], "never") { policyType = define.RestartPolicyNo } case 2: