From 58b7fcacfac667bbb425e2a109dcc9b4ed4d7791 Mon Sep 17 00:00:00 2001 From: minikube-bot Date: Mon, 12 Feb 2024 10:03:00 +0000 Subject: [PATCH 1/2] CI: Update golint from v1.55.2 to v1.56.1 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9a33f25a7f25..ab676e11b411 100644 --- a/Makefile +++ b/Makefile @@ -79,7 +79,7 @@ MINIKUBE_RELEASES_URL=https://github.com/kubernetes/minikube/releases/download KERNEL_VERSION ?= 5.10.57 # latest from https://github.com/golangci/golangci-lint/releases # update this only by running `make update-golint-version` -GOLINT_VERSION ?= v1.55.2 +GOLINT_VERSION ?= v1.56.1 # Limit number of default jobs, to avoid the CI builds running out of memory GOLINT_JOBS ?= 4 # see https://github.com/golangci/golangci-lint#memory-usage-of-golangci-lint From 4d32230e3e6a557046ac3b626466fca0be8ea541 Mon Sep 17 00:00:00 2001 From: Steven Powell Date: Mon, 12 Feb 2024 17:32:14 -0800 Subject: [PATCH 2/2] fix lint errors --- cmd/minikube/cmd/cache.go | 6 +-- cmd/minikube/cmd/cache_list.go | 2 +- cmd/minikube/cmd/completion.go | 10 ++--- cmd/minikube/cmd/config/addons.go | 2 +- cmd/minikube/cmd/config/addons_list.go | 2 +- cmd/minikube/cmd/config/config.go | 2 +- cmd/minikube/cmd/config/configure.go | 2 +- cmd/minikube/cmd/config/disable.go | 2 +- cmd/minikube/cmd/config/enable.go | 2 +- cmd/minikube/cmd/config/images.go | 2 +- cmd/minikube/cmd/config/open.go | 4 +- cmd/minikube/cmd/config/profile.go | 2 +- cmd/minikube/cmd/config/profile_list.go | 2 +- cmd/minikube/cmd/config/set.go | 2 +- cmd/minikube/cmd/config/unset.go | 2 +- cmd/minikube/cmd/config/view.go | 2 +- cmd/minikube/cmd/cp.go | 2 +- cmd/minikube/cmd/dashboard.go | 2 +- cmd/minikube/cmd/delete_test.go | 4 +- cmd/minikube/cmd/docker-env.go | 2 +- cmd/minikube/cmd/generate-docs.go | 2 +- cmd/minikube/cmd/image.go | 16 ++++---- cmd/minikube/cmd/ip.go | 2 +- cmd/minikube/cmd/kubectl.go | 2 +- cmd/minikube/cmd/license.go | 2 +- cmd/minikube/cmd/logs.go | 2 +- cmd/minikube/cmd/mount.go | 2 +- cmd/minikube/cmd/node.go | 2 +- cmd/minikube/cmd/node_add.go | 2 +- cmd/minikube/cmd/node_delete.go | 2 +- cmd/minikube/cmd/node_list.go | 2 +- cmd/minikube/cmd/node_stop.go | 2 +- cmd/minikube/cmd/podman-env.go | 2 +- cmd/minikube/cmd/root.go | 4 +- cmd/minikube/cmd/service.go | 2 +- cmd/minikube/cmd/service_list.go | 2 +- cmd/minikube/cmd/ssh-host.go | 2 +- cmd/minikube/cmd/ssh-key.go | 2 +- cmd/minikube/cmd/ssh.go | 2 +- cmd/minikube/cmd/start_test.go | 4 +- cmd/minikube/cmd/status.go | 2 +- cmd/minikube/cmd/tunnel.go | 2 +- cmd/minikube/cmd/unpause.go | 2 +- cmd/minikube/cmd/update-check.go | 2 +- cmd/minikube/cmd/update-context.go | 2 +- cmd/minikube/cmd/version.go | 2 +- cmd/performance/mkcmp/cmd/mkcmp.go | 4 +- hack/boilerplate/boilerplate.go | 2 +- hack/legacy_fill_db/filldb.go | 2 +- pkg/drivers/kic/oci/network_create_test.go | 4 +- pkg/generate/testdocs.go | 2 +- pkg/minikube/command/fake_runner.go | 4 +- pkg/minikube/download/download_test.go | 40 +++++++++---------- pkg/minikube/extract/extract.go | 2 +- pkg/minikube/localpath/localpath_test.go | 2 +- pkg/minikube/proxy/proxy_test.go | 9 +++-- pkg/minikube/shell/shell.go | 2 +- pkg/minikube/tunnel/tunnel_manager_test.go | 6 +-- pkg/network/network.go | 8 ++-- pkg/network/network_test.go | 5 +-- pkg/util/utils.go | 2 +- test/integration/functional_test.go | 4 +- .../functional_test_tunnel_test.go | 2 +- 63 files changed, 110 insertions(+), 116 deletions(-) diff --git a/cmd/minikube/cmd/cache.go b/cmd/minikube/cmd/cache.go index dd06d215ea47..80c562d4e1fa 100644 --- a/cmd/minikube/cmd/cache.go +++ b/cmd/minikube/cmd/cache.go @@ -47,7 +47,7 @@ var addCacheCmd = &cobra.Command{ Use: "add", Short: "Add an image to local cache.", Long: "Add an image to local cache.", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { out.WarningT("\"minikube cache\" will be deprecated in upcoming versions, please switch to \"minikube image load\"") // Cache and load images into docker daemon if err := machine.CacheAndLoadImages(args, cacheAddProfiles(), false); err != nil { @@ -85,7 +85,7 @@ var deleteCacheCmd = &cobra.Command{ Use: "delete", Short: "Delete an image from the local cache.", Long: "Delete an image from the local cache.", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { // Delete images from config file if err := cmdConfig.DeleteFromConfigMap(cacheImageConfigKey, args); err != nil { exit.Error(reason.InternalDelConfig, "Failed to delete images from config", err) @@ -102,7 +102,7 @@ var reloadCacheCmd = &cobra.Command{ Use: "reload", Short: "reload cached images.", Long: "reloads images previously added using the 'cache add' subcommand", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { err := node.CacheAndLoadImagesInConfig(cacheAddProfiles()) if err != nil { exit.Error(reason.GuestCacheLoad, "Failed to reload cached images", err) diff --git a/cmd/minikube/cmd/cache_list.go b/cmd/minikube/cmd/cache_list.go index a88069dac49f..11053f66a5e6 100644 --- a/cmd/minikube/cmd/cache_list.go +++ b/cmd/minikube/cmd/cache_list.go @@ -40,7 +40,7 @@ var listCacheCmd = &cobra.Command{ Use: "list", Short: "List all available images from the local cache.", Long: "List all available images from the local cache.", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { images, err := cmdConfig.ListConfigMap(cacheImageConfigKey) if err != nil { exit.Error(reason.InternalListConfig, "Failed to get image map", err) diff --git a/cmd/minikube/cmd/completion.go b/cmd/minikube/cmd/completion.go index cc254b4aecba..ab8221b21533 100644 --- a/cmd/minikube/cmd/completion.go +++ b/cmd/minikube/cmd/completion.go @@ -81,7 +81,7 @@ var completionCmd = &cobra.Command{ Use: "completion SHELL", Short: "Generate command completion for a shell", Long: longDescription, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { if len(args) != 1 { exit.Message(reason.Usage, "Usage: minikube completion SHELL") } @@ -95,7 +95,7 @@ var bashCmd = &cobra.Command{ Use: "bash", Short: "bash completion.", Long: "Generate command completion for bash.", - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { err := GenerateBashCompletion(os.Stdout, cmd.Root()) if err != nil { exit.Error(reason.InternalCompletion, "bash completion failed", err) @@ -107,7 +107,7 @@ var zshCmd = &cobra.Command{ Use: "zsh", Short: "zsh completion.", Long: "Generate command completion for zsh.", - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { err := GenerateZshCompletion(os.Stdout, cmd.Root()) if err != nil { exit.Error(reason.InternalCompletion, "zsh completion failed", err) @@ -119,7 +119,7 @@ var fishCmd = &cobra.Command{ Use: "fish", Short: "fish completion.", Long: "Generate command completion for fish .", - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { err := GenerateFishCompletion(os.Stdout, cmd.Root()) if err != nil { exit.Error(reason.InternalCompletion, "fish completion failed", err) @@ -131,7 +131,7 @@ var powershellCmd = &cobra.Command{ Use: "powershell", Short: "powershell completion.", Long: "Generate command completion for PowerShell.", - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { err := GeneratePowerShellCompletion(os.Stdout, cmd.Root()) if err != nil { exit.Error(reason.InternalCompletion, "powershell completion failed", err) diff --git a/cmd/minikube/cmd/config/addons.go b/cmd/minikube/cmd/config/addons.go index ffb5a1fa217e..415a523d93f1 100644 --- a/cmd/minikube/cmd/config/addons.go +++ b/cmd/minikube/cmd/config/addons.go @@ -27,7 +27,7 @@ var AddonsCmd = &cobra.Command{ Use: "addons SUBCOMMAND [flags]", Short: "Enable or disable a minikube addon", Long: `addons modifies minikube addons files using subcommands like "minikube addons enable dashboard"`, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { if err := cmd.Help(); err != nil { klog.Errorf("help: %v", err) } diff --git a/cmd/minikube/cmd/config/addons_list.go b/cmd/minikube/cmd/config/addons_list.go index 3ccae0e32713..4fb3596547a6 100644 --- a/cmd/minikube/cmd/config/addons_list.go +++ b/cmd/minikube/cmd/config/addons_list.go @@ -48,7 +48,7 @@ var addonsListCmd = &cobra.Command{ Use: "list", Short: "Lists all available minikube addons as well as their current statuses (enabled/disabled)", Long: "Lists all available minikube addons as well as their current statuses (enabled/disabled)", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { if len(args) != 0 { exit.Message(reason.Usage, "usage: minikube addons list") } diff --git a/cmd/minikube/cmd/config/config.go b/cmd/minikube/cmd/config/config.go index c17d0d77fd87..a98d72bb13bd 100644 --- a/cmd/minikube/cmd/config/config.go +++ b/cmd/minikube/cmd/config/config.go @@ -180,7 +180,7 @@ var ConfigCmd = &cobra.Command{ Short: "Modify persistent configuration values", Long: `config modifies minikube config files using subcommands like "minikube config set driver kvm2" Configurable fields: ` + "\n\n" + configurableFields(), - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { if err := cmd.Help(); err != nil { klog.ErrorS(err, "help") } diff --git a/cmd/minikube/cmd/config/configure.go b/cmd/minikube/cmd/config/configure.go index c0d77e9cf784..a877d49b877a 100644 --- a/cmd/minikube/cmd/config/configure.go +++ b/cmd/minikube/cmd/config/configure.go @@ -40,7 +40,7 @@ var addonsConfigureCmd = &cobra.Command{ Use: "configure ADDON_NAME", Short: "Configures the addon w/ADDON_NAME within minikube (example: minikube addons configure registry-creds). For a list of available addons use: minikube addons list", Long: "Configures the addon w/ADDON_NAME within minikube (example: minikube addons configure registry-creds). For a list of available addons use: minikube addons list", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { if len(args) != 1 { exit.Message(reason.Usage, "usage: minikube addons configure ADDON_NAME") } diff --git a/cmd/minikube/cmd/config/disable.go b/cmd/minikube/cmd/config/disable.go index 4a3635c18834..30459cd029a1 100644 --- a/cmd/minikube/cmd/config/disable.go +++ b/cmd/minikube/cmd/config/disable.go @@ -31,7 +31,7 @@ var addonsDisableCmd = &cobra.Command{ Use: "disable ADDON_NAME", Short: "Disables the addon w/ADDON_NAME within minikube (example: minikube addons disable dashboard). For a list of available addons use: minikube addons list ", Long: "Disables the addon w/ADDON_NAME within minikube (example: minikube addons disable dashboard). For a list of available addons use: minikube addons list ", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { if len(args) != 1 { exit.Message(reason.Usage, "usage: minikube addons disable ADDON_NAME") } diff --git a/cmd/minikube/cmd/config/enable.go b/cmd/minikube/cmd/config/enable.go index e04a6f75c786..74f382c8ea3b 100644 --- a/cmd/minikube/cmd/config/enable.go +++ b/cmd/minikube/cmd/config/enable.go @@ -37,7 +37,7 @@ var addonsEnableCmd = &cobra.Command{ Short: "Enables the addon w/ADDON_NAME within minikube. For a list of available addons use: minikube addons list ", Long: "Enables the addon w/ADDON_NAME within minikube. For a list of available addons use: minikube addons list ", Example: "minikube addons enable dashboard", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { if len(args) != 1 { exit.Message(reason.Usage, "usage: minikube addons enable ADDON_NAME") } diff --git a/cmd/minikube/cmd/config/images.go b/cmd/minikube/cmd/config/images.go index c18ab35d7c85..2ed24814ee96 100644 --- a/cmd/minikube/cmd/config/images.go +++ b/cmd/minikube/cmd/config/images.go @@ -32,7 +32,7 @@ var addonsImagesCmd = &cobra.Command{ Short: "List image names the addon w/ADDON_NAME used. For a list of available addons use: minikube addons list", Long: "List image names the addon w/ADDON_NAME used. For a list of available addons use: minikube addons list", Example: "minikube addons images ingress", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { if len(args) != 1 { exit.Message(reason.Usage, "usage: minikube addons images ADDON_NAME") } diff --git a/cmd/minikube/cmd/config/open.go b/cmd/minikube/cmd/config/open.go index 09e22eb5a82d..9dae98558bc1 100644 --- a/cmd/minikube/cmd/config/open.go +++ b/cmd/minikube/cmd/config/open.go @@ -46,14 +46,14 @@ var addonsOpenCmd = &cobra.Command{ Use: "open ADDON_NAME", Short: "Opens the addon w/ADDON_NAME within minikube (example: minikube addons open dashboard). For a list of available addons use: minikube addons list ", Long: "Opens the addon w/ADDON_NAME within minikube (example: minikube addons open dashboard). For a list of available addons use: minikube addons list ", - PreRun: func(cmd *cobra.Command, args []string) { + PreRun: func(_ *cobra.Command, _ []string) { t, err := template.New("addonsURL").Parse(addonsURLFormat) if err != nil { exit.Message(reason.Usage, "The value passed to --format is invalid: {{.error}}", out.V{"error": err}) } addonsURLTemplate = t }, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { if len(args) != 1 { exit.Message(reason.Usage, "usage: minikube addons open ADDON_NAME") } diff --git a/cmd/minikube/cmd/config/profile.go b/cmd/minikube/cmd/config/profile.go index d0a8e5e8ea81..aa569f596148 100644 --- a/cmd/minikube/cmd/config/profile.go +++ b/cmd/minikube/cmd/config/profile.go @@ -34,7 +34,7 @@ var ProfileCmd = &cobra.Command{ Use: "profile [MINIKUBE_PROFILE_NAME]. You can return to the default minikube profile by running `minikube profile default`", Short: "Get or list the current profiles (clusters)", Long: "profile sets the current minikube profile, or gets the current profile if no arguments are provided. This is used to run and manage multiple minikube instance. You can return to the default minikube profile by running `minikube profile default`", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { if len(args) == 0 { profile := ClusterFlagValue() out.Styled(style.Empty, profile) diff --git a/cmd/minikube/cmd/config/profile_list.go b/cmd/minikube/cmd/config/profile_list.go index 2cd2f1432f6e..bf374f92b3a3 100644 --- a/cmd/minikube/cmd/config/profile_list.go +++ b/cmd/minikube/cmd/config/profile_list.go @@ -49,7 +49,7 @@ var profileListCmd = &cobra.Command{ Use: "list", Short: "Lists all minikube profiles.", Long: "Lists all valid minikube profiles and detects all possible invalid profiles.", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { output := strings.ToLower(profileOutput) out.SetJSON(output == "json") go notify.MaybePrintUpdateTextFromGithub() diff --git a/cmd/minikube/cmd/config/set.go b/cmd/minikube/cmd/config/set.go index 6593dc2897f2..ee0cc1611472 100644 --- a/cmd/minikube/cmd/config/set.go +++ b/cmd/minikube/cmd/config/set.go @@ -31,7 +31,7 @@ var configSetCmd = &cobra.Command{ Short: "Sets an individual value in a minikube config file", Long: `Sets the PROPERTY_NAME config value to PROPERTY_VALUE These values can be overwritten by flags or environment variables at runtime.`, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { if len(args) < 2 { exit.Message(reason.Usage, "not enough arguments ({{.ArgCount}}).\nusage: minikube config set PROPERTY_NAME PROPERTY_VALUE", out.V{"ArgCount": len(args)}) } diff --git a/cmd/minikube/cmd/config/unset.go b/cmd/minikube/cmd/config/unset.go index b3581abd3732..bce6da57842f 100644 --- a/cmd/minikube/cmd/config/unset.go +++ b/cmd/minikube/cmd/config/unset.go @@ -28,7 +28,7 @@ var configUnsetCmd = &cobra.Command{ Use: "unset PROPERTY_NAME", Short: "unsets an individual value in a minikube config file", Long: "unsets PROPERTY_NAME from the minikube config file. Can be overwritten by flags or environmental variables", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { if len(args) != 1 { exit.Message(reason.Usage, "usage: minikube config unset PROPERTY_NAME") } diff --git a/cmd/minikube/cmd/config/view.go b/cmd/minikube/cmd/config/view.go index d8ff741dcc08..bd9ae570f7d6 100644 --- a/cmd/minikube/cmd/config/view.go +++ b/cmd/minikube/cmd/config/view.go @@ -41,7 +41,7 @@ var configViewCmd = &cobra.Command{ Use: "view", Short: "Display values currently set in the minikube config file", Long: "Display values currently set in the minikube config file.", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { err := View() if err != nil { exit.Error(reason.InternalConfigView, "config view failed", err) diff --git a/cmd/minikube/cmd/cp.go b/cmd/minikube/cmd/cp.go index f60a0685331e..895f098fc1c0 100644 --- a/cmd/minikube/cmd/cp.go +++ b/cmd/minikube/cmd/cp.go @@ -52,7 +52,7 @@ Default target node controlplane and If is omitted, It will t Example Command : "minikube cp a.txt /home/docker/b.txt" + "minikube cp a.txt minikube-m02:/home/docker/b.txt" "minikube cp minikube-m01:a.txt minikube-m02:/home/docker/b.txt"`, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { if len(args) != 2 { exit.Message(reason.Usage, `Please specify the path to copy: minikube cp (example: "minikube cp a/b.txt /copied.txt")`) diff --git a/cmd/minikube/cmd/dashboard.go b/cmd/minikube/cmd/dashboard.go index 29adf449c16d..86bd0f5a9fa2 100644 --- a/cmd/minikube/cmd/dashboard.go +++ b/cmd/minikube/cmd/dashboard.go @@ -57,7 +57,7 @@ var dashboardCmd = &cobra.Command{ Use: "dashboard", Short: "Access the Kubernetes dashboard running within the minikube cluster", Long: `Access the Kubernetes dashboard running within the minikube cluster`, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { cname := ClusterFlagValue() co := mustload.Healthy(cname) diff --git a/cmd/minikube/cmd/delete_test.go b/cmd/minikube/cmd/delete_test.go index 36adc1cb4ead..fc6248a9cfaf 100644 --- a/cmd/minikube/cmd/delete_test.go +++ b/cmd/minikube/cmd/delete_test.go @@ -145,9 +145,7 @@ func TestDeleteProfile(t *testing.T) { } } -var hostAndDirsDeleterMock = func(api libmachine.API, cc *config.ClusterConfig, profileName string) error { - return deleteContextTest() -} +var hostAndDirsDeleterMock = func(_ libmachine.API, _ *config.ClusterConfig, _ string) error { return deleteContextTest() } func deleteContextTest() error { if err := cmdcfg.Unset(config.ProfileName); err != nil { diff --git a/cmd/minikube/cmd/docker-env.go b/cmd/minikube/cmd/docker-env.go index 49da87b9dd11..a30626dba011 100644 --- a/cmd/minikube/cmd/docker-env.go +++ b/cmd/minikube/cmd/docker-env.go @@ -270,7 +270,7 @@ For example, you can do all docker operations such as docker build, docker run, Note: You need the docker-cli to be installed on your machine. docker-cli install instructions: https://minikube.sigs.k8s.io/docs/tutorials/docker_desktop_replacement/#steps`, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { var err error shl := shell.ForceShell diff --git a/cmd/minikube/cmd/generate-docs.go b/cmd/minikube/cmd/generate-docs.go index 8b9a847c7bf9..0cd4c89116cb 100644 --- a/cmd/minikube/cmd/generate-docs.go +++ b/cmd/minikube/cmd/generate-docs.go @@ -38,7 +38,7 @@ var generateDocs = &cobra.Command{ Long: "Populates the specified folder with documentation in markdown about minikube", Example: "minikube generate-docs --path ", Hidden: true, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { // if directory does not exist st, err := os.Stat(docsPath) if err != nil || !st.IsDir() { diff --git a/cmd/minikube/cmd/image.go b/cmd/minikube/cmd/image.go index 2de8af2a6518..85eb23f710ed 100644 --- a/cmd/minikube/cmd/image.go +++ b/cmd/minikube/cmd/image.go @@ -80,7 +80,7 @@ var loadImageCmd = &cobra.Command{ Short: "Load an image into minikube", Long: "Load an image into minikube", Example: "minikube image load image\nminikube image load image.tar", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { if len(args) == 0 { exit.Message(reason.Usage, "Please provide an image in your local daemon to load into minikube via ") } @@ -171,7 +171,7 @@ var saveImageCmd = &cobra.Command{ Short: "Save a image from minikube", Long: "Save a image from minikube", Example: "minikube image save image\nminikube image save image image.tar", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { if len(args) == 0 { exit.Message(reason.Usage, "Please provide an image in the container runtime to save from minikube via ") } @@ -230,7 +230,7 @@ $ minikube image unload image busybox `, Args: cobra.MinimumNArgs(1), Aliases: []string{"remove", "unload"}, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { profile, err := config.LoadProfile(viper.GetString(config.ProfileName)) if err != nil { exit.Error(reason.Usage, "loading profile", err) @@ -247,7 +247,7 @@ var pullImageCmd = &cobra.Command{ Example: ` $ minikube image pull busybox `, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { profile, err := config.LoadProfile(viper.GetString(config.ProfileName)) if err != nil { exit.Error(reason.Usage, "loading profile", err) @@ -273,7 +273,7 @@ var buildImageCmd = &cobra.Command{ Short: "Build a container image in minikube", Long: "Build a container image, using the container runtime.", Example: `minikube image build .`, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { if len(args) < 1 { exit.Message(reason.Usage, "Please provide a path or url to build") } @@ -333,7 +333,7 @@ var listImageCmd = &cobra.Command{ $ minikube image ls `, Aliases: []string{"list"}, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { profile, err := config.LoadProfile(viper.GetString(config.ProfileName)) if err != nil { exit.Error(reason.Usage, "loading profile", err) @@ -352,7 +352,7 @@ var tagImageCmd = &cobra.Command{ $ minikube image tag source target `, Aliases: []string{"list"}, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { if len(args) != 2 { exit.Message(reason.Usage, "Please provide source and target image") } @@ -373,7 +373,7 @@ var pushImageCmd = &cobra.Command{ Example: ` $ minikube image push busybox `, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { profile, err := config.LoadProfile(viper.GetString(config.ProfileName)) if err != nil { exit.Error(reason.Usage, "loading profile", err) diff --git a/cmd/minikube/cmd/ip.go b/cmd/minikube/cmd/ip.go index 3a34fad294d0..1ac6dde42beb 100644 --- a/cmd/minikube/cmd/ip.go +++ b/cmd/minikube/cmd/ip.go @@ -30,7 +30,7 @@ var ipCmd = &cobra.Command{ Use: "ip", Short: "Retrieves the IP address of the specified node", Long: `Retrieves the IP address of the specified node, and writes it to STDOUT.`, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { co := mustload.Running(ClusterFlagValue()) n, _, err := node.Retrieve(*co.Config, nodeName) if err != nil { diff --git a/cmd/minikube/cmd/kubectl.go b/cmd/minikube/cmd/kubectl.go index a6e52c991862..a796ceea22e5 100644 --- a/cmd/minikube/cmd/kubectl.go +++ b/cmd/minikube/cmd/kubectl.go @@ -53,7 +53,7 @@ but optionally you can also run it directly on the control plane over the ssh co This can be useful if you cannot run kubectl locally for some reason, like unsupported host. Please be aware that when using --ssh all paths will apply to the remote machine.`, Example: "minikube kubectl -- --help\nminikube kubectl -- get pods --namespace kube-system", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { cc, err := config.Load(ClusterFlagValue()) version := constants.DefaultKubernetesVersion diff --git a/cmd/minikube/cmd/license.go b/cmd/minikube/cmd/license.go index 252450da2b5d..986a7d58928b 100644 --- a/cmd/minikube/cmd/license.go +++ b/cmd/minikube/cmd/license.go @@ -30,7 +30,7 @@ var licenseCmd = &cobra.Command{ Use: "license", Short: "Outputs the licenses of dependencies to a directory", Long: "Outputs the licenses of dependencies to a directory", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { if err := download.Licenses(dir); err != nil { exit.Error(reason.InetLicenses, "Failed to download licenses", err) } diff --git a/cmd/minikube/cmd/logs.go b/cmd/minikube/cmd/logs.go index 91122cf0e7ca..2c9d9f96d19c 100644 --- a/cmd/minikube/cmd/logs.go +++ b/cmd/minikube/cmd/logs.go @@ -62,7 +62,7 @@ var logsCmd = &cobra.Command{ Use: "logs", Short: "Returns logs to debug a local Kubernetes cluster", Long: `Gets the logs of the running instance, used for debugging minikube, not user code.`, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { var logOutput *os.File = os.Stdout var err error diff --git a/cmd/minikube/cmd/mount.go b/cmd/minikube/cmd/mount.go index dde841f25977..07e3545e38b3 100644 --- a/cmd/minikube/cmd/mount.go +++ b/cmd/minikube/cmd/mount.go @@ -91,7 +91,7 @@ var mountCmd = &cobra.Command{ Use: "mount [flags] :", Short: "Mounts the specified directory into minikube", Long: `Mounts the specified directory into minikube.`, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { if isKill { if err := killMountProcess(); err != nil { exit.Error(reason.HostKillMountProc, "Error killing mount process", err) diff --git a/cmd/minikube/cmd/node.go b/cmd/minikube/cmd/node.go index 5b6fbb4c5b9d..f0883baeb1ec 100644 --- a/cmd/minikube/cmd/node.go +++ b/cmd/minikube/cmd/node.go @@ -27,7 +27,7 @@ var nodeCmd = &cobra.Command{ Use: "node", Short: "Add, remove, or list additional nodes", Long: "Operations on nodes", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { exit.Message(reason.Usage, "Usage: minikube node [add|start|stop|delete|list]") }, } diff --git a/cmd/minikube/cmd/node_add.go b/cmd/minikube/cmd/node_add.go index 1e54aec7fb92..8fbed153d243 100644 --- a/cmd/minikube/cmd/node_add.go +++ b/cmd/minikube/cmd/node_add.go @@ -40,7 +40,7 @@ var nodeAddCmd = &cobra.Command{ Use: "add", Short: "Adds a node to the given cluster.", Long: "Adds a node to the given cluster config, and starts it.", - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { co := mustload.Healthy(ClusterFlagValue()) cc := co.Config diff --git a/cmd/minikube/cmd/node_delete.go b/cmd/minikube/cmd/node_delete.go index 686fdf6a3881..4a789da82c47 100644 --- a/cmd/minikube/cmd/node_delete.go +++ b/cmd/minikube/cmd/node_delete.go @@ -36,7 +36,7 @@ var nodeDeleteCmd = &cobra.Command{ Use: "delete", Short: "Deletes a node from a cluster.", Long: "Deletes a node from a cluster.", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { if len(args) == 0 { exit.Message(reason.Usage, "Usage: minikube node delete [name]") } diff --git a/cmd/minikube/cmd/node_list.go b/cmd/minikube/cmd/node_list.go index 006366b8ccd9..40f4687164e4 100644 --- a/cmd/minikube/cmd/node_list.go +++ b/cmd/minikube/cmd/node_list.go @@ -32,7 +32,7 @@ var nodeListCmd = &cobra.Command{ Use: "list", Short: "List nodes.", Long: "List existing minikube nodes.", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { if len(args) != 0 { exit.Message(reason.Usage, "Usage: minikube node list") } diff --git a/cmd/minikube/cmd/node_stop.go b/cmd/minikube/cmd/node_stop.go index b8f59f8c18cf..a45fd35032e1 100644 --- a/cmd/minikube/cmd/node_stop.go +++ b/cmd/minikube/cmd/node_stop.go @@ -34,7 +34,7 @@ var nodeStopCmd = &cobra.Command{ Use: "stop", Short: "Stops a node in a cluster.", Long: "Stops a node in a cluster.", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { if len(args) == 0 { exit.Message(reason.Usage, "Usage: minikube node stop [name]") } diff --git a/cmd/minikube/cmd/podman-env.go b/cmd/minikube/cmd/podman-env.go index fbcd4d920cee..f236e15a3f5a 100644 --- a/cmd/minikube/cmd/podman-env.go +++ b/cmd/minikube/cmd/podman-env.go @@ -138,7 +138,7 @@ var podmanEnvCmd = &cobra.Command{ Use: "podman-env", Short: "Configure environment to use minikube's Podman service", Long: `Sets up podman env variables; similar to '$(podman-machine env)'.`, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { sh := shell.EnvConfig{ Shell: shell.ForceShell, } diff --git a/cmd/minikube/cmd/root.go b/cmd/minikube/cmd/root.go index 2a6af4efa026..0d35165d5d2b 100644 --- a/cmd/minikube/cmd/root.go +++ b/cmd/minikube/cmd/root.go @@ -63,7 +63,7 @@ var RootCmd = &cobra.Command{ Use: "minikube", Short: "minikube quickly sets up a local Kubernetes cluster", Long: `minikube provisions and manages local Kubernetes clusters optimized for development workflows.`, - PersistentPreRun: func(cmd *cobra.Command, args []string) { + PersistentPreRun: func(_ *cobra.Command, _ []string) { for _, path := range dirs { if err := os.MkdirAll(path, 0777); err != nil { exit.Error(reason.HostHomeMkdir, "Error creating minikube directory", err) @@ -86,7 +86,7 @@ var RootCmd = &cobra.Command{ os.Setenv(constants.MinikubeRootlessEnv, "true") } }, - PersistentPostRun: func(cmd *cobra.Command, args []string) { + PersistentPostRun: func(_ *cobra.Command, _ []string) { if err := audit.LogCommandEnd(auditID); err != nil { klog.Warningf("failed to log command end to audit: %v", err) } diff --git a/cmd/minikube/cmd/service.go b/cmd/minikube/cmd/service.go index 28df4bbb8cca..8fbe24482935 100644 --- a/cmd/minikube/cmd/service.go +++ b/cmd/minikube/cmd/service.go @@ -74,7 +74,7 @@ var serviceCmd = &cobra.Command{ RootCmd.PersistentPreRun(cmd, args) }, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { if len(args) == 0 && !all || (len(args) > 0 && all) { exit.Message(reason.Usage, "You must specify service name(s) or --all") } diff --git a/cmd/minikube/cmd/service_list.go b/cmd/minikube/cmd/service_list.go index 338c993d0180..34bf7d55f4d3 100644 --- a/cmd/minikube/cmd/service_list.go +++ b/cmd/minikube/cmd/service_list.go @@ -41,7 +41,7 @@ var serviceListCmd = &cobra.Command{ Use: "list [flags]", Short: "Lists the URLs for the services in your local cluster", Long: `Lists the URLs for the services in your local cluster`, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { co := mustload.Healthy(ClusterFlagValue()) output := strings.ToLower(profileOutput) diff --git a/cmd/minikube/cmd/ssh-host.go b/cmd/minikube/cmd/ssh-host.go index 51d408d74cff..523357654ea9 100644 --- a/cmd/minikube/cmd/ssh-host.go +++ b/cmd/minikube/cmd/ssh-host.go @@ -44,7 +44,7 @@ var sshHostCmd = &cobra.Command{ Use: "ssh-host", Short: "Retrieve the ssh host key of the specified node", Long: "Retrieve the ssh host key of the specified node.", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { appendKnownHelper(nodeName, appendKnown) }, } diff --git a/cmd/minikube/cmd/ssh-key.go b/cmd/minikube/cmd/ssh-key.go index 7cdf6b564e1d..cd62510df4f4 100644 --- a/cmd/minikube/cmd/ssh-key.go +++ b/cmd/minikube/cmd/ssh-key.go @@ -34,7 +34,7 @@ var sshKeyCmd = &cobra.Command{ Use: "ssh-key", Short: "Retrieve the ssh identity key path of the specified node", Long: "Retrieve the ssh identity key path of the specified node, and writes it to STDOUT.", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { _, cc := mustload.Partial(ClusterFlagValue()) n, _, err := node.Retrieve(*cc, nodeName) if err != nil { diff --git a/cmd/minikube/cmd/ssh.go b/cmd/minikube/cmd/ssh.go index 15621092476b..c1a5db35c857 100644 --- a/cmd/minikube/cmd/ssh.go +++ b/cmd/minikube/cmd/ssh.go @@ -38,7 +38,7 @@ var sshCmd = &cobra.Command{ Use: "ssh", Short: "Log into the minikube environment (for debugging)", Long: "Log into or run a command on a machine with SSH; similar to 'docker-machine ssh'.", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { cname := ClusterFlagValue() co := mustload.Running(cname) if co.CP.Host.DriverName == driver.None { diff --git a/cmd/minikube/cmd/start_test.go b/cmd/minikube/cmd/start_test.go index 21286337f450..4b7e997eb52e 100644 --- a/cmd/minikube/cmd/start_test.go +++ b/cmd/minikube/cmd/start_test.go @@ -116,9 +116,7 @@ func TestGetKubernetesVersion(t *testing.T) { } } -var checkRepoMock = func(v semver.Version, repo string) error { - return nil -} +var checkRepoMock = func(_ semver.Version, _ string) error { return nil } func TestMirrorCountry(t *testing.T) { // Set default disk size value in lieu of flag init diff --git a/cmd/minikube/cmd/status.go b/cmd/minikube/cmd/status.go index aaee94cbb734..e45ef460e2b9 100644 --- a/cmd/minikube/cmd/status.go +++ b/cmd/minikube/cmd/status.go @@ -213,7 +213,7 @@ var statusCmd = &cobra.Command{ Long: `Gets the status of a local Kubernetes cluster. Exit status contains the status of minikube's VM, cluster and Kubernetes encoded on it's bits in this order from right to left. Eg: 7 meaning: 1 (for minikube NOK) + 2 (for cluster NOK) + 4 (for Kubernetes NOK)`, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { output = strings.ToLower(output) if output != "text" && statusFormat != defaultStatusFormat { exit.Message(reason.Usage, "Cannot use both --output and --format options") diff --git a/cmd/minikube/cmd/tunnel.go b/cmd/minikube/cmd/tunnel.go index cda2f6b2a912..279ab007eb60 100644 --- a/cmd/minikube/cmd/tunnel.go +++ b/cmd/minikube/cmd/tunnel.go @@ -56,7 +56,7 @@ var tunnelCmd = &cobra.Command{ PersistentPreRun: func(cmd *cobra.Command, args []string) { RootCmd.PersistentPreRun(cmd, args) }, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { manager := tunnel.NewManager() cname := ClusterFlagValue() co := mustload.Healthy(cname) diff --git a/cmd/minikube/cmd/unpause.go b/cmd/minikube/cmd/unpause.go index e1c590961efe..fd305bca6c9b 100644 --- a/cmd/minikube/cmd/unpause.go +++ b/cmd/minikube/cmd/unpause.go @@ -42,7 +42,7 @@ var unpauseCmd = &cobra.Command{ Use: "unpause", Aliases: []string{"resume"}, Short: "unpause Kubernetes", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { cname := ClusterFlagValue() register.SetEventLogPath(localpath.EventLog(cname)) diff --git a/cmd/minikube/cmd/update-check.go b/cmd/minikube/cmd/update-check.go index e0e2715937d2..ce12428ba611 100644 --- a/cmd/minikube/cmd/update-check.go +++ b/cmd/minikube/cmd/update-check.go @@ -29,7 +29,7 @@ var updateCheckCmd = &cobra.Command{ Use: "update-check", Short: "Print current and latest version number", Long: `Print current and latest version number`, - Run: func(command *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { url := notify.GithubMinikubeReleasesURL r, err := notify.AllVersionsFromURL(url) if err != nil { diff --git a/cmd/minikube/cmd/update-context.go b/cmd/minikube/cmd/update-context.go index e50fb9b827c9..2be567dd709d 100644 --- a/cmd/minikube/cmd/update-context.go +++ b/cmd/minikube/cmd/update-context.go @@ -32,7 +32,7 @@ var updateContextCmd = &cobra.Command{ Short: "Update kubeconfig in case of an IP or port change", Long: `Retrieves the IP address of the running cluster, checks it with IP in kubeconfig, and corrects kubeconfig if incorrect.`, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { cname := ClusterFlagValue() co := mustload.Running(cname) // cluster extension metada for kubeconfig diff --git a/cmd/minikube/cmd/version.go b/cmd/minikube/cmd/version.go index 6fcbb92ecf07..7f44055dd019 100644 --- a/cmd/minikube/cmd/version.go +++ b/cmd/minikube/cmd/version.go @@ -42,7 +42,7 @@ var versionCmd = &cobra.Command{ Use: "version", Short: "Print the version of minikube", Long: `Print the version of minikube.`, - Run: func(command *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { minikubeVersion := version.GetVersion() gitCommitID := version.GetGitCommitID() data := map[string]interface{}{ diff --git a/cmd/performance/mkcmp/cmd/mkcmp.go b/cmd/performance/mkcmp/cmd/mkcmp.go index c7e2c21f989e..6817cabe74d1 100644 --- a/cmd/performance/mkcmp/cmd/mkcmp.go +++ b/cmd/performance/mkcmp/cmd/mkcmp.go @@ -32,10 +32,10 @@ var rootCmd = &cobra.Command{ Short: "mkcmp is used to compare performance of two minikube binaries", SilenceUsage: true, SilenceErrors: true, - PersistentPreRunE: func(cmd *cobra.Command, args []string) error { + PersistentPreRunE: func(_ *cobra.Command, args []string) error { return validateArgs(args) }, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(_ *cobra.Command, args []string) error { binaries, err := retrieveBinaries(args) if err != nil { return err diff --git a/hack/boilerplate/boilerplate.go b/hack/boilerplate/boilerplate.go index a3284d590fb7..5672dc701e2a 100644 --- a/hack/boilerplate/boilerplate.go +++ b/hack/boilerplate/boilerplate.go @@ -135,7 +135,7 @@ func filePasses(filename string, expectedBoilerplate []byte) (bool, error) { // filesToCheck returns the list of the filers that will be checked for the boilerplate. func filesToCheck(rootDir string, extensions map[string][]byte) ([]string, error) { var outFiles []string - err := filepath.Walk(rootDir, func(path string, info os.FileInfo, err error) error { + err := filepath.Walk(rootDir, func(path string, info os.FileInfo, _ error) error { // remove current workdir from the beginning of the path in case it matches the skipped path cwd, _ := os.Getwd() // replace "\" with "\\" for windows style path diff --git a/hack/legacy_fill_db/filldb.go b/hack/legacy_fill_db/filldb.go index 7bab254435dc..744025aa640b 100644 --- a/hack/legacy_fill_db/filldb.go +++ b/hack/legacy_fill_db/filldb.go @@ -154,7 +154,7 @@ func processCommitFolder(commitSha string, logger *log.Logger, gp string) error dbPath := fmt.Sprintf(dbPathPattern, os.Getenv("DB_PASS")) // Iterate over the JSON files in the local directory - err = filepath.Walk(dirPath, func(path string, info os.FileInfo, err error) error { + err = filepath.Walk(dirPath, func(path string, info os.FileInfo, _ error) error { filename := filepath.Base(path[:len(path)-len(".json")]) if !info.IsDir() && strings.HasSuffix(path, ".json") && !strings.HasSuffix(path, "summary.json") && notInDB(commitSha, filename) { gopoghCmd := fmt.Sprintf(gopoghCommand, gp, filename, mkRepo, path, commitSha, host, dbPath, dbBackend) diff --git a/pkg/drivers/kic/oci/network_create_test.go b/pkg/drivers/kic/oci/network_create_test.go index ac4e1c45eff1..79a931789f4b 100644 --- a/pkg/drivers/kic/oci/network_create_test.go +++ b/pkg/drivers/kic/oci/network_create_test.go @@ -23,7 +23,7 @@ import ( ) var dockerResponse string -var dockerInspectGetterMock = func(name string) (*RunResult, error) { +var dockerInspectGetterMock = func(_ string) (*RunResult, error) { var responseInBytes bytes.Buffer responseInBytes.WriteString(dockerResponse) response := &RunResult{Stdout: responseInBytes} @@ -84,7 +84,7 @@ func TestDockerInspect(t *testing.T) { } var podmanResponse string -var podmanInspectGetterMock = func(name string) (*RunResult, error) { +var podmanInspectGetterMock = func(_ string) (*RunResult, error) { var responseInBytes bytes.Buffer responseInBytes.WriteString(podmanResponse) response := &RunResult{Stdout: responseInBytes} diff --git a/pkg/generate/testdocs.go b/pkg/generate/testdocs.go index 46bb42d5a769..75e331762646 100644 --- a/pkg/generate/testdocs.go +++ b/pkg/generate/testdocs.go @@ -43,7 +43,7 @@ func TestDocs(docPath string, pathToCheck string) error { return err } - err = filepath.Walk(pathToCheck, func(path string, info os.FileInfo, err error) error { + err = filepath.Walk(pathToCheck, func(path string, info os.FileInfo, _ error) error { if info.IsDir() || !strings.HasSuffix(path, ".go") { return nil } diff --git a/pkg/minikube/command/fake_runner.go b/pkg/minikube/command/fake_runner.go index d5ea83f1a68a..6a775615a71e 100644 --- a/pkg/minikube/command/fake_runner.go +++ b/pkg/minikube/command/fake_runner.go @@ -193,7 +193,7 @@ func (f *FakeCommandRunner) GetFileToContents(filename string) (string, error) { func (f *FakeCommandRunner) commands() []string { cmds := []string{} - f.cmdMap.Range(func(k, v interface{}) bool { + f.cmdMap.Range(func(k, _ interface{}) bool { cmds = append(cmds, fmt.Sprintf("%s", k)) return true }) @@ -208,7 +208,7 @@ func (f *FakeCommandRunner) DumpMaps(w io.Writer) { return true }) fmt.Fprintln(w, "Filenames: ") - f.fileMap.Range(func(k, v interface{}) bool { + f.fileMap.Range(func(k, _ interface{}) bool { fmt.Fprint(w, k) return true }) diff --git a/pkg/minikube/download/download_test.go b/pkg/minikube/download/download_test.go index 7ec88b0df7da..beb44643fbd1 100644 --- a/pkg/minikube/download/download_test.go +++ b/pkg/minikube/download/download_test.go @@ -52,7 +52,7 @@ func testBinaryDownloadPreventsMultipleDownload(t *testing.T) { downloadNum := 0 DownloadMock = mockSleepDownload(&downloadNum) - checkCache = func(file string) (fs.FileInfo, error) { + checkCache = func(_ string) (fs.FileInfo, error) { if downloadNum == 0 { return nil, fmt.Errorf("some error") } @@ -90,15 +90,15 @@ func testPreloadDownloadPreventsMultipleDownload(t *testing.T) { t.Fatalf("failed to write to temp file: %v", err) } - checkCache = func(file string) (fs.FileInfo, error) { + checkCache = func(_ string) (fs.FileInfo, error) { if downloadNum == 0 { return nil, fmt.Errorf("some error") } return os.Stat(f.Name()) } - checkPreloadExists = func(k8sVersion, containerRuntime, driverName string, forcePreload ...bool) bool { return true } - getChecksum = func(k8sVersion, containerRuntime string) ([]byte, error) { return []byte("check"), nil } - ensureChecksumValid = func(k8sVersion, containerRuntime, path string, checksum []byte) error { return nil } + checkPreloadExists = func(_, _, _ string, _ ...bool) bool { return true } + getChecksum = func(_, _ string) ([]byte, error) { return []byte("check"), nil } + ensureChecksumValid = func(_, _, _ string, _ []byte) error { return nil } var group sync.WaitGroup group.Add(2) @@ -123,10 +123,10 @@ func testPreloadNotExists(t *testing.T) { downloadNum := 0 DownloadMock = mockSleepDownload(&downloadNum) - checkCache = func(file string) (fs.FileInfo, error) { return nil, fmt.Errorf("cache not found") } - checkPreloadExists = func(k8sVersion, containerRuntime, driverName string, forcePreload ...bool) bool { return false } - getChecksum = func(k8sVersion, containerRuntime string) ([]byte, error) { return []byte("check"), nil } - ensureChecksumValid = func(k8sVersion, containerRuntime, path string, checksum []byte) error { return nil } + checkCache = func(_ string) (fs.FileInfo, error) { return nil, fmt.Errorf("cache not found") } + checkPreloadExists = func(_, _, _ string, _ ...bool) bool { return false } + getChecksum = func(_, _ string) ([]byte, error) { return []byte("check"), nil } + ensureChecksumValid = func(_, _, _ string, _ []byte) error { return nil } err := Preload(constants.DefaultKubernetesVersion, constants.Docker, "docker") if err != nil { @@ -142,10 +142,10 @@ func testPreloadChecksumMismatch(t *testing.T) { downloadNum := 0 DownloadMock = mockSleepDownload(&downloadNum) - checkCache = func(file string) (fs.FileInfo, error) { return nil, fmt.Errorf("cache not found") } - checkPreloadExists = func(k8sVersion, containerRuntime, driverName string, forcePreload ...bool) bool { return true } - getChecksum = func(k8sVersion, containerRuntime string) ([]byte, error) { return []byte("check"), nil } - ensureChecksumValid = func(k8sVersion, containerRuntime, path string, checksum []byte) error { + checkCache = func(_ string) (fs.FileInfo, error) { return nil, fmt.Errorf("cache not found") } + checkPreloadExists = func(_, _, _ string, _ ...bool) bool { return true } + getChecksum = func(_, _ string) ([]byte, error) { return []byte("check"), nil } + ensureChecksumValid = func(_, _, _ string, _ []byte) error { return fmt.Errorf("checksum mismatch") } @@ -162,7 +162,7 @@ func testImageToCache(t *testing.T) { downloadNum := 0 DownloadMock = mockSleepDownload(&downloadNum) - checkImageExistsInCache = func(img string) bool { return downloadNum > 0 } + checkImageExistsInCache = func(_ string) bool { return downloadNum > 0 } var group sync.WaitGroup group.Add(2) @@ -185,12 +185,12 @@ func testImageToCache(t *testing.T) { // Validates that preload existence checks correctly caches values retrieved by remote checks. func testPreloadExistsCaching(t *testing.T) { - checkCache = func(file string) (fs.FileInfo, error) { + checkCache = func(_ string) (fs.FileInfo, error) { return nil, fmt.Errorf("cache not found") } doesPreloadExist := false checkCalled := false - checkRemotePreloadExists = func(k8sVersion, containerRuntime string) bool { + checkRemotePreloadExists = func(_, _ string) bool { checkCalled = true return doesPreloadExist } @@ -229,10 +229,10 @@ func testPreloadWithCachedSizeZero(t *testing.T) { t.Fatalf("failed to create temp file: %v", err) } - checkCache = func(file string) (fs.FileInfo, error) { return os.Stat(f.Name()) } - checkPreloadExists = func(k8sVersion, containerRuntime, driverName string, forcePreload ...bool) bool { return true } - getChecksum = func(k8sVersion, containerRuntime string) ([]byte, error) { return []byte("check"), nil } - ensureChecksumValid = func(k8sVersion, containerRuntime, path string, checksum []byte) error { return nil } + checkCache = func(_ string) (fs.FileInfo, error) { return os.Stat(f.Name()) } + checkPreloadExists = func(_, _, _ string, _ ...bool) bool { return true } + getChecksum = func(_, _ string) ([]byte, error) { return []byte("check"), nil } + ensureChecksumValid = func(_, _, _ string, _ []byte) error { return nil } if err := Preload(constants.DefaultKubernetesVersion, constants.Docker, "docker"); err != nil { t.Errorf("Expected no error with cached preload of size zero") diff --git a/pkg/minikube/extract/extract.go b/pkg/minikube/extract/extract.go index 94901b770490..5bacd33d386f 100644 --- a/pkg/minikube/extract/extract.go +++ b/pkg/minikube/extract/extract.go @@ -134,7 +134,7 @@ func TranslatableStrings(paths []string, functions []string, output string) erro f := e.fs.Pop().(funcType) e.currentFunc = f for _, root := range paths { - err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error { + err := filepath.Walk(root, func(path string, _ os.FileInfo, _ error) error { if shouldCheckFile(path) { e.filename = path return inspectFile(e) diff --git a/pkg/minikube/localpath/localpath_test.go b/pkg/minikube/localpath/localpath_test.go index 9b73737bbf0f..ad62cc361fc7 100644 --- a/pkg/minikube/localpath/localpath_test.go +++ b/pkg/minikube/localpath/localpath_test.go @@ -31,7 +31,7 @@ func TestReplaceWinDriveLetterToVolumeName(t *testing.T) { if runtime.GOOS != "windows" { // Replace to fake func. - getWindowsVolumeName = func(d string) (string, error) { + getWindowsVolumeName = func(_ string) (string, error) { return `/`, nil } // Add dummy Windows drive letter. diff --git a/pkg/minikube/proxy/proxy_test.go b/pkg/minikube/proxy/proxy_test.go index a7da8cd7e912..467d11cec080 100644 --- a/pkg/minikube/proxy/proxy_test.go +++ b/pkg/minikube/proxy/proxy_test.go @@ -193,10 +193,11 @@ func TestExcludeIP(t *testing.T) { func TestUpdateTransport(t *testing.T) { t.Run("new", func(t *testing.T) { - rc := rest.Config{} - UpdateTransport(&rc) - tr := &http.Transport{} - tr.RegisterProtocol("file", http.NewFileTransport(http.Dir("/tmp"))) + rcBefore := rest.Config{} + rcAfter := UpdateTransport(&rcBefore) + if rcAfter.WrapTransport == nil { + t.Errorf("UpdateTransport(%v) = %v, WrapTransport was unexpectedly nil", rcBefore, rcAfter) + } }) t.Run("existing", func(t *testing.T) { // rest config initialized with WrapTransport function diff --git a/pkg/minikube/shell/shell.go b/pkg/minikube/shell/shell.go index e13341596f5e..0c9958e4233b 100644 --- a/pkg/minikube/shell/shell.go +++ b/pkg/minikube/shell/shell.go @@ -140,7 +140,7 @@ REM @FOR /f "tokens=*" %%i IN ('%s --shell cmd') DO @%%i unsetPrefix: "", unsetSuffix: "\n", unsetDelimiter: "", - usageHint: func(s ...interface{}) string { + usageHint: func(_ ...interface{}) string { return "" }, }, diff --git a/pkg/minikube/tunnel/tunnel_manager_test.go b/pkg/minikube/tunnel/tunnel_manager_test.go index bf00c37ed7f9..ea41b2c863af 100644 --- a/pkg/minikube/tunnel/tunnel_manager_test.go +++ b/pkg/minikube/tunnel/tunnel_manager_test.go @@ -38,7 +38,7 @@ func TestTunnelManagerEventHandling(t *testing.T) { { name: "tunnel quits on stopped minikube", repeat: 1, - test: func(tunnel *tunnelStub, cancel context.CancelFunc, ready, check, done chan bool) error { + test: func(tunnel *tunnelStub, _ context.CancelFunc, ready, check, done chan bool) error { tunnel.mockClusterInfo = &Status{ MinikubeState: Stopped, } @@ -63,7 +63,7 @@ func TestTunnelManagerEventHandling(t *testing.T) { { name: "tunnel quits on ctrlc before doing a check", repeat: 1, - test: func(tunnel *tunnelStub, cancel context.CancelFunc, ready, check, done chan bool) error { + test: func(tunnel *tunnelStub, cancel context.CancelFunc, ready, _, done chan bool) error { tunnel.mockClusterInfo = &Status{ MinikubeState: Stopped, } @@ -137,7 +137,7 @@ func TestTunnelManagerEventHandling(t *testing.T) { go tunnelManager.run(ctx, tunnel, ready, check, done) err = tc.test(tunnel, cancel, ready, check, done) if err != nil { - klog.Errorf("error at %d", i) + t.Errorf("error at %d", i) } } }) diff --git a/pkg/network/network.go b/pkg/network/network.go index 616f75f0c4b4..8077ef633385 100644 --- a/pkg/network/network.go +++ b/pkg/network/network.go @@ -27,8 +27,6 @@ import ( "k8s.io/minikube/pkg/util/lock" ) -const defaultReservationPeriod = 1 * time.Minute - // Parameters contains main network parameters. type Parameters struct { IP string // IP address of network @@ -204,7 +202,7 @@ func FreeSubnet(startSubnet string, step, tries int) (*Parameters, error) { return nil, err } if !taken { - if reservation, err := reserveSubnet(subnet, defaultReservationPeriod); err == nil { + if reservation, err := reserveSubnet(subnet); err == nil { n.reservation = reservation klog.Infof("using free private subnet %s: %+v", n.CIDR, n) return n, nil @@ -241,8 +239,8 @@ func ParseAddr(addr string) (net.IP, *net.IPNet, error) { return ip, network, err } -// reserveSubnet returns releaser if subnet was successfully reserved for given period, creating lock for subnet to avoid race condition between multiple minikube instances (especially while testing in parallel). -var reserveSubnet = func(subnet string, period time.Duration) (mutex.Releaser, error) { +// reserveSubnet returns releaser if subnet was successfully reserved, creating lock for subnet to avoid race condition between multiple minikube instances (especially while testing in parallel). +var reserveSubnet = func(subnet string) (mutex.Releaser, error) { spec := lock.PathMutexSpec(subnet) spec.Timeout = 1 * time.Millisecond // practically: just check, don't wait reservation, err := mutex.Acquire(spec) diff --git a/pkg/network/network_test.go b/pkg/network/network_test.go index ad1eddead432..2fae67de86a6 100644 --- a/pkg/network/network_test.go +++ b/pkg/network/network_test.go @@ -19,13 +19,12 @@ package network import ( "strings" "testing" - "time" "github.com/juju/mutex/v2" ) func TestFreeSubnet(t *testing.T) { - reserveSubnet = func(subnet string, period time.Duration) (mutex.Releaser, error) { return nil, nil } + reserveSubnet = func(_ string) (mutex.Releaser, error) { return nil, nil } t.Run("NoRetriesSuccess", func(t *testing.T) { startingSubnet := "192.168.0.0" @@ -46,7 +45,7 @@ func TestFreeSubnet(t *testing.T) { isSubnetTaken = originalIsSubnetTaken }() - isSubnetTaken = func(subnet string) (bool, error) { + isSubnetTaken = func(_ string) (bool, error) { count++ return count == 1, nil } diff --git a/pkg/util/utils.go b/pkg/util/utils.go index a30b9e08e555..e7a6a7dc10b2 100644 --- a/pkg/util/utils.go +++ b/pkg/util/utils.go @@ -74,7 +74,7 @@ func GetBinaryDownloadURL(version, platform, arch string) string { // ChownR does a recursive os.Chown func ChownR(path string, uid, gid int) error { - return filepath.Walk(path, func(name string, info os.FileInfo, err error) error { + return filepath.Walk(path, func(name string, _ os.FileInfo, err error) error { if err == nil { err = os.Chown(name, uid, gid) } diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index b3e97c289248..bc288374c7fd 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -780,8 +780,8 @@ func imageID(image string) string { }, } - if imgIds, ok := ids[image]; ok { - if id, ok := imgIds[runtime.GOARCH]; ok { + if imgIDs, ok := ids[image]; ok { + if id, ok := imgIDs[runtime.GOARCH]; ok { return id } panic(fmt.Sprintf("unexpected architecture for image %q: %v", image, runtime.GOARCH)) diff --git a/test/integration/functional_test_tunnel_test.go b/test/integration/functional_test_tunnel_test.go index 63939d2fb11f..3f08a2e6062c 100644 --- a/test/integration/functional_test_tunnel_test.go +++ b/test/integration/functional_test_tunnel_test.go @@ -379,7 +379,7 @@ func validateAccessDNS(_ context.Context, t *testing.T, profile string) { dnsIP := fmt.Sprintf("%s:53", ip) // Set kube-dns dial - kubeDNSDial := func(ctx context.Context, network, address string) (net.Conn, error) { + kubeDNSDial := func(ctx context.Context, _, _ string) (net.Conn, error) { d := net.Dialer{} return d.DialContext(ctx, "udp", dnsIP) }