Skip to content

Commit bee45cd

Browse files
Merge pull request #39 from FrankYang0529/HARV-6160
feat: upgrade go version to 1.22
2 parents 0e6e08c + 3ce89d7 commit bee45cd

File tree

21 files changed

+33
-44
lines changed

21 files changed

+33
-44
lines changed

Dockerfile.dapper

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
FROM registry.suse.com/bci/golang:1.20
1+
FROM registry.suse.com/bci/golang:1.22
22

33
RUN zypper in -y bash git gcc docker vim less file curl wget ca-certificates trousers-devel
44

5-
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.51.1
5+
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.58.2
66

77
ENV DAPPER_ENV REPO TAG DRONE_TAG
88
ENV DAPPER_SOURCE /go/src/github.com/rancher/rancherd/

cmd/rancherd/bootstrap/bootstrap.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type Bootstrap struct {
1818
//Config string `usage:"Custom config path" default:"/etc/rancher/rancherd/config.yaml" short:"c"`
1919
}
2020

21-
func (b *Bootstrap) Run(cmd *cobra.Command, args []string) error {
21+
func (b *Bootstrap) Run(cmd *cobra.Command, _ []string) error {
2222
r := rancherd.New(rancherd.Config{
2323
Force: b.Force,
2424
DataDir: rancherd.DefaultDataDir,

cmd/rancherd/gettoken/gettoken.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type GetToken struct {
1818
Kubeconfig string `usage:"Kubeconfig file" env:"KUBECONFIG"`
1919
}
2020

21-
func (p *GetToken) Run(cmd *cobra.Command, args []string) error {
21+
func (p *GetToken) Run(cmd *cobra.Command, _ []string) error {
2222
str, err := token.GetToken(cmd.Context(), p.Kubeconfig)
2323
if err != nil {
2424
return err

cmd/rancherd/gettpmhash/gettpmhash.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func NewGetTPMHash() *cobra.Command {
1818
type GetTPMHash struct {
1919
}
2020

21-
func (p *GetTPMHash) Run(cmd *cobra.Command, args []string) error {
21+
func (p *GetTPMHash) Run(*cobra.Command, []string) error {
2222
str, err := tpm.GetPubHash()
2323
if err != nil {
2424
return err

cmd/rancherd/info/info.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func NewInfo() *cobra.Command {
1515
type Info struct {
1616
}
1717

18-
func (b *Info) Run(cmd *cobra.Command, args []string) error {
18+
func (b *Info) Run(cmd *cobra.Command, _ []string) error {
1919
r := rancherd.New(rancherd.Config{
2020
DataDir: rancherd.DefaultDataDir,
2121
ConfigPath: rancherd.DefaultConfigFile,

cmd/rancherd/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
type Rancherd struct {
1919
}
2020

21-
func (a *Rancherd) Run(cmd *cobra.Command, args []string) error {
21+
func (a *Rancherd) Run(cmd *cobra.Command, _ []string) error {
2222
return cmd.Help()
2323
}
2424

cmd/rancherd/probe/probe.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type Probe struct {
2121
File string `usage:"Plan file" default:"/var/lib/rancher/rancherd/plan/plan.json" short:"f"`
2222
}
2323

24-
func (p *Probe) Run(cmd *cobra.Command, args []string) error {
24+
func (p *Probe) Run(cmd *cobra.Command, _ []string) error {
2525
interval, err := time.ParseDuration(p.Interval)
2626
if err != nil {
2727
return fmt.Errorf("parsing duration %s: %w", p.Interval, err)

cmd/rancherd/resetadmin/resetadmin.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type ResetAdmin struct {
1818
Kubeconfig string `usage:"Kubeconfig file" env:"KUBECONFIG"`
1919
}
2020

21-
func (p *ResetAdmin) Run(cmd *cobra.Command, args []string) error {
21+
func (p *ResetAdmin) Run(cmd *cobra.Command, _ []string) error {
2222
return auth.ResetAdmin(cmd.Context(), &auth.Options{
2323
Password: p.Password,
2424
PasswordFile: p.PasswordFile,

cmd/rancherd/updateclientsecret/update.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ type UpdateClientSecret struct {
1717
Kubeconfig string `usage:"Kubeconfig file" env:"KUBECONFIG"`
1818
}
1919

20-
func (s *UpdateClientSecret) Run(cmd *cobra.Command, args []string) error {
20+
func (s *UpdateClientSecret) Run(cmd *cobra.Command, _ []string) error {
2121
return rancher.UpdateClientSecret(cmd.Context(), &rancher.Options{Kubeconfig: s.Kubeconfig})
2222
}

cmd/rancherd/upgrade/upgrade.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type Upgrade struct {
1919
Force bool `usage:"Run without prompting for confirmation" short:"f"`
2020
}
2121

22-
func (b *Upgrade) Run(cmd *cobra.Command, args []string) error {
22+
func (b *Upgrade) Run(cmd *cobra.Command, _ []string) error {
2323
r := rancherd.New(rancherd.Config{
2424
Force: b.Force,
2525
DataDir: rancherd.DefaultDataDir,

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/rancher/rancherd
22

3-
go 1.20
3+
go 1.22
44

55
replace (
66
k8s.io/api => k8s.io/api v0.24.10

go.sum

+6
Original file line numberDiff line numberDiff line change
@@ -1476,6 +1476,7 @@ github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfn
14761476
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
14771477
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
14781478
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
1479+
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
14791480
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
14801481
github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA=
14811482
github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
@@ -1644,6 +1645,7 @@ github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
16441645
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
16451646
github.com/onsi/ginkgo/v2 v2.0.0/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c=
16461647
github.com/onsi/ginkgo/v2 v2.1.4 h1:GNapqRSid3zijZ9H77KrgVG4/8KqiyRsxcSxe+7ApXY=
1648+
github.com/onsi/ginkgo/v2 v2.1.4/go.mod h1:um6tUpWM/cxCK3/FK8BXqEiUMUwRgSM4JXG47RKZmLU=
16471649
github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
16481650
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
16491651
github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
@@ -1656,6 +1658,7 @@ github.com/onsi/gomega v1.11.0/go.mod h1:azGKhqFUon9Vuj0YmTfLSmx0FUwqXYSTl5re8lQ
16561658
github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
16571659
github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs=
16581660
github.com/onsi/gomega v1.19.0 h1:4ieX6qQjPP/BfC3mpsAtIGGlxTWPeA3Inl/7DtXw1tw=
1661+
github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro=
16591662
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk=
16601663
github.com/opencontainers/go-digest v0.0.0-20180430190053-c9281466c8b2/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
16611664
github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
@@ -1822,6 +1825,7 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
18221825
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
18231826
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
18241827
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
1828+
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
18251829
github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
18261830
github.com/rs/cors v1.8.0/go.mod h1:EBwu+T5AvHOcXwvZIkQFjUN6s8Czyqw12GL/Y0tUyRM=
18271831
github.com/rubiojr/go-vhd v0.0.0-20200706105327-02e210299021/go.mod h1:DM5xW0nvfNNm2uytzsvhI3OnX8uzaRAg8UX/CnDqbto=
@@ -1922,6 +1926,7 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
19221926
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
19231927
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
19241928
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
1929+
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
19251930
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
19261931
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
19271932
github.com/tencentcloud/tencentcloud-sdk-go v3.0.83+incompatible h1:8uRvJleFpqLsO77WaAh2UrasMOzd8MxXrNj20e7El+Q=
@@ -2840,6 +2845,7 @@ google.golang.org/genproto v0.0.0-20230331144136-dcfb400f0633/go.mod h1:UUQDJDOl
28402845
google.golang.org/genproto v0.0.0-20230525234025-438c736192d0/go.mod h1:9ExIQyXL5hZrHzQceCwuSYwZZ5QZBazOcprJ5rgs3lY=
28412846
google.golang.org/genproto v0.0.0-20230526161137-0005af68ea54/go.mod h1:zqTuNwFlFRsw5zIts5VnzLQxSRqh+CGOTVMlYbY0Eyk=
28422847
google.golang.org/genproto v0.0.0-20231016165738-49dd2c1f3d0b h1:+YaDE2r2OG8t/z5qmsh7Y+XXwCbvadxxZ0YY6mTdrVA=
2848+
google.golang.org/genproto v0.0.0-20231016165738-49dd2c1f3d0b/go.mod h1:CgAqfJo+Xmu0GwA0411Ht3OU3OntXwsGmrmjI8ioGXI=
28432849
google.golang.org/genproto/googleapis/api v0.0.0-20230525234020-1aefcd67740a/go.mod h1:ts19tUU+Z0ZShN1y3aPyq2+O3d5FUNNgT6FtOzmrNn8=
28442850
google.golang.org/genproto/googleapis/api v0.0.0-20230525234035-dd9d682886f9/go.mod h1:vHYtlOoi6TsQ3Uk2yxR7NI5z8uoV+3pZtR4jmHIkRig=
28452851
google.golang.org/genproto/googleapis/api v0.0.0-20231012201019-e917dd12ba7a h1:myvhA4is3vrit1a6NZCWBIwN0kNEnX21DJOJX/NvIfI=

pkg/discovery/discovery.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ func (j *joinServer) setPeers(peers []string) []string {
311311
return j.peers
312312
}
313313

314-
func (j *joinServer) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
314+
func (j *joinServer) ServeHTTP(rw http.ResponseWriter, _ *http.Request) {
315315
j.lock.Lock()
316316
defer j.lock.Unlock()
317317

pkg/probe/run.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"github.com/sirupsen/logrus"
1313
)
1414

15-
func RunProbes(ctx context.Context, planFile string, interval time.Duration) error {
15+
func RunProbes(_ context.Context, planFile string, interval time.Duration) error {
1616
f, err := os.Open(planFile)
1717
if err != nil {
1818
return fmt.Errorf("opening plan %s: %w", planFile, err)

pkg/rancher/run.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func ToInstruction(imageOverride, systemDefaultRegistry, k8sVersion, rancherVers
5353
}, nil
5454
}
5555

56-
func ToUpgradeInstruction(imageOverride, systemDefaultRegistry, k8sVersion, rancherVersion, dataDir string) (*applyinator.Instruction, error) {
56+
func ToUpgradeInstruction(imageOverride, systemDefaultRegistry, k8sVersion, rancherVersion, _ string) (*applyinator.Instruction, error) {
5757
return &applyinator.Instruction{
5858
Name: "rancher",
5959
SaveOutput: true,

pkg/rancher/wait.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/rancher/rancherd/pkg/self"
1111
)
1212

13-
func ToWaitRancherInstruction(imageOverride, systemDefaultRegistry, k8sVersion string) (*applyinator.Instruction, error) {
13+
func ToWaitRancherInstruction(_, _, k8sVersion string) (*applyinator.Instruction, error) {
1414
cmd, err := self.Self()
1515
if err != nil {
1616
return nil, fmt.Errorf("resolving location of %s: %w", os.Args[0], err)
@@ -24,7 +24,7 @@ func ToWaitRancherInstruction(imageOverride, systemDefaultRegistry, k8sVersion s
2424
}, nil
2525
}
2626

27-
func ToWaitRancherWebhookInstruction(imageOverride, systemDefaultRegistry, k8sVersion string) (*applyinator.Instruction, error) {
27+
func ToWaitRancherWebhookInstruction(_, _, k8sVersion string) (*applyinator.Instruction, error) {
2828
cmd, err := self.Self()
2929
if err != nil {
3030
return nil, fmt.Errorf("resolving location of %s: %w", os.Args[0], err)
@@ -38,7 +38,7 @@ func ToWaitRancherWebhookInstruction(imageOverride, systemDefaultRegistry, k8sVe
3838
}, nil
3939
}
4040

41-
func ToWaitSUCInstruction(imageOverride, systemDefaultRegistry, k8sVersion string) (*applyinator.Instruction, error) {
41+
func ToWaitSUCInstruction(_, _, k8sVersion string) (*applyinator.Instruction, error) {
4242
cmd, err := self.Self()
4343
if err != nil {
4444
return nil, fmt.Errorf("resolving location of %s: %w", os.Args[0], err)
@@ -52,7 +52,7 @@ func ToWaitSUCInstruction(imageOverride, systemDefaultRegistry, k8sVersion strin
5252
}, nil
5353
}
5454

55-
func ToWaitSUCPlanInstruction(imageOverride, systemDefaultRegistry, k8sVersion string) (*applyinator.Instruction, error) {
55+
func ToWaitSUCPlanInstruction(_, _, k8sVersion string) (*applyinator.Instruction, error) {
5656
cmd, err := self.Self()
5757
if err != nil {
5858
return nil, fmt.Errorf("resolving location of %s: %w", os.Args[0], err)
@@ -67,7 +67,7 @@ func ToWaitSUCPlanInstruction(imageOverride, systemDefaultRegistry, k8sVersion s
6767
}, nil
6868
}
6969

70-
func ToWaitClusterClientSecretInstruction(imageOverride, systemDefaultRegistry, k8sVersion string) (*applyinator.Instruction, error) {
70+
func ToWaitClusterClientSecretInstruction(_, _, k8sVersion string) (*applyinator.Instruction, error) {
7171
cmd, err := self.Self()
7272
if err != nil {
7373
return nil, fmt.Errorf("resolving location of %s: %w", os.Args[0], err)
@@ -82,7 +82,7 @@ func ToWaitClusterClientSecretInstruction(imageOverride, systemDefaultRegistry,
8282
}, nil
8383
}
8484

85-
func ToUpdateClientSecretInstruction(imageOverride, systemDefaultRegistry, k8sVersion string) (*applyinator.Instruction, error) {
85+
func ToUpdateClientSecretInstruction(_, _, k8sVersion string) (*applyinator.Instruction, error) {
8686
cmd, err := self.Self()
8787
if err != nil {
8888
return nil, fmt.Errorf("resolving location of %s: %w", os.Args[0], err)
@@ -96,7 +96,7 @@ func ToUpdateClientSecretInstruction(imageOverride, systemDefaultRegistry, k8sVe
9696
}, nil
9797
}
9898

99-
func ToScaleDownFleetControllerInstruction(imageOverride, systemDefaultRegistry, k8sVersion string) (*applyinator.Instruction, error) {
99+
func ToScaleDownFleetControllerInstruction(_, _, k8sVersion string) (*applyinator.Instruction, error) {
100100
cmd, err := self.Self()
101101
if err != nil {
102102
return nil, fmt.Errorf("resolving location of %s: %w", os.Args[0], err)
@@ -110,7 +110,7 @@ func ToScaleDownFleetControllerInstruction(imageOverride, systemDefaultRegistry,
110110
}, nil
111111
}
112112

113-
func ToScaleUpFleetControllerInstruction(imageOverride, systemDefaultRegistry, k8sVersion string) (*applyinator.Instruction, error) {
113+
func ToScaleUpFleetControllerInstruction(_, _, k8sVersion string) (*applyinator.Instruction, error) {
114114
cmd, err := self.Self()
115115
if err != nil {
116116
return nil, fmt.Errorf("resolving location of %s: %w", os.Args[0], err)
@@ -126,7 +126,7 @@ func ToScaleUpFleetControllerInstruction(imageOverride, systemDefaultRegistry, k
126126

127127
// Needs to patch status subresource
128128
// k patch cluster.provisioning local -n fleet-local --subresource=status --type=merge --patch '{"status":{"fleetWorkspaceName": "fleet-local"}}'
129-
func PatchLocalProvisioningClusterStatus(imageOverride, systemDefaultRegistry, k8sVersion string) (*applyinator.Instruction, error) {
129+
func PatchLocalProvisioningClusterStatus(_, _, k8sVersion string) (*applyinator.Instruction, error) {
130130
cmd, err := self.Self()
131131
if err != nil {
132132
return nil, fmt.Errorf("resolving location of %s: %w", os.Args[0], err)

pkg/resources/resources.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ func writeCattleID(id string) error {
3737

3838
func getCattleID() (string, error) {
3939
data, err := ioutil.ReadFile("/etc/rancher/agent/cattle-id")
40-
if os.IsNotExist(err) {
41-
} else if err != nil {
40+
if err != nil && !os.IsNotExist(err) {
4241
return "", err
4342
}
4443
id := strings.TrimSpace(string(data))

pkg/runtime/wait.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/rancher/system-agent/pkg/applyinator"
1010
)
1111

12-
func ToWaitKubernetesInstruction(imageOverride, systemDefaultRegistry, k8sVersion string) (*applyinator.Instruction, error) {
12+
func ToWaitKubernetesInstruction(_, _, k8sVersion string) (*applyinator.Instruction, error) {
1313
cmd, err := self.Self()
1414
if err != nil {
1515
return nil, fmt.Errorf("resolving location of %s: %w", os.Args[0], err)

pkg/versions/versions.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var (
1717
cachedRancherVersion = map[string]string{}
1818
cachedLock sync.Mutex
1919
redirectClient = &http.Client{
20-
CheckRedirect: func(req *http.Request, via []*http.Request) error {
20+
CheckRedirect: func(*http.Request, []*http.Request) error {
2121
return http.ErrUseLastResponse
2222
},
2323
}

scripts/ci

-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@ cd $(dirname $0)
66
./build
77
./test
88
./validate
9-
./validate-ci
109
./package

scripts/validate-ci

-15
This file was deleted.

0 commit comments

Comments
 (0)