update golangci-lint to 1.60.1

Fixes new spotted issues around printf() formats and using os.Setenv()
in tests.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger
2024-08-14 13:14:02 +02:00
parent 5f069d8742
commit c17daf2b09
10 changed files with 16 additions and 15 deletions

View File

@ -62,7 +62,7 @@ BUILDTAGS += ${EXTRA_BUILDTAGS}
# N/B: This value is managed by Renovate, manual changes are
# possible, as long as they don't disturb the formatting
# (i.e. DO NOT ADD A 'v' prefix!)
GOLANGCI_LINT_VERSION := 1.59.1
GOLANGCI_LINT_VERSION := 1.60.1
PYTHON ?= $(shell command -v python3 python|head -n1)
PKG_MANAGER ?= $(shell command -v dnf yum|head -n1)
# ~/.local/bin is not in PATH on all systems

View File

@ -314,7 +314,7 @@ func CreateInit(c *cobra.Command, vals entities.ContainerCreateOptions, isInfra
vals.ShmSizeSystemd = c.Flag("shm-size-systemd").Value.String()
}
if (c.Flag("dns").Changed || c.Flag("dns-option").Changed || c.Flag("dns-search").Changed) && vals.Net != nil && (vals.Net.Network.NSMode == specgen.NoNetwork || vals.Net.Network.IsContainer()) {
return vals, fmt.Errorf("conflicting options: dns and the network mode: " + string(vals.Net.Network.NSMode))
return vals, errors.New("conflicting options: dns and the network mode: " + string(vals.Net.Network.NSMode))
}
noHosts, err := c.Flags().GetBool("no-hosts")
if err != nil {

View File

@ -411,7 +411,7 @@ func (c *Container) execPSinContainer(args []string) ([]string, error) {
if logrus.GetLevel() >= logrus.DebugLevel {
// If we're running in debug mode or higher, we might want to have a
// look at stderr which includes debug logs from conmon.
logrus.Debugf(errBuf.String())
logrus.Debug(errBuf.String())
}
if err := <-outErrChan; err != nil {

View File

@ -1,6 +1,7 @@
package annotations
import (
"errors"
"fmt"
"regexp"
"strings"
@ -41,7 +42,7 @@ func isDNS1123Subdomain(value string) error {
}
if !dns1123SubdomainRegexp.MatchString(value) {
return fmt.Errorf(regexErrorMsg(dns1123SubdomainErrorMsg, dns1123SubdomainFmt, "example.com"))
return errors.New(regexErrorMsg(dns1123SubdomainErrorMsg, dns1123SubdomainFmt, "example.com"))
}
return nil

View File

@ -131,7 +131,7 @@ func AutoUpdate(ctx context.Context, runtime *libpod.Runtime, options entities.A
// Connect to DBUS.
conn, err := systemd.ConnectToDBUS()
if err != nil {
logrus.Errorf(err.Error())
logrus.Error(err.Error())
allErrors = append(allErrors, err)
return nil, allErrors
}

View File

@ -303,7 +303,7 @@ func getFiles(usrName string, uid int, rootful bool, vmtype define.VMType, _ boo
lingerExample.Add("Service", "ExecStart", "/usr/bin/sleep infinity")
lingerExampleFile, err := lingerExample.ToString()
if err != nil {
logrus.Warnf(err.Error())
logrus.Warn(err.Error())
}
containers := `[containers]

View File

@ -176,7 +176,7 @@ func shouldMask(mask string, unmask []string) bool {
for _, m1 := range strings.Split(m, ":") {
match, err := filepath.Match(m1, mask)
if err != nil {
logrus.Errorf(err.Error())
logrus.Error(err.Error())
}
if match {
return false

View File

@ -268,7 +268,7 @@ func MapSpec(p *specgen.PodSpecGenerator) (*specgen.SpecGenerator, error) {
spec.ConmonPidFile = p.InfraConmonPidFile
}
if p.Sysctl != nil && len(p.Sysctl) > 0 {
if len(p.Sysctl) > 0 {
spec.Sysctl = p.Sysctl
}

View File

@ -14,19 +14,19 @@ func TestSocketActivated(t *testing.T) {
assert.False(SocketActivated())
// different pid
assert.NoError(os.Setenv("LISTEN_PID", "1"))
t.Setenv("LISTEN_PID", "1")
assert.False(SocketActivated())
// same pid no fds
assert.NoError(os.Setenv("LISTEN_PID", strconv.Itoa(os.Getpid())))
assert.NoError(os.Setenv("LISTEN_FDS", "0"))
t.Setenv("LISTEN_PID", strconv.Itoa(os.Getpid()))
t.Setenv("LISTEN_FDS", "0")
assert.False(SocketActivated())
// same pid some fds
assert.NoError(os.Setenv("LISTEN_FDS", "1"))
t.Setenv("LISTEN_FDS", "1")
assert.True(SocketActivated())
// FDNAME is ok too (but not required)
assert.NoError(os.Setenv("LISTEN_FDNAMES", "/meshuggah/rocks"))
t.Setenv("LISTEN_FDNAMES", "/meshuggah/rocks")
assert.True(SocketActivated())
}

View File

@ -1775,7 +1775,7 @@ func handleUserRemap(unitFile *parser.UnitFile, groupName string, podman *Podman
autoOpts = append(autoOpts, fmt.Sprintf("size=%v", uidSize))
}
podman.addf("--userns=" + usernsOpts("auto", autoOpts))
podman.add("--userns=" + usernsOpts("auto", autoOpts))
case "keep-id":
if !isUser {
return fmt.Errorf("RemapUsers=keep-id is unsupported for system units")
@ -1795,7 +1795,7 @@ func handleUserRemap(unitFile *parser.UnitFile, groupName string, podman *Podman
keepidOpts = append(keepidOpts, "gid="+gidMaps[0])
}
podman.addf("--userns=" + usernsOpts("keep-id", keepidOpts))
podman.add("--userns=" + usernsOpts("keep-id", keepidOpts))
default:
return fmt.Errorf("unsupported RemapUsers option '%s'", remapUsers)