Skip to content

Commit

Permalink
Merge pull request #24525 from Luap99/lint
Browse files Browse the repository at this point in the history
update golangci-lint to v1.62.0
  • Loading branch information
openshift-merge-bot[bot] authored Nov 13, 2024
2 parents c348367 + 9eca92d commit ecaf9bf
Show file tree
Hide file tree
Showing 19 changed files with 75 additions and 71 deletions.
7 changes: 5 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ linters:
- wsl
- godox
- tparallel
- gomnd
- nlreturn
- noctx
- nestif
Expand Down Expand Up @@ -62,7 +61,6 @@ linters:
- nonamedreturns
- exhaustruct
# deprecated linters
- execinquery
- exportloopref
linters-settings:
errcheck:
Expand Down Expand Up @@ -90,3 +88,8 @@ issues:
- dependencies
exclude-files:
- swagger.go
exclude-rules:
# Exclude recvcheck from running on the imported k8s files, to much failures
- path: pkg/k8s.io/
linters:
- recvcheck
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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.61.0
GOLANGCI_LINT_VERSION := 1.62.0
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
Expand Down
1 change: 1 addition & 0 deletions cmd/podman/common/completion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/stretchr/testify/assert"
)

//nolint:recvcheck // We like to test mixed pointer receiver and non-pointer receiver
type Car struct {
Brand string
Stats struct {
Expand Down
4 changes: 2 additions & 2 deletions cmd/podman/system/df.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ func (d *dfSummary) Reclaimable() string {
return fmt.Sprintf("%s (%d%%)", units.HumanSize(float64(d.RawReclaimable)), percent)
}

func (d dfSummary) MarshalJSON() ([]byte, error) {
func (d *dfSummary) MarshalJSON() ([]byte, error) {
// need to create a new type here to prevent infinite recursion in MarshalJSON() call
type rawDf dfSummary

Expand All @@ -329,5 +329,5 @@ func (d dfSummary) MarshalJSON() ([]byte, error) {
TotalCount int
Size string
Reclaimable string
}{rawDf(d), d.Total, d.Size(), d.Reclaimable()})
}{rawDf(*d), d.Total, d.Size(), d.Reclaimable()})
}
4 changes: 2 additions & 2 deletions pkg/bindings/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ func handleError(data []byte, unmarshalErrorInto interface{}) error {

// Process drains the response body, and processes the HTTP status code
// Note: Closing the response.Body is left to the caller
func (h APIResponse) Process(unmarshalInto interface{}) error {
func (h *APIResponse) Process(unmarshalInto interface{}) error {
return h.ProcessWithError(unmarshalInto, &errorhandling.ErrorModel{})
}

// ProcessWithError drains the response body, and processes the HTTP status code
// Note: Closing the response.Body is left to the caller
func (h APIResponse) ProcessWithError(unmarshalInto interface{}, unmarshalErrorInto interface{}) error {
func (h *APIResponse) ProcessWithError(unmarshalInto interface{}, unmarshalErrorInto interface{}) error {
data, err := io.ReadAll(h.Response.Body)
if err != nil {
return fmt.Errorf("unable to process API response: %w", err)
Expand Down
6 changes: 3 additions & 3 deletions pkg/domain/infra/abi/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ func (ic *ContainerEngine) Unshare(ctx context.Context, args []string, options e
return unshare()
}

func (ic ContainerEngine) Version(ctx context.Context) (*entities.SystemVersionReport, error) {
func (ic *ContainerEngine) Version(ctx context.Context) (*entities.SystemVersionReport, error) {
var report entities.SystemVersionReport
v, err := define.GetVersion()
if err != nil {
Expand All @@ -334,7 +334,7 @@ func (ic ContainerEngine) Version(ctx context.Context) (*entities.SystemVersionR
return &report, err
}

func (ic ContainerEngine) Locks(ctx context.Context) (*entities.LocksReport, error) {
func (ic *ContainerEngine) Locks(ctx context.Context) (*entities.LocksReport, error) {
var report entities.LocksReport
conflicts, held, err := ic.Libpod.LockConflicts()
if err != nil {
Expand All @@ -345,7 +345,7 @@ func (ic ContainerEngine) Locks(ctx context.Context) (*entities.LocksReport, err
return &report, nil
}

func (ic ContainerEngine) SystemCheck(ctx context.Context, options entities.SystemCheckOptions) (*entities.SystemCheckReport, error) {
func (ic *ContainerEngine) SystemCheck(ctx context.Context, options entities.SystemCheckOptions) (*entities.SystemCheckReport, error) {
report, err := ic.Libpod.SystemCheck(ctx, options)
if err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions pkg/domain/infra/tunnel/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ func (ic *ContainerEngine) Unshare(ctx context.Context, args []string, options e
return errors.New("unshare is not supported on remote clients")
}

func (ic ContainerEngine) Version(ctx context.Context) (*entities.SystemVersionReport, error) {
func (ic *ContainerEngine) Version(ctx context.Context) (*entities.SystemVersionReport, error) {
return system.Version(ic.ClientCtx, nil)
}

func (ic ContainerEngine) Locks(ctx context.Context) (*entities.LocksReport, error) {
func (ic *ContainerEngine) Locks(ctx context.Context) (*entities.LocksReport, error) {
return nil, errors.New("locks is not supported on remote clients")
}
32 changes: 16 additions & 16 deletions pkg/machine/applehv/stubber.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ type AppleHVStubber struct {
vmconfigs.AppleHVConfig
}

func (a AppleHVStubber) UserModeNetworkEnabled(_ *vmconfigs.MachineConfig) bool {
func (a *AppleHVStubber) UserModeNetworkEnabled(_ *vmconfigs.MachineConfig) bool {
return true
}

func (a AppleHVStubber) UseProviderNetworkSetup() bool {
func (a *AppleHVStubber) UseProviderNetworkSetup() bool {
return false
}

func (a AppleHVStubber) RequireExclusiveActive() bool {
func (a *AppleHVStubber) RequireExclusiveActive() bool {
return true
}

func (a AppleHVStubber) CreateVM(opts define.CreateVMOpts, mc *vmconfigs.MachineConfig, ignBuilder *ignition.IgnitionBuilder) error {
func (a *AppleHVStubber) CreateVM(opts define.CreateVMOpts, mc *vmconfigs.MachineConfig, ignBuilder *ignition.IgnitionBuilder) error {
mc.AppleHypervisor = new(vmconfigs.AppleHVConfig)
mc.AppleHypervisor.Vfkit = vfkit.Helper{}
bl := vfConfig.NewEFIBootloader(fmt.Sprintf("%s/efi-bl-%s", opts.Dirs.DataDir.GetPath(), opts.Name), true)
Expand Down Expand Up @@ -79,37 +79,37 @@ func (a AppleHVStubber) CreateVM(opts define.CreateVMOpts, mc *vmconfigs.Machine
return apple.ResizeDisk(mc, mc.Resources.DiskSize)
}

func (a AppleHVStubber) Exists(name string) (bool, error) {
func (a *AppleHVStubber) Exists(name string) (bool, error) {
// not applicable for applehv
return false, nil
}

func (a AppleHVStubber) MountType() vmconfigs.VolumeMountType {
func (a *AppleHVStubber) MountType() vmconfigs.VolumeMountType {
return vmconfigs.VirtIOFS
}

func (a AppleHVStubber) MountVolumesToVM(_ *vmconfigs.MachineConfig, _ bool) error {
func (a *AppleHVStubber) MountVolumesToVM(_ *vmconfigs.MachineConfig, _ bool) error {
// virtiofs: nothing to do here
return nil
}

func (a AppleHVStubber) RemoveAndCleanMachines(_ *define.MachineDirs) error {
func (a *AppleHVStubber) RemoveAndCleanMachines(_ *define.MachineDirs) error {
return nil
}

func (a AppleHVStubber) SetProviderAttrs(mc *vmconfigs.MachineConfig, opts define.SetOptions) error {
func (a *AppleHVStubber) SetProviderAttrs(mc *vmconfigs.MachineConfig, opts define.SetOptions) error {
state, err := a.State(mc, false)
if err != nil {
return err
}
return apple.SetProviderAttrs(mc, opts, state)
}

func (a AppleHVStubber) StartNetworking(mc *vmconfigs.MachineConfig, cmd *gvproxy.GvproxyCommand) error {
func (a *AppleHVStubber) StartNetworking(mc *vmconfigs.MachineConfig, cmd *gvproxy.GvproxyCommand) error {
return apple.StartGenericNetworking(mc, cmd)
}

func (a AppleHVStubber) StartVM(mc *vmconfigs.MachineConfig) (func() error, func() error, error) {
func (a *AppleHVStubber) StartVM(mc *vmconfigs.MachineConfig) (func() error, func() error, error) {
bl := mc.AppleHypervisor.Vfkit.VirtualMachine.Bootloader
if bl == nil {
return nil, nil, fmt.Errorf("unable to determine boot loader for this machine")
Expand All @@ -130,24 +130,24 @@ func (a AppleHVStubber) StartVM(mc *vmconfigs.MachineConfig) (func() error, func
return apple.StartGenericAppleVM(mc, vfkitCommand, bl, mc.AppleHypervisor.Vfkit.Endpoint)
}

func (a AppleHVStubber) StopHostNetworking(_ *vmconfigs.MachineConfig, _ define.VMType) error {
func (a *AppleHVStubber) StopHostNetworking(_ *vmconfigs.MachineConfig, _ define.VMType) error {
return nil
}

func (a AppleHVStubber) UpdateSSHPort(mc *vmconfigs.MachineConfig, port int) error {
func (a *AppleHVStubber) UpdateSSHPort(mc *vmconfigs.MachineConfig, port int) error {
// managed by gvproxy on this backend, so nothing to do
return nil
}

func (a AppleHVStubber) VMType() define.VMType {
func (a *AppleHVStubber) VMType() define.VMType {
return define.AppleHvVirt
}

func (a AppleHVStubber) PrepareIgnition(_ *vmconfigs.MachineConfig, _ *ignition.IgnitionBuilder) (*ignition.ReadyUnitOpts, error) {
func (a *AppleHVStubber) PrepareIgnition(_ *vmconfigs.MachineConfig, _ *ignition.IgnitionBuilder) (*ignition.ReadyUnitOpts, error) {
return nil, nil
}

func (a AppleHVStubber) PostStartNetworking(mc *vmconfigs.MachineConfig, noInfo bool) error {
func (a *AppleHVStubber) PostStartNetworking(mc *vmconfigs.MachineConfig, noInfo bool) error {
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/machine/e2e/config_basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ type basicMachine struct {
args []string
}

func (s basicMachine) buildCmd(m *machineTestBuilder) []string {
func (s *basicMachine) buildCmd(m *machineTestBuilder) []string {
cmd := []string{"-r"}
if len(s.args) > 0 {
cmd = append(cmd, s.args...)
Expand Down
2 changes: 1 addition & 1 deletion pkg/machine/e2e/config_ssh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type sshMachine struct {
sshCommand []string
}

func (s sshMachine) buildCmd(m *machineTestBuilder) []string {
func (s *sshMachine) buildCmd(m *machineTestBuilder) []string {
cmd := []string{"machine", "ssh"}
if len(m.name) > 0 {
cmd = append(cmd, m.name)
Expand Down
6 changes: 3 additions & 3 deletions pkg/machine/e2e/config_start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type startMachine struct {
noInfo bool
}

func (s startMachine) buildCmd(m *machineTestBuilder) []string {
func (s *startMachine) buildCmd(m *machineTestBuilder) []string {
cmd := []string{"machine", "start"}
if len(m.name) > 0 {
cmd = append(cmd, m.name)
Expand All @@ -22,12 +22,12 @@ func (s startMachine) buildCmd(m *machineTestBuilder) []string {
return cmd
}

func (s startMachine) withQuiet() startMachine {
func (s *startMachine) withQuiet() *startMachine {
s.quiet = true
return s
}

func (s startMachine) withNoInfo() startMachine {
func (s *startMachine) withNoInfo() *startMachine {
s.noInfo = true
return s
}
2 changes: 1 addition & 1 deletion pkg/machine/e2e/config_system_connection_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type listSystemConnection struct {
format string
}

func (l listSystemConnection) buildCmd(m *machineTestBuilder) []string {
func (l *listSystemConnection) buildCmd(m *machineTestBuilder) []string {
cmd := []string{"system", "connection", "list"}
if len(l.format) > 0 {
cmd = append(cmd, "--format", l.format)
Expand Down
12 changes: 6 additions & 6 deletions pkg/machine/e2e/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ var _ = Describe("podman machine init", func() {
Expect(inspectBefore).ToNot(BeEmpty())
Expect(inspectBefore[0].Name).To(Equal(mb.names[0]))

s := startMachine{}
s := &startMachine{}
ssession, err := mb.setCmd(s).setTimeout(time.Minute * 10).run()
Expect(err).ToNot(HaveOccurred())
Expect(ssession).Should(Exit(0))
Expand Down Expand Up @@ -217,7 +217,7 @@ var _ = Describe("podman machine init", func() {
Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(0))

ssh := sshMachine{}
ssh := &sshMachine{}
sshSession, err := mb.setName(name).setCmd(ssh.withSSHCommand([]string{"ls /very-long-test-mount-dir-path-more-than-thirty-six-bytes"})).run()
Expect(err).ToNot(HaveOccurred())
Expect(sshSession).To(Exit(0))
Expand All @@ -231,7 +231,7 @@ var _ = Describe("podman machine init", func() {
Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(0))

s := startMachine{}
s := &startMachine{}
ssession, err := mb.setCmd(s).setTimeout(time.Minute * 10).run()
Expect(err).ToNot(HaveOccurred())
Expect(ssession).Should(Exit(0))
Expand All @@ -254,7 +254,7 @@ var _ = Describe("podman machine init", func() {
Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(0))

s := startMachine{}
s := &startMachine{}
ssession, err := mb.setCmd(s).setTimeout(time.Minute * 10).run()
Expect(err).ToNot(HaveOccurred())
Expect(ssession).Should(Exit(0))
Expand Down Expand Up @@ -386,7 +386,7 @@ var _ = Describe("podman machine init", func() {
Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(0))

s := startMachine{}
s := &startMachine{}
ssession, err := mb.setCmd(s).setTimeout(time.Minute * 10).run()
Expect(err).ToNot(HaveOccurred())
Expect(ssession).Should(Exit(0))
Expand Down Expand Up @@ -437,7 +437,7 @@ var _ = Describe("podman machine init", func() {
Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(0))

s := startMachine{}
s := &startMachine{}
ssession, err := mb.setCmd(s).setTimeout(time.Minute * 10).run()
Expect(err).ToNot(HaveOccurred())
Expect(ssession).Should(Exit(0))
Expand Down
2 changes: 1 addition & 1 deletion pkg/machine/e2e/os_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ package e2e_test
// Expect(err).ToNot(HaveOccurred())
// Expect(foo1).To(Exit(0))

// ssh := sshMachine{}
// ssh := &sshMachine{}
// sshSession, err := mb.setName("foo1").setCmd(ssh.withSSHComand([]string{"podman", "pull", "quay.io/baude/podman_next"})).run()
// Expect(err).ToNot(HaveOccurred())
// Expect(sshSession).To(Exit(0))
Expand Down
6 changes: 3 additions & 3 deletions pkg/machine/e2e/ssh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var _ = Describe("podman machine ssh", func() {

It("bad machine name", func() {
name := randomString()
ssh := sshMachine{}
ssh := &sshMachine{}
session, err := mb.setName(name).setCmd(ssh).run()
Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(125))
Expand All @@ -25,7 +25,7 @@ var _ = Describe("podman machine ssh", func() {
Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(0))

ssh := sshMachine{}
ssh := &sshMachine{}
sshSession, err := mb.setName(name).setCmd(ssh).run()
Expect(err).ToNot(HaveOccurred())
Expect(sshSession.errorToString()).To(ContainSubstring("is not running"))
Expand All @@ -40,7 +40,7 @@ var _ = Describe("podman machine ssh", func() {
Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(0))

ssh := sshMachine{}
ssh := &sshMachine{}
sshSession, err := mb.setName(name).setCmd(ssh.withSSHCommand([]string{"cat", "/etc/os-release"})).run()
Expect(err).ToNot(HaveOccurred())
Expect(sshSession).To(Exit(0))
Expand Down
6 changes: 3 additions & 3 deletions pkg/machine/e2e/start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ var _ = Describe("podman machine start", func() {
Expect(err).ToNot(HaveOccurred())
Expect(session2).To(Exit(0))

s := startMachine{}
s := &startMachine{}
session3, err := mb.setName(startme).setCmd(s).setTimeout(time.Minute * 10).run()
Expect(err).ToNot(HaveOccurred())
Expect(session3).Should(Exit(0))
Expand Down Expand Up @@ -181,14 +181,14 @@ var _ = Describe("podman machine start", func() {
go func() {
defer GinkgoRecover()
defer wg.Done()
s := startMachine{}
s := &startMachine{}
startSession1, err = mb.setName(machine1).setCmd(s).setTimeout(time.Minute * 10).run()
Expect(err).ToNot(HaveOccurred())
}()
go func() {
defer GinkgoRecover()
defer wg.Done()
s := startMachine{}
s := &startMachine{}
// ok this is a hack and should not be needed but the way these test are setup they all
// share "mb" which stores the name that is used for the VM, thus running two parallel
// can overwrite the name from the other, work around that by creating a new mb for the
Expand Down
Loading

0 comments on commit ecaf9bf

Please sign in to comment.