From 651d51fbbeed5571b31172dc5d6079b81cb67b25 Mon Sep 17 00:00:00 2001 From: Christophe Fergeau Date: Tue, 18 Jul 2023 18:18:00 +0300 Subject: [PATCH] lint: Fix 'unused-parameter' errors GOOS=darwin "/home/teuf/redhat/crc/crc/tools/bin"/golangci-lint run pkg/drivers/none/driver.go:53:34: unused-parameter: parameter 'rawData' seems to be unused, consider removing or renaming it as _ (revive) func (d *Driver) UpdateConfigRaw(rawData []byte) error { ^ --- cmd/crc/cmd/ip.go | 2 +- cmd/crc/cmd/oc_env.go | 2 +- cmd/crc/cmd/setup.go | 2 +- pkg/crc/cluster/clusteroperator_test.go | 2 +- pkg/crc/machine/driver_darwin.go | 2 +- pkg/crc/machine/driver_linux.go | 4 ++-- pkg/crc/machine/driver_windows.go | 2 +- pkg/crc/machine/fakemachine/client.go | 6 +++--- pkg/crc/machine/generate_bundle_nonlinux.go | 2 +- pkg/crc/machine/sync_test.go | 2 +- pkg/crc/preflight/preflight_checks_unix.go | 2 +- pkg/crc/preflight/preflight_darwin.go | 2 +- pkg/crc/systemd/systemd.go | 2 +- pkg/crc/systemd/systemd_linux_test.go | 4 ++-- pkg/crc/tray/util_linux.go | 2 +- pkg/crc/tray/util_windows.go | 2 +- pkg/drivers/none/driver.go | 2 +- pkg/libmachine/load_darwin.go | 2 +- pkg/libmachine/load_windows.go | 2 +- test/e2e/e2e_test.go | 2 +- 20 files changed, 24 insertions(+), 24 deletions(-) diff --git a/cmd/crc/cmd/ip.go b/cmd/crc/cmd/ip.go index 315652c839..47830886cd 100644 --- a/cmd/crc/cmd/ip.go +++ b/cmd/crc/cmd/ip.go @@ -19,7 +19,7 @@ var ipCmd = &cobra.Command{ }, } -func runIP(arguments []string) error { +func runIP(_ []string) error { client := newMachine() if err := checkIfMachineMissing(client); err != nil { return err diff --git a/cmd/crc/cmd/oc_env.go b/cmd/crc/cmd/oc_env.go index fcbc494819..992d6c0a06 100644 --- a/cmd/crc/cmd/oc_env.go +++ b/cmd/crc/cmd/oc_env.go @@ -21,7 +21,7 @@ var ocEnvCmd = &cobra.Command{ }, } -func runOcEnv(args []string) error { +func runOcEnv(_ []string) error { userShell, err := shell.GetShell(forceShell) if err != nil { return fmt.Errorf("Error running the oc-env command: %s", err.Error()) diff --git a/cmd/crc/cmd/setup.go b/cmd/crc/cmd/setup.go index 93aa4df8ba..b1a4226be9 100644 --- a/cmd/crc/cmd/setup.go +++ b/cmd/crc/cmd/setup.go @@ -43,7 +43,7 @@ var setupCmd = &cobra.Command{ }, } -func runSetup(arguments []string) error { +func runSetup(_ []string) error { if config.Get(crcConfig.ConsentTelemetry).AsString() == "" { fmt.Println("CRC is constantly improving and we would like to know more about usage (more details at https://developers.redhat.com/article/tool-data-collection)") fmt.Println("Your preference can be changed manually if desired using 'crc config set consent-telemetry '") diff --git a/pkg/crc/cluster/clusteroperator_test.go b/pkg/crc/cluster/clusteroperator_test.go index ad678bb52c..a94d498ec6 100644 --- a/pkg/crc/cluster/clusteroperator_test.go +++ b/pkg/crc/cluster/clusteroperator_test.go @@ -39,7 +39,7 @@ type mockLister struct { file string } -func (r *mockLister) List(ctx context.Context, opts metav1.ListOptions) (*v1.ClusterOperatorList, error) { +func (r *mockLister) List(_ context.Context, _ metav1.ListOptions) (*v1.ClusterOperatorList, error) { bin, err := os.ReadFile(r.file) if err != nil { return nil, err diff --git a/pkg/crc/machine/driver_darwin.go b/pkg/crc/machine/driver_darwin.go index 43d2454598..c1ec3feb1c 100644 --- a/pkg/crc/machine/driver_darwin.go +++ b/pkg/crc/machine/driver_darwin.go @@ -65,6 +65,6 @@ func updateKernelArgs(vm *virtualMachine) error { return vm.api.Save(vm.Host) } -func updateDriverStruct(host *host.Host, driver *machineVf.Driver) error { +func updateDriverStruct(_ *host.Host, _ *machineVf.Driver) error { return drivers.ErrNotImplemented } diff --git a/pkg/crc/machine/driver_linux.go b/pkg/crc/machine/driver_linux.go index b6f9b00ec2..2e53178b12 100644 --- a/pkg/crc/machine/driver_linux.go +++ b/pkg/crc/machine/driver_linux.go @@ -39,7 +39,7 @@ func updateDriverConfig(host *host.Host, driver *machineLibvirt.Driver) error { return host.UpdateConfig(driverData) } -func updateKernelArgs(vm *virtualMachine) error { +func updateKernelArgs(_ *virtualMachine) error { return nil } @@ -49,6 +49,6 @@ func (r *RPCServerDriver) SetConfigRaw(data []byte, _ *struct{}) error { } */ -func updateDriverStruct(host *host.Host, driver *machineLibvirt.Driver) error { +func updateDriverStruct(_ *host.Host, _ *machineLibvirt.Driver) error { return drivers.ErrNotImplemented } diff --git a/pkg/crc/machine/driver_windows.go b/pkg/crc/machine/driver_windows.go index 81c473e43c..148bb1f637 100644 --- a/pkg/crc/machine/driver_windows.go +++ b/pkg/crc/machine/driver_windows.go @@ -34,7 +34,7 @@ func updateDriverConfig(host *host.Host, driver *machineHyperv.Driver) error { return host.UpdateConfig(driverData) } -func updateKernelArgs(vm *virtualMachine) error { +func updateKernelArgs(_ *virtualMachine) error { return nil } diff --git a/pkg/crc/machine/fakemachine/client.go b/pkg/crc/machine/fakemachine/client.go index 8af3e309b2..0a092f8083 100644 --- a/pkg/crc/machine/fakemachine/client.go +++ b/pkg/crc/machine/fakemachine/client.go @@ -55,7 +55,7 @@ func (c *Client) GetConsoleURL() (*types.ConsoleResult, error) { }, nil } -func (c *Client) GetProxyConfig(machineName string) (*httpproxy.ProxyConfig, error) { +func (c *Client) GetProxyConfig(_ string) (*httpproxy.ProxyConfig, error) { return nil, errors.New("not implemented") } @@ -70,14 +70,14 @@ func (c *Client) PowerOff() error { return nil } -func (c *Client) GenerateBundle(forceStop bool) error { +func (c *Client) GenerateBundle(_ bool) error { if c.Failing { return errors.New("bundle generation failed") } return nil } -func (c *Client) Start(ctx context.Context, startConfig types.StartConfig) (*types.StartResult, error) { +func (c *Client) Start(_ context.Context, _ types.StartConfig) (*types.StartResult, error) { if c.Failing { return nil, errors.New("Failed to start") } diff --git a/pkg/crc/machine/generate_bundle_nonlinux.go b/pkg/crc/machine/generate_bundle_nonlinux.go index 79501d415b..dbd3d312d5 100644 --- a/pkg/crc/machine/generate_bundle_nonlinux.go +++ b/pkg/crc/machine/generate_bundle_nonlinux.go @@ -8,6 +8,6 @@ import ( "runtime" ) -func copyDiskImage(dirName string) (string, string, error) { +func copyDiskImage(_ string) (string, string, error) { return "", "", fmt.Errorf("Not implemented for %s", runtime.GOOS) } diff --git a/pkg/crc/machine/sync_test.go b/pkg/crc/machine/sync_test.go index 93ca3f81f1..e102ec9e26 100644 --- a/pkg/crc/machine/sync_test.go +++ b/pkg/crc/machine/sync_test.go @@ -167,7 +167,7 @@ func (m *waitingMachine) Stop() (state.State, error) { return state.Stopped, nil } -func (m *waitingMachine) GenerateBundle(forceStop bool) error { +func (m *waitingMachine) GenerateBundle(_ bool) error { return errors.New("not implemented") } diff --git a/pkg/crc/preflight/preflight_checks_unix.go b/pkg/crc/preflight/preflight_checks_unix.go index eca49047f5..89c0239a61 100644 --- a/pkg/crc/preflight/preflight_checks_unix.go +++ b/pkg/crc/preflight/preflight_checks_unix.go @@ -33,7 +33,7 @@ var nonWinPreflightChecks = []Check{ }, } -func genericPreflightChecks(preset crcpreset.Preset) []Check { +func genericPreflightChecks(_ crcpreset.Preset) []Check { return []Check{ { configKeySuffix: "check-admin-helper-cached", diff --git a/pkg/crc/preflight/preflight_darwin.go b/pkg/crc/preflight/preflight_darwin.go index d922c718f5..53927c9974 100644 --- a/pkg/crc/preflight/preflight_darwin.go +++ b/pkg/crc/preflight/preflight_darwin.go @@ -102,7 +102,7 @@ func getAllPreflightChecks() []Check { return getPreflightChecks(true, network.SystemNetworkingMode, constants.GetDefaultBundlePath(preset.OpenShift), preset.OpenShift) } -func getChecks(mode network.Mode, bundlePath string, preset crcpreset.Preset) []Check { +func getChecks(_ network.Mode, bundlePath string, preset crcpreset.Preset) []Check { checks := []Check{} checks = append(checks, nonWinPreflightChecks...) diff --git a/pkg/crc/systemd/systemd.go b/pkg/crc/systemd/systemd.go index 77f2ede944..ea8ab2e8ff 100644 --- a/pkg/crc/systemd/systemd.go +++ b/pkg/crc/systemd/systemd.go @@ -112,7 +112,7 @@ func (userRunner *systemctlUserRunner) RunPrivate(command string, args ...string return userRunner.runner.RunPrivate("systemctl", append([]string{"--user"}, args...)...) } -func (userRunner *systemctlUserRunner) RunPrivileged(reason string, cmdAndArgs ...string) (string, string, error) { +func (userRunner *systemctlUserRunner) RunPrivileged(_ string, cmdAndArgs ...string) (string, string, error) { command := cmdAndArgs[0] args := cmdAndArgs[1:] if command != "systemctl" { diff --git a/pkg/crc/systemd/systemd_linux_test.go b/pkg/crc/systemd/systemd_linux_test.go index d044165bd0..9d0c925893 100644 --- a/pkg/crc/systemd/systemd_linux_test.go +++ b/pkg/crc/systemd/systemd_linux_test.go @@ -79,12 +79,12 @@ func (r *mockSystemdRunner) Run(command string, args ...string) (string, string, } } -func (r *mockSystemdRunner) RunPrivate(command string, args ...string) (string, string, error) { +func (r *mockSystemdRunner) RunPrivate(_ string, _ ...string) (string, string, error) { r.test.FailNow() return "", "", fmt.Errorf("Unexpected RunPrivate() call") } -func (r *mockSystemdRunner) RunPrivileged(reason string, cmdAndArgs ...string) (string, string, error) { +func (r *mockSystemdRunner) RunPrivileged(_ string, cmdAndArgs ...string) (string, string, error) { privilegedCommands := []string{ "start", "stop", diff --git a/pkg/crc/tray/util_linux.go b/pkg/crc/tray/util_linux.go index 404f837681..8e91fb83a6 100644 --- a/pkg/crc/tray/util_linux.go +++ b/pkg/crc/tray/util_linux.go @@ -1,6 +1,6 @@ package tray // ValidateTrayAutostart checks tray-auto-start is used in macOS and its a bool -func ValidateTrayAutostart(value interface{}) (bool, string) { +func ValidateTrayAutostart(_ interface{}) (bool, string) { return false, "Not supported on Linux" } diff --git a/pkg/crc/tray/util_windows.go b/pkg/crc/tray/util_windows.go index 529c740d6b..3f22881641 100644 --- a/pkg/crc/tray/util_windows.go +++ b/pkg/crc/tray/util_windows.go @@ -1,6 +1,6 @@ package tray // ValidateTrayAutostart checks tray-auto-start is used in macOS and its a bool -func ValidateTrayAutostart(value interface{}) (bool, string) { +func ValidateTrayAutostart(_ interface{}) (bool, string) { return false, "Not supported on Windows" } diff --git a/pkg/drivers/none/driver.go b/pkg/drivers/none/driver.go index 7c180827a4..b676d7d15c 100644 --- a/pkg/drivers/none/driver.go +++ b/pkg/drivers/none/driver.go @@ -50,7 +50,7 @@ func (d *Driver) Remove() error { return nil } -func (d *Driver) UpdateConfigRaw(rawData []byte) error { +func (d *Driver) UpdateConfigRaw(_ []byte) error { return fmt.Errorf("hosts without a driver cannot be updated") } diff --git a/pkg/libmachine/load_darwin.go b/pkg/libmachine/load_darwin.go index bf897643b9..c47269603c 100644 --- a/pkg/libmachine/load_darwin.go +++ b/pkg/libmachine/load_darwin.go @@ -7,7 +7,7 @@ import ( "github.com/crc-org/crc/pkg/libmachine/host" ) -func (api *Client) NewHost(driverName string, driverPath string, rawDriver []byte) (*host.Host, error) { +func (api *Client) NewHost(_ string, driverPath string, rawDriver []byte) (*host.Host, error) { driver := vfkit.NewDriver("", "") if err := json.Unmarshal(rawDriver, &driver); err != nil { return nil, err diff --git a/pkg/libmachine/load_windows.go b/pkg/libmachine/load_windows.go index cf5393fe27..f25cb2dced 100644 --- a/pkg/libmachine/load_windows.go +++ b/pkg/libmachine/load_windows.go @@ -7,7 +7,7 @@ import ( "github.com/crc-org/crc/pkg/libmachine/host" ) -func (api *Client) NewHost(driverName string, driverPath string, rawDriver []byte) (*host.Host, error) { +func (api *Client) NewHost(_ string, driverPath string, rawDriver []byte) (*host.Host, error) { driver := hyperv.NewDriver("", "") if err := json.Unmarshal(rawDriver, &driver); err != nil { return nil, err diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index d913ec1118..ac83b3a3dc 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -30,7 +30,7 @@ func init() { testsuite.ParseFlags() } -func TestMain(m *testing.M) { +func TestMain(_ *testing.M) { pflag.Parse() testsuite.GodogTags = opts.Tags