Skip to content

Commit

Permalink
Merge pull request #39 from FrankYang0529/HARV-6160
Browse files Browse the repository at this point in the history
feat: upgrade go version to 1.22
  • Loading branch information
FrankYang0529 authored Jul 16, 2024
2 parents 0e6e08c + 3ce89d7 commit bee45cd
Show file tree
Hide file tree
Showing 21 changed files with 33 additions and 44 deletions.
4 changes: 2 additions & 2 deletions Dockerfile.dapper
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM registry.suse.com/bci/golang:1.20
FROM registry.suse.com/bci/golang:1.22

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

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

ENV DAPPER_ENV REPO TAG DRONE_TAG
ENV DAPPER_SOURCE /go/src/github.com/rancher/rancherd/
Expand Down
2 changes: 1 addition & 1 deletion cmd/rancherd/bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type Bootstrap struct {
//Config string `usage:"Custom config path" default:"/etc/rancher/rancherd/config.yaml" short:"c"`
}

func (b *Bootstrap) Run(cmd *cobra.Command, args []string) error {
func (b *Bootstrap) Run(cmd *cobra.Command, _ []string) error {
r := rancherd.New(rancherd.Config{
Force: b.Force,
DataDir: rancherd.DefaultDataDir,
Expand Down
2 changes: 1 addition & 1 deletion cmd/rancherd/gettoken/gettoken.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type GetToken struct {
Kubeconfig string `usage:"Kubeconfig file" env:"KUBECONFIG"`
}

func (p *GetToken) Run(cmd *cobra.Command, args []string) error {
func (p *GetToken) Run(cmd *cobra.Command, _ []string) error {
str, err := token.GetToken(cmd.Context(), p.Kubeconfig)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion cmd/rancherd/gettpmhash/gettpmhash.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func NewGetTPMHash() *cobra.Command {
type GetTPMHash struct {
}

func (p *GetTPMHash) Run(cmd *cobra.Command, args []string) error {
func (p *GetTPMHash) Run(*cobra.Command, []string) error {
str, err := tpm.GetPubHash()
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion cmd/rancherd/info/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func NewInfo() *cobra.Command {
type Info struct {
}

func (b *Info) Run(cmd *cobra.Command, args []string) error {
func (b *Info) Run(cmd *cobra.Command, _ []string) error {
r := rancherd.New(rancherd.Config{
DataDir: rancherd.DefaultDataDir,
ConfigPath: rancherd.DefaultConfigFile,
Expand Down
2 changes: 1 addition & 1 deletion cmd/rancherd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
type Rancherd struct {
}

func (a *Rancherd) Run(cmd *cobra.Command, args []string) error {
func (a *Rancherd) Run(cmd *cobra.Command, _ []string) error {
return cmd.Help()
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/rancherd/probe/probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type Probe struct {
File string `usage:"Plan file" default:"/var/lib/rancher/rancherd/plan/plan.json" short:"f"`
}

func (p *Probe) Run(cmd *cobra.Command, args []string) error {
func (p *Probe) Run(cmd *cobra.Command, _ []string) error {
interval, err := time.ParseDuration(p.Interval)
if err != nil {
return fmt.Errorf("parsing duration %s: %w", p.Interval, err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/rancherd/resetadmin/resetadmin.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type ResetAdmin struct {
Kubeconfig string `usage:"Kubeconfig file" env:"KUBECONFIG"`
}

func (p *ResetAdmin) Run(cmd *cobra.Command, args []string) error {
func (p *ResetAdmin) Run(cmd *cobra.Command, _ []string) error {
return auth.ResetAdmin(cmd.Context(), &auth.Options{
Password: p.Password,
PasswordFile: p.PasswordFile,
Expand Down
2 changes: 1 addition & 1 deletion cmd/rancherd/updateclientsecret/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ type UpdateClientSecret struct {
Kubeconfig string `usage:"Kubeconfig file" env:"KUBECONFIG"`
}

func (s *UpdateClientSecret) Run(cmd *cobra.Command, args []string) error {
func (s *UpdateClientSecret) Run(cmd *cobra.Command, _ []string) error {
return rancher.UpdateClientSecret(cmd.Context(), &rancher.Options{Kubeconfig: s.Kubeconfig})
}
2 changes: 1 addition & 1 deletion cmd/rancherd/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type Upgrade struct {
Force bool `usage:"Run without prompting for confirmation" short:"f"`
}

func (b *Upgrade) Run(cmd *cobra.Command, args []string) error {
func (b *Upgrade) Run(cmd *cobra.Command, _ []string) error {
r := rancherd.New(rancherd.Config{
Force: b.Force,
DataDir: rancherd.DefaultDataDir,
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/rancher/rancherd

go 1.20
go 1.22

replace (
k8s.io/api => k8s.io/api v0.24.10
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1476,6 +1476,7 @@ github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfn
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA=
github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
Expand Down Expand Up @@ -1644,6 +1645,7 @@ github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
github.com/onsi/ginkgo/v2 v2.0.0/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c=
github.com/onsi/ginkgo/v2 v2.1.4 h1:GNapqRSid3zijZ9H77KrgVG4/8KqiyRsxcSxe+7ApXY=
github.com/onsi/ginkgo/v2 v2.1.4/go.mod h1:um6tUpWM/cxCK3/FK8BXqEiUMUwRgSM4JXG47RKZmLU=
github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
Expand All @@ -1656,6 +1658,7 @@ github.com/onsi/gomega v1.11.0/go.mod h1:azGKhqFUon9Vuj0YmTfLSmx0FUwqXYSTl5re8lQ
github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs=
github.com/onsi/gomega v1.19.0 h1:4ieX6qQjPP/BfC3mpsAtIGGlxTWPeA3Inl/7DtXw1tw=
github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro=
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk=
github.com/opencontainers/go-digest v0.0.0-20180430190053-c9281466c8b2/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
Expand Down Expand Up @@ -1822,6 +1825,7 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
github.com/rs/cors v1.8.0/go.mod h1:EBwu+T5AvHOcXwvZIkQFjUN6s8Czyqw12GL/Y0tUyRM=
github.com/rubiojr/go-vhd v0.0.0-20200706105327-02e210299021/go.mod h1:DM5xW0nvfNNm2uytzsvhI3OnX8uzaRAg8UX/CnDqbto=
Expand Down Expand Up @@ -1922,6 +1926,7 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
github.com/tencentcloud/tencentcloud-sdk-go v3.0.83+incompatible h1:8uRvJleFpqLsO77WaAh2UrasMOzd8MxXrNj20e7El+Q=
Expand Down Expand Up @@ -2840,6 +2845,7 @@ google.golang.org/genproto v0.0.0-20230331144136-dcfb400f0633/go.mod h1:UUQDJDOl
google.golang.org/genproto v0.0.0-20230525234025-438c736192d0/go.mod h1:9ExIQyXL5hZrHzQceCwuSYwZZ5QZBazOcprJ5rgs3lY=
google.golang.org/genproto v0.0.0-20230526161137-0005af68ea54/go.mod h1:zqTuNwFlFRsw5zIts5VnzLQxSRqh+CGOTVMlYbY0Eyk=
google.golang.org/genproto v0.0.0-20231016165738-49dd2c1f3d0b h1:+YaDE2r2OG8t/z5qmsh7Y+XXwCbvadxxZ0YY6mTdrVA=
google.golang.org/genproto v0.0.0-20231016165738-49dd2c1f3d0b/go.mod h1:CgAqfJo+Xmu0GwA0411Ht3OU3OntXwsGmrmjI8ioGXI=
google.golang.org/genproto/googleapis/api v0.0.0-20230525234020-1aefcd67740a/go.mod h1:ts19tUU+Z0ZShN1y3aPyq2+O3d5FUNNgT6FtOzmrNn8=
google.golang.org/genproto/googleapis/api v0.0.0-20230525234035-dd9d682886f9/go.mod h1:vHYtlOoi6TsQ3Uk2yxR7NI5z8uoV+3pZtR4jmHIkRig=
google.golang.org/genproto/googleapis/api v0.0.0-20231012201019-e917dd12ba7a h1:myvhA4is3vrit1a6NZCWBIwN0kNEnX21DJOJX/NvIfI=
Expand Down
2 changes: 1 addition & 1 deletion pkg/discovery/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ func (j *joinServer) setPeers(peers []string) []string {
return j.peers
}

func (j *joinServer) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
func (j *joinServer) ServeHTTP(rw http.ResponseWriter, _ *http.Request) {
j.lock.Lock()
defer j.lock.Unlock()

Expand Down
2 changes: 1 addition & 1 deletion pkg/probe/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/sirupsen/logrus"
)

func RunProbes(ctx context.Context, planFile string, interval time.Duration) error {
func RunProbes(_ context.Context, planFile string, interval time.Duration) error {
f, err := os.Open(planFile)
if err != nil {
return fmt.Errorf("opening plan %s: %w", planFile, err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/rancher/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func ToInstruction(imageOverride, systemDefaultRegistry, k8sVersion, rancherVers
}, nil
}

func ToUpgradeInstruction(imageOverride, systemDefaultRegistry, k8sVersion, rancherVersion, dataDir string) (*applyinator.Instruction, error) {
func ToUpgradeInstruction(imageOverride, systemDefaultRegistry, k8sVersion, rancherVersion, _ string) (*applyinator.Instruction, error) {
return &applyinator.Instruction{
Name: "rancher",
SaveOutput: true,
Expand Down
18 changes: 9 additions & 9 deletions pkg/rancher/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/rancher/rancherd/pkg/self"
)

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

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

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

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

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

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

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

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

// Needs to patch status subresource
// k patch cluster.provisioning local -n fleet-local --subresource=status --type=merge --patch '{"status":{"fleetWorkspaceName": "fleet-local"}}'
func PatchLocalProvisioningClusterStatus(imageOverride, systemDefaultRegistry, k8sVersion string) (*applyinator.Instruction, error) {
func PatchLocalProvisioningClusterStatus(_, _, k8sVersion string) (*applyinator.Instruction, error) {
cmd, err := self.Self()
if err != nil {
return nil, fmt.Errorf("resolving location of %s: %w", os.Args[0], err)
Expand Down
3 changes: 1 addition & 2 deletions pkg/resources/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ func writeCattleID(id string) error {

func getCattleID() (string, error) {
data, err := ioutil.ReadFile("/etc/rancher/agent/cattle-id")
if os.IsNotExist(err) {
} else if err != nil {
if err != nil && !os.IsNotExist(err) {
return "", err
}
id := strings.TrimSpace(string(data))
Expand Down
2 changes: 1 addition & 1 deletion pkg/runtime/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/rancher/system-agent/pkg/applyinator"
)

func ToWaitKubernetesInstruction(imageOverride, systemDefaultRegistry, k8sVersion string) (*applyinator.Instruction, error) {
func ToWaitKubernetesInstruction(_, _, k8sVersion string) (*applyinator.Instruction, error) {
cmd, err := self.Self()
if err != nil {
return nil, fmt.Errorf("resolving location of %s: %w", os.Args[0], err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/versions/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var (
cachedRancherVersion = map[string]string{}
cachedLock sync.Mutex
redirectClient = &http.Client{
CheckRedirect: func(req *http.Request, via []*http.Request) error {
CheckRedirect: func(*http.Request, []*http.Request) error {
return http.ErrUseLastResponse
},
}
Expand Down
1 change: 0 additions & 1 deletion scripts/ci
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ cd $(dirname $0)
./build
./test
./validate
./validate-ci
./package
15 changes: 0 additions & 15 deletions scripts/validate-ci

This file was deleted.

0 comments on commit bee45cd

Please sign in to comment.