Skip to content

Commit 3029c4a

Browse files
authored
Merge pull request #852 from negz/y-u-do-this-golangci
Bump to Go v1.24, and golangci-lint v2.2.0
2 parents 0d81d3f + 678177c commit 3029c4a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+988
-314
lines changed

.golangci.yml

Lines changed: 165 additions & 216 deletions
Large diffs are not rendered by default.

Earthfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ VERSION --try --raw-output 0.8
33

44
PROJECT crossplane/crossplane-runtime
55

6-
ARG --global GO_VERSION=1.23.7
6+
ARG --global GO_VERSION=1.24.4
77

88
# reviewable checks that a branch is ready for review. Run it before opening a
99
# pull request. It will catch a lot of the things our CI workflow will catch.
@@ -102,7 +102,7 @@ go-test:
102102

103103
# go-lint lints Go code.
104104
go-lint:
105-
ARG GOLANGCI_LINT_VERSION=v1.64.8
105+
ARG GOLANGCI_LINT_VERSION=v2.2.1
106106
FROM +go-modules
107107
# This cache is private because golangci-lint doesn't support concurrent runs.
108108
CACHE --id go-lint --sharing private /root/.cache/golangci-lint

apis/common/v1/condition.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const (
6868
// See https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties
6969

7070
// A Condition that may apply to a resource.
71-
type Condition struct {
71+
type Condition struct { //nolint:recvcheck // False positive - only has non-pointer methods AFAICT.
7272
// Type of this condition. At most one of each condition type may apply to
7373
// a resource at any point in time.
7474
Type ConditionType `json:"type"`
@@ -126,6 +126,7 @@ func IsSystemConditionType(t ConditionType) bool {
126126
case TypeReady, TypeSynced, TypeHealthy:
127127
return true
128128
}
129+
129130
return false
130131
}
131132

@@ -150,6 +151,7 @@ type ConditionedStatus struct {
150151
func NewConditionedStatus(c ...Condition) *ConditionedStatus {
151152
s := &ConditionedStatus{}
152153
s.SetConditions(c...)
154+
153155
return s
154156
}
155157

@@ -171,6 +173,7 @@ func (s *ConditionedStatus) GetCondition(ct ConditionType) Condition {
171173
func (s *ConditionedStatus) SetConditions(c ...Condition) {
172174
for _, cond := range c {
173175
exists := false
176+
174177
for i, existing := range s.Conditions {
175178
if existing.Type != cond.Type {
176179
continue
@@ -184,6 +187,7 @@ func (s *ConditionedStatus) SetConditions(c ...Condition) {
184187
s.Conditions[i] = cond
185188
exists = true
186189
}
190+
187191
if !exists {
188192
s.Conditions = append(s.Conditions, cond)
189193
}

apis/common/v1/connection_details.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ func (in *ConnectionSecretMetadata) SetOwnerUID(uid types.UID) {
7272
if in.Labels == nil {
7373
in.Labels = map[string]string{}
7474
}
75+
7576
in.Labels[LabelKeyOwnerUID] = string(uid)
7677
}
7778

@@ -80,6 +81,7 @@ func (in *ConnectionSecretMetadata) GetOwnerUID() string {
8081
if u, ok := in.Labels[LabelKeyOwnerUID]; ok {
8182
return u
8283
}
84+
8385
return ""
8486
}
8587

@@ -145,13 +147,13 @@ type Config struct {
145147
// KubernetesAuthConfig required to authenticate to a K8s API. It expects
146148
// a "kubeconfig" file to be provided.
147149
type KubernetesAuthConfig struct {
148-
// Source of the credentials.
149-
// +kubebuilder:validation:Enum=None;Secret;Environment;Filesystem
150-
Source CredentialsSource `json:"source"`
151-
152150
// CommonCredentialSelectors provides common selectors for extracting
153151
// credentials.
154152
CommonCredentialSelectors `json:",inline"`
153+
154+
// Source of the credentials.
155+
// +kubebuilder:validation:Enum=None;Secret;Environment;Filesystem
156+
Source CredentialsSource `json:"source"`
155157
}
156158

157159
// KubernetesSecretStoreConfig represents the required configuration

apis/common/v1/merge.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ func (mo *MergeOptions) MergoConfiguration() []func(*mergo.Config) {
4040
if mo.KeepMapValues != nil && *mo.KeepMapValues {
4141
config = config[:0]
4242
}
43+
4344
if mo.AppendSlice != nil && *mo.AppendSlice {
4445
config = append(config, mergo.WithAppendSlice)
4546
}
47+
4648
return config
4749
}
4850

apis/common/v1/merge_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,15 @@ func (arr mergoOptArr) names() []string {
3333
for i, opt := range arr {
3434
names[i] = runtime.FuncForPC(reflect.ValueOf(opt).Pointer()).Name()
3535
}
36+
3637
sort.Strings(names)
38+
3739
return names
3840
}
3941

4042
func TestMergoConfiguration(t *testing.T) {
4143
valTrue := true
44+
4245
tests := map[string]struct {
4346
mo *MergeOptions
4447
want mergoOptArr

apis/common/v1/resource.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ func (p *Policy) IsResolutionPolicyOptional() bool {
101101
if p == nil || p.Resolution == nil {
102102
return false
103103
}
104+
104105
return *p.Resolution == ResolutionPolicyOptional
105106
}
106107

@@ -109,6 +110,7 @@ func (p *Policy) IsResolvePolicyAlways() bool {
109110
if p == nil || p.Resolve == nil {
110111
return false
111112
}
113+
112114
return *p.Resolve == ResolvePolicyAlways
113115
}
114116

go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
module github.com/crossplane/crossplane-runtime
22

3-
go 1.23.0
4-
5-
toolchain go1.23.7
3+
go 1.24.0
64

75
require (
86
dario.cat/mergo v1.0.1

pkg/certificates/certificates.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,14 @@ const (
3636
func LoadMTLSConfig(caPath, certPath, keyPath string, isServer bool) (*tls.Config, error) {
3737
tlsCertFilePath := filepath.Clean(certPath)
3838
tlsKeyFilePath := filepath.Clean(keyPath)
39+
3940
certificate, err := tls.LoadX509KeyPair(tlsCertFilePath, tlsKeyFilePath)
4041
if err != nil {
4142
return nil, errors.Wrap(err, errLoadCert)
4243
}
4344

4445
caCertFilePath := filepath.Clean(caPath)
46+
4547
ca, err := os.ReadFile(caCertFilePath)
4648
if err != nil {
4749
return nil, errors.Wrap(err, errLoadCA)

pkg/certificates/certificates_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ func TestLoad(t *testing.T) {
2727
certsFolderPath string
2828
requireClientValidation bool
2929
}
30+
3031
type want struct {
3132
err error
3233
out *tls.Config
3334
}
35+
3436
cases := map[string]struct {
3537
reason string
3638
args
@@ -92,16 +94,16 @@ func TestLoad(t *testing.T) {
9294
}
9395
for name, tc := range cases {
9496
t.Run(name, func(t *testing.T) {
95-
certsFolderPath := tc.args.certsFolderPath
96-
requireClient := tc.args.requireClientValidation
97+
certsFolderPath := tc.certsFolderPath
98+
requireClient := tc.requireClientValidation
9799

98100
cfg, err := LoadMTLSConfig(filepath.Join(certsFolderPath, caCertFileName), filepath.Join(certsFolderPath, tlsCertFileName), filepath.Join(certsFolderPath, tlsKeyFileName), requireClient)
99-
if diff := cmp.Diff(tc.want.err, err, test.EquateErrors()); diff != "" {
101+
if diff := cmp.Diff(tc.err, err, test.EquateErrors()); diff != "" {
100102
t.Errorf("\n%s\nLoad(...): -want error, +got error:\n%s", tc.reason, diff)
101103
}
102104

103105
if requireClient {
104-
if diff := cmp.Diff(tc.want.out.ClientAuth, cfg.ClientAuth); diff != "" {
106+
if diff := cmp.Diff(tc.out.ClientAuth, cfg.ClientAuth); diff != "" {
105107
t.Errorf("\n%s\nLoad(...): -want, +got:\n%s", tc.reason, diff)
106108
}
107109
}

0 commit comments

Comments
 (0)