Skip to content

Commit

Permalink
upgrade golangci-lint for go 1.18 support
Browse files Browse the repository at this point in the history
With versions lower than 1.45.0, golangci-lint returns a lot of invalid
errors when running in Go 1.18+.

This commit upgrades golangci-lint to the latest released version and fixes
all linting errors that came up.
  • Loading branch information
apricote committed Mar 25, 2022
1 parent 66a2cde commit cae44b1
Show file tree
Hide file tree
Showing 8 changed files with 233 additions and 113 deletions.
1 change: 0 additions & 1 deletion api/v1alpha3/openstackcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const (

// OpenStackClusterSpec defines the desired state of OpenStackCluster.
type OpenStackClusterSpec struct {

// The name of the secret containing the openstack credentials
// +optional
// +k8s:conversion-gen=false
Expand Down
1 change: 0 additions & 1 deletion api/v1alpha3/openstackmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ type OpenStackMachineSpec struct {

// OpenStackMachineStatus defines the observed state of OpenStackMachine.
type OpenStackMachineStatus struct {

// Ready is true when the provider resource is ready.
// +optional
Ready bool `json:"ready"`
Expand Down
1 change: 0 additions & 1 deletion api/v1alpha4/openstackmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ type OpenStackMachineSpec struct {

// OpenStackMachineStatus defines the observed state of OpenStackMachine.
type OpenStackMachineStatus struct {

// Ready is true when the provider resource is ready.
// +optional
Ready bool `json:"ready"`
Expand Down
1 change: 0 additions & 1 deletion api/v1beta1/openstackmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ type OpenStackMachineSpec struct {

// OpenStackMachineStatus defines the observed state of OpenStackMachine.
type OpenStackMachineStatus struct {

// Ready is true when the provider resource is ready.
// +optional
Ready bool `json:"ready"`
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ require (
github.com/prometheus/client_golang v1.11.0
github.com/spf13/pflag v1.0.5
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5
golang.org/x/text v0.3.7
gopkg.in/ini.v1 v1.63.2
k8s.io/api v0.23.0
k8s.io/apimachinery v0.23.0
Expand Down Expand Up @@ -97,7 +98,6 @@ require (
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
golang.org/x/sys v0.0.0-20211029165221-6e7872819dc8 // indirect
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
Expand Down
2 changes: 1 addition & 1 deletion hack/tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.16
require (
github.com/a8m/envsubst v1.2.0
github.com/golang/mock v1.6.0
github.com/golangci/golangci-lint v1.43.0
github.com/golangci/golangci-lint v1.45.2
github.com/itchyny/gojq v0.12.2
github.com/onsi/ginkgo v1.16.4
k8s.io/code-generator v0.22.2
Expand Down
327 changes: 225 additions & 102 deletions hack/tools/go.sum

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions pkg/record/recorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ limitations under the License.
package record

import (
"strings"
"sync"

"golang.org/x/text/cases"
"golang.org/x/text/language"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/tools/record"
Expand All @@ -45,20 +46,20 @@ func InitFromRecorder(recorder record.EventRecorder) {

// Event constructs an event from the given information and puts it in the queue for sending.
func Event(object runtime.Object, reason, message string) {
defaultRecorder.Event(object, corev1.EventTypeNormal, strings.Title(reason), message)
defaultRecorder.Event(object, corev1.EventTypeNormal, cases.Title(language.English).String(reason), message)
}

// Eventf is just like Event, but with Sprintf for the message field.
func Eventf(object runtime.Object, reason, message string, args ...interface{}) {
defaultRecorder.Eventf(object, corev1.EventTypeNormal, strings.Title(reason), message, args...)
defaultRecorder.Eventf(object, corev1.EventTypeNormal, cases.Title(language.English).String(reason), message, args...)
}

// Warn constructs a warning event from the given information and puts it in the queue for sending.
func Warn(object runtime.Object, reason, message string) {
defaultRecorder.Event(object, corev1.EventTypeWarning, strings.Title(reason), message)
defaultRecorder.Event(object, corev1.EventTypeWarning, cases.Title(language.English).String(reason), message)
}

// Warnf is just like Warn, but with Sprintf for the message field.
func Warnf(object runtime.Object, reason, message string, args ...interface{}) {
defaultRecorder.Eventf(object, corev1.EventTypeWarning, strings.Title(reason), message, args...)
defaultRecorder.Eventf(object, corev1.EventTypeWarning, cases.Title(language.English).String(reason), message, args...)
}

0 comments on commit cae44b1

Please sign in to comment.