Skip to content

Commit be99484

Browse files
orangedengJacieChao
authored andcommitted
fix(autok3s): Upgrade golang builder to v1.20.8
Also upgraded golangci-lint version to adapt v1.20+ golang And use revive linter instead of golint And lint fixes
1 parent dacf25f commit be99484

File tree

34 files changed

+94
-99
lines changed

34 files changed

+94
-99
lines changed

.golangci.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"disable-all": true,
44
"enable": [
55
"govet",
6-
"golint",
6+
"revive",
77
"goimports",
88
"misspell",
99
"ineffassign",

Dockerfile.dapper

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1-
FROM registry.suse.com/bci/golang:1.19
1+
# FROM registry.suse.com/bci/golang:1.20
2+
FROM registry.suse.com/bci/bci-base:latest
23
ARG PROXY
34
ARG GOPROXY
4-
RUN zypper -n install netcat wget curl gawk
5+
ARG ARCH=amd64
6+
ARG GO_VERSION=1.20.8
7+
RUN curl -sSL https://go.dev/dl/go${GO_VERSION}.linux-${ARCH}.tar.gz -o /tmp/go.tar.gz \
8+
&& rm -rf /usr/local/go && tar -C /usr/local -xzf /tmp/go.tar.gz \
9+
&& /usr/local/go/bin/go version
10+
ENV GOPATH=/go PATH=/go/bin:/usr/local/go/bin:/root/go/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
11+
RUN zypper -n install netcat wget curl gawk git make
512
RUN zypper install -y -f docker
613
## install golangci-lint
714
RUN if [ "$(go env GOARCH)" = "amd64" ]; then \
815
export HTTPS_PROXY=${PROXY}; \
9-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.50.1; \
16+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.54.2; \
1017
golangci-lint --version; \
1118
fi
1219
## install mockgen

cmd/airgap/import.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ var (
1919
if err := cobra.MaximumNArgs(2)(cmd, args); err != nil {
2020
return err
2121
}
22-
if err := cobra.MinimumNArgs(1)(cmd, args); err != nil {
23-
return err
24-
}
25-
return nil
22+
23+
return cobra.MinimumNArgs(1)(cmd, args)
2624
},
2725
RunE: importFunc,
2826
}

cmd/airgap/ls.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ func init() {
2424
listCmd.Flags().BoolVarP(&airgapFlags.isJSON, "json", "j", airgapFlags.isJSON, "json output")
2525
}
2626

27-
func list(cmd *cobra.Command, args []string) error {
27+
func list(cmd *cobra.Command, _ []string) error {
2828
pkgs, err := common.DefaultDB.ListPackages(nil)
2929
if err != nil {
30-
return errors.Wrap(err, "failed to list airgap packages.")
30+
return errors.Wrap(err, "failed to list airgap packages")
3131
}
3232
if airgapFlags.isJSON {
3333
data, err := json.Marshal(pkgs)

cmd/airgap/update_script.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var (
1717
}
1818
)
1919

20-
func updateInstallScript(cmd *cobra.Command, args []string) error {
20+
func updateInstallScript(cmd *cobra.Command, _ []string) error {
2121
buff := bytes.NewBuffer([]byte{})
2222
if err := settings.GetScriptFromSource(buff); err != nil {
2323
return err

cmd/sshkey/export.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func init() {
2626
exportCmd.Flags().StringVarP(&sshKeyFlags.OutputPath, "output", "o", ".", "The path to write key pair files, will write to id_rsa, id_rsa.pub and pub.cert under the output path")
2727
}
2828

29-
func validateFiles(cmd *cobra.Command, args []string) error {
29+
func validateFiles(_ *cobra.Command, args []string) error {
3030
if err := pathExists(sshKeyFlags.OutputPath); err != nil {
3131
return err
3232
}
@@ -51,11 +51,8 @@ func validateFiles(cmd *cobra.Command, args []string) error {
5151
}
5252
toValidate = append(toValidate, filename)
5353
}
54-
if err := pathsNotExists(sshKeyFlags.OutputPath, toValidate...); err != nil {
55-
return err
56-
}
5754

58-
return nil
55+
return pathsNotExists(sshKeyFlags.OutputPath, toValidate...)
5956
}
6057

6158
func export(cmd *cobra.Command, args []string) error {

go.mod

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
module github.com/cnrancher/autok3s
22

3-
go 1.19
3+
go 1.20
4+
5+
replace (
6+
go4.org/unsafe/assume-no-moving-gc => go4.org/unsafe/assume-no-moving-gc v0.0.0-20230525183740-e7c30c78aeb2
7+
inet.af/netaddr => inet.af/netaddr v0.0.0-20230525184311-b8eac61e914a
8+
)
49

510
require (
611
github.com/AlecAivazis/survey/v2 v2.3.5
@@ -170,7 +175,7 @@ require (
170175
go.opencensus.io v0.24.0 // indirect
171176
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
172177
go4.org/intern v0.0.0-20211027215823-ae77deb06f29 // indirect
173-
go4.org/unsafe/assume-no-moving-gc v0.0.0-20220617031537-928513b29760 // indirect
178+
go4.org/unsafe/assume-no-moving-gc v0.0.0-20230525183740-e7c30c78aeb2 // indirect
174179
golang.org/x/sys v0.5.0 // indirect
175180
golang.org/x/text v0.7.0 // indirect
176181
golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9 // indirect

go.sum

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,9 +1107,8 @@ go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/
11071107
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
11081108
go4.org/intern v0.0.0-20211027215823-ae77deb06f29 h1:UXLjNohABv4S58tHmeuIZDO6e3mHpW2Dx33gaNt03LE=
11091109
go4.org/intern v0.0.0-20211027215823-ae77deb06f29/go.mod h1:cS2ma+47FKrLPdXFpr7CuxiTW3eyJbWew4qx0qtQWDA=
1110-
go4.org/unsafe/assume-no-moving-gc v0.0.0-20211027215541-db492cf91b37/go.mod h1:FftLjUGFEDu5k8lt0ddY+HcrH/qU/0qk+H8j9/nTl3E=
1111-
go4.org/unsafe/assume-no-moving-gc v0.0.0-20220617031537-928513b29760 h1:FyBZqvoA/jbNzuAWLQE2kG820zMAkcilx6BMjGbL/E4=
1112-
go4.org/unsafe/assume-no-moving-gc v0.0.0-20220617031537-928513b29760/go.mod h1:FftLjUGFEDu5k8lt0ddY+HcrH/qU/0qk+H8j9/nTl3E=
1110+
go4.org/unsafe/assume-no-moving-gc v0.0.0-20230525183740-e7c30c78aeb2 h1:WJhcL4p+YeDxmZWg141nRm7XC8IDmhz7lk5GpadO1Sg=
1111+
go4.org/unsafe/assume-no-moving-gc v0.0.0-20230525183740-e7c30c78aeb2/go.mod h1:FftLjUGFEDu5k8lt0ddY+HcrH/qU/0qk+H8j9/nTl3E=
11131112
golang.org/x/crypto v0.0.0-20171113213409-9f005a07e0d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
11141113
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
11151114
golang.org/x/crypto v0.0.0-20181009213950-7c1a557ab941/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
@@ -1639,8 +1638,8 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
16391638
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
16401639
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
16411640
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
1642-
inet.af/netaddr v0.0.0-20220811202034-502d2d690317 h1:U2fwK6P2EqmopP/hFLTOAjWTki0qgd4GMJn5X8wOleU=
1643-
inet.af/netaddr v0.0.0-20220811202034-502d2d690317/go.mod h1:OIezDfdzOgFhuw4HuWapWq2e9l0H9tK4F1j+ETRtF3k=
1641+
inet.af/netaddr v0.0.0-20230525184311-b8eac61e914a h1:1XCVEdxrvL6c0TGOhecLuB7U9zYNdxZEjvOqJreKZiM=
1642+
inet.af/netaddr v0.0.0-20230525184311-b8eac61e914a/go.mod h1:e83i32mAQOW1LAqEIweALsuK2Uw4mhQadA5r7b0Wobo=
16441643
k8s.io/api v0.18.0/go.mod h1:q2HRQkfDzHMBZL9l/y9rH63PkQl4vae0xRT+8prbrK8=
16451644
k8s.io/api v0.20.1/go.mod h1:KqwcCVogGxQY3nBlRpwt+wpAMF/KjaCc7RpywacvqUo=
16461645
k8s.io/api v0.20.4/go.mod h1:++lNL1AJMkDymriNniQsWRkMDzRaX2Y/POTUi8yvqYQ=

hack/lib/lint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function autok3s::lint::lint() {
3434

3535
if autok3s::lint::validate; then
3636
for path in "$@"; do
37-
golangci-lint run "${path}"
37+
golangci-lint -v run "${path}"
3838
done
3939
else
4040
autok3s::log::warn "no golangci-lint available, using go fmt/vet instead"

pkg/airgap/download.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ func (d *downloader) validateVersion() error {
249249
downloadURL := fmt.Sprintf("%s/%s", sourceURL, imageListFilename)
250250
resp, err := doRequestWithCtx(d.ctx, http.MethodGet, downloadURL, nil)
251251
if err != nil {
252-
return errors.Wrapf(err, "failed to download image list of k3s version %s, this version may be not validated.", d.pkg.K3sVersion)
252+
return errors.Wrapf(err, "failed to download image list of k3s version %s, this version may be not validated", d.pkg.K3sVersion)
253253
}
254254
defer resp.Body.Close()
255255
if resp.StatusCode < 200 || resp.StatusCode >= 300 {

0 commit comments

Comments
 (0)