Skip to content

Commit ccf4af0

Browse files
committed
change depricated golint to revive and fix lint issues
1 parent a85e155 commit ccf4af0

File tree

17 files changed

+28
-73
lines changed

17 files changed

+28
-73
lines changed

Makefile

+3-11
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ RPM_VERSION ?= $(DEB_VERSION)
3232
RPM_REVISION ?= 0
3333

3434
# used by hack/jenkins/release_build_and_upload.sh and KVM_BUILD_IMAGE, see also BUILD_IMAGE below
35-
# update this only by running `make update-golang-version`
3635
GO_VERSION ?= 1.16.7
3736

3837
# replace "x.y.0" => "x.y". kube-cross and golang.org/dl use different formats for x.y.0 go versions
@@ -67,17 +66,16 @@ MINIKUBE_UPLOAD_LOCATION := gs://${MINIKUBE_BUCKET}
6766
MINIKUBE_RELEASES_URL=https://github.com/kubernetes/minikube/releases/download
6867

6968
KERNEL_VERSION ?= 4.19.182
70-
# latest from https://github.com/golangci/golangci-lint/releases
71-
# update this only by running `make update-golint-version`
72-
GOLINT_VERSION ?= v1.41.1
69+
# latest from https://github.com/golangci/golangci-lint/releases
70+
GOLINT_VERSION ?= v1.39.0
7371
# Limit number of default jobs, to avoid the CI builds running out of memory
7472
GOLINT_JOBS ?= 4
7573
# see https://github.com/golangci/golangci-lint#memory-usage-of-golangci-lint
7674
GOLINT_GOGC ?= 100
7775
# options for lint (golangci-lint)
7876
GOLINT_OPTIONS = --timeout 7m \
7977
--build-tags "${MINIKUBE_INTEGRATION_BUILD_TAGS}" \
80-
--enable gofmt,goimports,gocritic,golint,gocyclo,misspell,nakedret,stylecheck,unconvert,unparam,dogsled \
78+
--enable gofmt,goimports,gocritic,revive,gocyclo,misspell,nakedret,stylecheck,unconvert,unparam,dogsled \
8179
--exclude 'variable on range scope.*in function literal|ifElseChain'
8280

8381
export GO111MODULE := on
@@ -975,12 +973,6 @@ update-kubernetes-version:
975973
(cd hack/update/kubernetes_version && \
976974
go run update_kubernetes_version.go)
977975

978-
.PHONY: update-golint-version
979-
update-golint-version:
980-
(cd hack/update/golint_version && \
981-
go run update_golint_version.go)
982-
983-
984976
.PHONY: update-kubernetes-version-pr
985977
update-kubernetes-version-pr:
986978
ifndef GITHUB_TOKEN

hack/benchmark/time-to-k8s/chart.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,7 @@ func createChart(chartPath string, values []plotter.Values, totals []float64, na
220220

221221
p.Add(l)
222222

223-
if err := p.Save(12*vg.Inch, 8*vg.Inch, chartPath); err != nil {
224-
return err
225-
}
226-
227-
return nil
223+
return p.Save(12*vg.Inch, 8*vg.Inch, chartPath)
228224
}
229225

230226
func createBars(values plotter.Values, index int) (*plotter.BarChart, error) {

hack/update/registry.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,7 @@ func crUpdate(ctx context.Context, reg registry, image, version string) error {
9898
// TagImage tags local image:current with stable version, and returns any error occurred.
9999
func TagImage(ctx context.Context, image, current, stable string) error {
100100
tag := exec.CommandContext(ctx, "docker", "tag", image+":"+current, image+":"+stable)
101-
if err := RunWithRetryNotify(ctx, tag, nil, 1*time.Second, 10); err != nil {
102-
return err
103-
}
104-
return nil
101+
return RunWithRetryNotify(ctx, tag, nil, 1*time.Second, 10)
105102
}
106103

107104
// PullImage checks if current image exists locally, tries to pull it if not, and returns reference image url and any error occurred.

hack/update/update.go

+2-5
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ func RunWithRetryNotify(ctx context.Context, cmd *exec.Cmd, stdin io.Reader, max
189189
notify := func(err error, wait time.Duration) {
190190
klog.Errorf("Temporary error running '%s' (will retry in %s): %v", cmd.String(), wait, err)
191191
}
192-
if err := backoff.RetryNotify(func() error {
192+
return backoff.RetryNotify(func() error {
193193
cmd.Stdin = stdin
194194
var stderr bytes.Buffer
195195
cmd.Stderr = &stderr
@@ -198,10 +198,7 @@ func RunWithRetryNotify(ctx context.Context, cmd *exec.Cmd, stdin io.Reader, max
198198
return fmt.Errorf("%w: %s", err, stderr.String())
199199
}
200200
return nil
201-
}, bc, notify); err != nil {
202-
return err
203-
}
204-
return nil
201+
}, bc, notify)
205202
}
206203

207204
// Run runs command cmd with stdin

pkg/addons/addons.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ import (
4848
)
4949

5050
// Force is used to override checks for addons
51-
var Force bool = false
51+
var Force = false
5252

5353
// Refresh is used to refresh pods in specific cases when an addon is enabled
5454
// Currently only used for gcp-auth
55-
var Refresh bool = false
55+
var Refresh = false
5656

5757
// RunCallbacks runs all actions associated to an addon, but does not set it (thread-safe)
5858
func RunCallbacks(cc *config.ClusterConfig, name string, value string) error {
@@ -377,7 +377,7 @@ func Start(wg *sync.WaitGroup, cc *config.ClusterConfig, toEnable map[string]boo
377377

378378
var awg sync.WaitGroup
379379

380-
enabledAddons := []string{}
380+
var enabledAddons []string
381381

382382
defer func() { // making it show after verifications (see #7613)
383383
register.Reg.SetStep(register.EnablingAddons)

pkg/drivers/hyperkit/driver.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,7 @@ func (d *Driver) Start() error {
276276
return err
277277
}
278278

279-
if err := d.setupNFSMounts(); err != nil {
280-
return err
281-
}
282-
return nil
279+
return d.setupNFSMounts()
283280
}
284281

285282
func (d *Driver) setupIP(mac string) error {

pkg/drivers/none/none.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,7 @@ func (d *Driver) Remove() error {
192192

193193
// Restart a host
194194
func (d *Driver) Restart() error {
195-
if err := sysinit.New(d.exec).Restart("kubelet"); err != nil {
196-
return err
197-
}
198-
return nil
195+
return sysinit.New(d.exec).Restart("kubelet")
199196
}
200197

201198
// Start a host

pkg/drivers/ssh/ssh.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,7 @@ func (d *Driver) Stop() error {
206206

207207
// Restart a host
208208
func (d *Driver) Restart() error {
209-
if err := sysinit.New(d.exec).Restart("kubelet"); err != nil {
210-
return err
211-
}
212-
return nil
209+
return sysinit.New(d.exec).Restart("kubelet")
213210
}
214211

215212
// Kill stops a host forcefully, including any containers that we are managing.

pkg/minikube/config/profile.go

+2-9
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,7 @@ func SaveProfile(name string, cfg *ClusterConfig, miniHome ...string) error {
152152

153153
// If no config file exists, don't worry about swapping paths
154154
if _, err := os.Stat(path); os.IsNotExist(err) {
155-
if err := lock.WriteFile(path, data, 0600); err != nil {
156-
return err
157-
}
158-
return nil
155+
return lock.WriteFile(path, data, 0600)
159156
}
160157

161158
tf, err := ioutil.TempFile(filepath.Dir(path), "config.json.tmp")
@@ -176,11 +173,7 @@ func SaveProfile(name string, cfg *ClusterConfig, miniHome ...string) error {
176173
return err
177174
}
178175

179-
if err = os.Rename(tf.Name(), path); err != nil {
180-
return err
181-
}
182-
183-
return nil
176+
return os.Rename(tf.Name(), path)
184177
}
185178

186179
// DeleteProfile deletes a profile and removes the profile dir

pkg/minikube/download/download.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ import (
3535

3636
var (
3737
// DownloadMock is called instead of the download implementation if not nil.
38-
DownloadMock func(src, dst string) error = nil
39-
checkCache = os.Stat
38+
DownloadMock func(src, dst string) error
39+
checkCache = os.Stat
4040
)
4141

4242
// CreateDstDownloadMock is the default mock implementation of download.

pkg/minikube/download/preload.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const (
4949
)
5050

5151
var (
52-
preloadStates map[string]map[string]bool = make(map[string]map[string]bool)
52+
preloadStates = make(map[string]map[string]bool)
5353
)
5454

5555
// TarballName returns name of the tarball

pkg/minikube/driver/driver_darwin.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
)
2323

2424
// supportedDrivers is a list of supported drivers on Darwin.
25-
var supportedDrivers []string = func() []string {
25+
var supportedDrivers = func() []string {
2626
if runtime.GOARCH == "arm64" {
2727
// on darwin/arm64 only docker and ssh are supported yet
2828
return []string{

pkg/minikube/kubeconfig/context.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ func UnsetCurrentContext(machineName string, configPath ...string) error {
2828
if configPath != nil {
2929
fPath = configPath[0]
3030
}
31-
kCfg, err := readOrNew(fPath)
31+
cfg, err := readOrNew(fPath)
3232
if err != nil {
3333
return errors.Wrap(err, "Error getting kubeconfig status")
3434
}
3535

3636
// Unset current-context only if profile is the current-context
37-
if kCfg.CurrentContext == machineName {
38-
kCfg.CurrentContext = ""
39-
if err := writeToFile(kCfg, fPath); err != nil {
37+
if cfg.CurrentContext == machineName {
38+
cfg.CurrentContext = ""
39+
if err := writeToFile(cfg, fPath); err != nil {
4040
return errors.Wrap(err, "writing kubeconfig")
4141
}
4242
return nil

pkg/minikube/kubeconfig/extension.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,7 @@ func (in *Extension) DeepCopy() *Extension {
5555

5656
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
5757
func (in *Extension) DeepCopyObject() runtime.Object {
58-
if c := in.DeepCopy(); c != nil {
59-
return c
60-
}
61-
return nil
58+
return in.DeepCopy()
6259
}
6360

6461
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

pkg/minikube/node/start.go

+2-10
Original file line numberDiff line numberDiff line change
@@ -401,11 +401,7 @@ func waitForCRISocket(runner cruntime.CommandRunner, socket string, wait int, in
401401
}
402402
return nil
403403
}
404-
if err := retry.Expo(chkPath, time.Duration(interval)*time.Second, time.Duration(wait)*time.Second); err != nil {
405-
return err
406-
}
407-
408-
return nil
404+
return retry.Expo(chkPath, time.Duration(interval)*time.Second, time.Duration(wait)*time.Second)
409405
}
410406

411407
func waitForCRIVersion(runner cruntime.CommandRunner, socket string, wait int, interval int) error {
@@ -426,11 +422,7 @@ func waitForCRIVersion(runner cruntime.CommandRunner, socket string, wait int, i
426422
klog.Info(rr.Stdout.String())
427423
return nil
428424
}
429-
if err := retry.Expo(chkInfo, time.Duration(interval)*time.Second, time.Duration(wait)*time.Second); err != nil {
430-
return err
431-
}
432-
433-
return nil
425+
return retry.Expo(chkInfo, time.Duration(interval)*time.Second, time.Duration(wait)*time.Second)
434426
}
435427

436428
// setupKubeAdm adds any requested files into the VM before Kubernetes is started

pkg/minikube/shell/shell.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ REM @FOR /f "tokens=*" %%i IN ('%s') DO @%%i
139139
}
140140

141141
var defaultSh = "bash"
142-
var defaultShell shellData = shellConfigMap[defaultSh]
142+
var defaultShell = shellConfigMap[defaultSh]
143143

144144
var (
145145
// ForceShell forces a shell name

test/integration/functional_test_mount_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { // no
276276
t.Logf("reading mount text")
277277
mountText := func() string {
278278
str := ""
279-
var err error = nil
279+
var err error
280280
for err == nil {
281281
var add string
282282
add, err = ss.Stdout.ReadString(0)

0 commit comments

Comments
 (0)