Skip to content

Commit a85e155

Browse files
authored
Merge pull request #12252 from medyagh/fix_lint
Fix lint for gocilint 1.41.1
2 parents 79df20b + 6aa7abc commit a85e155

File tree

14 files changed

+30
-27
lines changed

14 files changed

+30
-27
lines changed

Diff for: Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ MINIKUBE_RELEASES_URL=https://github.com/kubernetes/minikube/releases/download
6969
KERNEL_VERSION ?= 4.19.182
7070
# latest from https://github.com/golangci/golangci-lint/releases
7171
# update this only by running `make update-golint-version`
72-
GOLINT_VERSION ?= v1.39.0
72+
GOLINT_VERSION ?= v1.41.1
7373
# Limit number of default jobs, to avoid the CI builds running out of memory
7474
GOLINT_JOBS ?= 4
7575
# see https://github.com/golangci/golangci-lint#memory-usage-of-golangci-lint

Diff for: cmd/auto-pause/auto-pause-hook/config.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ func selfRegistration(clientset *kubernetes.Clientset, caCert []byte) {
9191
klog.Fatal(err2)
9292
}
9393
}
94-
var failurePolicy v1.FailurePolicyType = v1.Fail
95-
var sideEffects v1.SideEffectClass = v1.SideEffectClassNone
94+
var failurePolicy = v1.Fail
95+
var sideEffects = v1.SideEffectClassNone
9696

9797
webhookConfig := &v1.MutatingWebhookConfiguration{
9898
ObjectMeta: metav1.ObjectMeta{

Diff for: cmd/minikube/cmd/delete.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ func runDelete(cmd *cobra.Command, args []string) {
157157
if err != nil {
158158
klog.Warningf("'error loading profiles in minikube home %q: %v", localpath.MiniPath(), err)
159159
}
160-
profilesToDelete := append(validProfiles, invalidProfiles...)
160+
profilesToDelete := validProfiles
161+
profilesToDelete = append(profilesToDelete, invalidProfiles...)
161162
// in the case user has more than 1 profile and runs --purge
162163
// to prevent abandoned VMs/containers, force user to run with delete --all
163164
if purge && len(profilesToDelete) > 1 && !deleteAll {

Diff for: cmd/minikube/cmd/delete_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,8 @@ func TestDeleteAllProfiles(t *testing.T) {
221221
t.Errorf("ListProfiles length = %d, expected %d\nvalid: %v\ninvalid: %v\n", len(validProfiles)+len(inValidProfiles), numberOfTotalProfileDirs, validProfiles, inValidProfiles)
222222
}
223223

224-
profiles := append(validProfiles, inValidProfiles...)
224+
profiles := validProfiles
225+
profiles = append(profiles, inValidProfiles...)
225226
hostAndDirsDeleter = hostAndDirsDeleterMock
226227
errs := DeleteProfiles(profiles)
227228

Diff for: hack/benchmark/cpu_usage/auto_pause/chart.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func execute() error {
7272

7373
// Open non-autopause csv file of benchmark summary
7474
napResults := []float64{}
75-
var napFn string = "./out/benchmark-results/" + sessionID + "/cstat.nonautopause.summary"
75+
napFn := "./out/benchmark-results/" + sessionID + "/cstat.nonautopause.summary"
7676
napFile, err := os.Open(napFn)
7777
if err != nil {
7878
return errors.Wrap(err, "Missing summary csv")
@@ -97,7 +97,7 @@ func execute() error {
9797

9898
// Open auto-pause csv file of benchmark summary
9999
apResults := []float64{}
100-
var apFn string = "./out/benchmark-results/" + sessionID + "/cstat.autopause.summary"
100+
apFn := "./out/benchmark-results/" + sessionID + "/cstat.autopause.summary"
101101
apFile, err := os.Open(apFn)
102102
if err != nil {
103103
return errors.Wrap(err, "Missing summary csv")

Diff for: hack/benchmark/cpu_usage/idle_only/chart.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func execute() error {
7171

7272
// Open csv file of benchmark summary
7373
results := []float64{}
74-
var fn string = "./out/benchmark-results/" + sessionID + "/cstat.summary"
74+
fn := "./out/benchmark-results/" + sessionID + "/cstat.summary"
7575
file, err := os.Open(fn)
7676
if err != nil {
7777
return errors.Wrap(err, "Missing summary csv")

Diff for: pkg/gvisor/enable.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func Enable() error {
6262
return errors.Wrap(err, "restarting containerd")
6363
}
6464
// When pod is terminated, disable gvisor and exit
65-
c := make(chan os.Signal)
65+
c := make(chan os.Signal, 1)
6666
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
6767
go func() {
6868
<-c

Diff for: pkg/minikube/bootstrapper/certs.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,15 @@ func generateProfileCerts(k8s config.KubernetesConfig, n config.Node, ccs CACert
204204
return nil, errors.Wrap(err, "getting service cluster ip")
205205
}
206206

207-
apiServerIPs := append(k8s.APIServerIPs,
207+
apiServerIPs := k8s.APIServerIPs
208+
apiServerIPs = append(apiServerIPs,
208209
net.ParseIP(n.IP), serviceIP, net.ParseIP(oci.DefaultBindIPV4), net.ParseIP("10.0.0.1"))
209210

210-
apiServerNames := append(k8s.APIServerNames, k8s.APIServerName, constants.ControlPlaneAlias)
211-
apiServerAlternateNames := append(
212-
apiServerNames,
211+
apiServerNames := k8s.APIServerNames
212+
apiServerNames = append(apiServerNames, k8s.APIServerName, constants.ControlPlaneAlias)
213+
214+
apiServerAlternateNames := apiServerNames
215+
apiServerAlternateNames = append(apiServerAlternateNames,
213216
util.GetAlternateDNS(k8s.DNSDomain)...)
214217

215218
daemonHost := oci.DaemonHost(k8s.ContainerRuntime)

Diff for: pkg/minikube/cruntime/cri.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ func pauseCRIContainers(cr CommandRunner, root string, ids []string) error {
134134
args = append(args, "--root", root)
135135
}
136136
args = append(args, "pause")
137-
137+
cargs := args
138138
for _, id := range ids {
139-
cargs := append(args, id)
139+
cargs = append(cargs, id)
140140
if _, err := cr.RunCmd(exec.Command("sudo", cargs...)); err != nil {
141141
return errors.Wrap(err, "runc")
142142
}
@@ -161,9 +161,9 @@ func unpauseCRIContainers(cr CommandRunner, root string, ids []string) error {
161161
args = append(args, "--root", root)
162162
}
163163
args = append(args, "resume")
164-
164+
cargs := args
165165
for _, id := range ids {
166-
cargs := append(args, id)
166+
cargs := append(cargs, id)
167167
if _, err := cr.RunCmd(exec.Command("sudo", cargs...)); err != nil {
168168
return errors.Wrap(err, "runc")
169169
}

Diff for: pkg/minikube/proxy/proxy_test.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,9 @@ func TestExcludeIP(t *testing.T) {
222222
func TestUpdateTransport(t *testing.T) {
223223
t.Run("new", func(t *testing.T) {
224224
rc := rest.Config{}
225-
c := UpdateTransport(&rc)
225+
UpdateTransport(&rc)
226226
tr := &http.Transport{}
227227
tr.RegisterProtocol("file", http.NewFileTransport(http.Dir("/tmp")))
228-
rt := c.WrapTransport(tr)
229-
if _, ok := rt.(http.RoundTripper); !ok {
230-
t.Fatalf("Cannot cast rt(%v) to http.RoundTripper", rt)
231-
}
232228
})
233229
t.Run("existing", func(t *testing.T) {
234230
// rest config initialized with WrapTransport function

Diff for: pkg/minikube/registry/drvs/docker/docker_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ type testCase struct {
3030
}
3131

3232
func appendVersionVariations(tc []testCase, v []int, reason string) []testCase {
33-
appendedTc := append(tc, testCase{
33+
appendedTc := tc
34+
appendedTc = append(appendedTc, testCase{
3435
version: fmt.Sprintf("linux-%02d.%02d", v[0], v[1]),
3536
expect: reason,
3637
})

Diff for: pkg/minikube/tunnel/route_darwin.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func (router *osRouter) EnsureRouteIsAdded(route *Route) error {
5050
command := exec.Command("sudo", "route", "-n", "add", serviceCIDR, gatewayIP)
5151
klog.Infof("About to run command: %s", command.Args)
5252
stdInAndOut, err := command.CombinedOutput()
53-
message := fmt.Sprintf("%s", stdInAndOut)
53+
message := string(stdInAndOut)
5454
re := regexp.MustCompile(fmt.Sprintf("add net (.*): gateway %s\n", gatewayIP))
5555
if !re.MatchString(message) {
5656
return fmt.Errorf("error adding Route: %s, %d", message, len(strings.Split(message, "\n")))
@@ -164,7 +164,7 @@ func (router *osRouter) Cleanup(route *Route) error {
164164
if err != nil {
165165
return err
166166
}
167-
msg := fmt.Sprintf("%s", stdInAndOut)
167+
msg := string(stdInAndOut)
168168
klog.V(4).Infof("%s", msg)
169169
re := regexp.MustCompile("^delete net ([^:]*)$")
170170
if !re.MatchString(msg) {

Diff for: pkg/minikube/tunnel/route_linux.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func (router *osRouter) Cleanup(route *Route) error {
129129
klog.Infof("Cleaning up route for CIDR %s to gateway %s\n", serviceCIDR, gatewayIP)
130130
command := exec.Command("sudo", "ip", "route", "delete", serviceCIDR)
131131
stdInAndOut, err := command.CombinedOutput()
132-
message := fmt.Sprintf("%s", stdInAndOut)
132+
message := string(stdInAndOut)
133133
klog.Infof("%s", message)
134134
if err != nil {
135135
return fmt.Errorf("error deleting Route: %s, %s", message, err)

Diff for: pkg/provision/provision.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,9 @@ func configureAuth(p miniProvisioner) error {
106106
return err
107107
}
108108

109+
hosts := authOptions.ServerCertSANs
109110
// The Host IP is always added to the certificate's SANs list
110-
hosts := append(authOptions.ServerCertSANs, ip, hostIP, "localhost", "127.0.0.1", "minikube", machineName)
111+
hosts = append(hosts, ip, hostIP, "localhost", "127.0.0.1", "minikube", machineName)
111112
klog.Infof("generating server cert: %s ca-key=%s private-key=%s org=%s san=%s",
112113
authOptions.ServerCertPath,
113114
authOptions.CaCertPath,

0 commit comments

Comments
 (0)