Skip to content

Commit f3ad32b

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents db0643a + cf0fed0 commit f3ad32b

File tree

235 files changed

+5824
-4356
lines changed

Some content is hidden

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

235 files changed

+5824
-4356
lines changed

.github/workflows/pr-golangci-lint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
with:
2727
go-version: ${{ steps.vars.outputs.go_version }}
2828
- name: golangci-lint
29-
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # tag=v8.0.0
29+
uses: golangci/golangci-lint-action@0a35821d5c230e903fcfe077583637dea1b27b47 # tag=v9.0.0
3030
with:
3131
version: v2.1.0
3232
working-directory: ${{matrix.working-directory}}

.golangci.yml

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,6 @@ linters:
139139
alias: runtimeserializer
140140
- pkg: k8s.io/apimachinery/pkg/runtime/serializer/yaml
141141
alias: yamlserializer
142-
- pkg: sigs.k8s.io/cluster-api/api/v1beta1
143-
alias: clusterv1
144142
- pkg: sigs.k8s.io/cluster-api/util/defaulting
145143
alias: utildefaulting
146144
- pkg: sigs.k8s.io/controller-runtime
@@ -169,8 +167,14 @@ linters:
169167
alias: crclient
170168
- pkg: k8s.io/apimachinery/pkg/types
171169
alias: apimachinerytypes
172-
- pkg: sigs.k8s.io/cluster-api/exp/api/v1beta1
173-
alias: expclusterv1
170+
- pkg: "sigs.k8s.io/cluster-api/api/core/v1beta2"
171+
alias: clusterv1
172+
- pkg: "sigs.k8s.io/cluster-api/api/core/v1beta1"
173+
alias: clusterv1beta1
174+
- pkg: "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/patch"
175+
alias: v1beta1patch
176+
- pkg: "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions"
177+
alias: v1beta1conditions
174178
no-unaliased: false
175179
nolintlint:
176180
require-specific: true
@@ -212,16 +216,16 @@ linters:
212216
# - errcheck
213217
# text: Error return value of `outputPrinter.Print` is not checked
214218
- linters:
215-
- gosec
216-
text: 'G103: Use of unsafe calls should be audited'
219+
- gosec
220+
text: "G103: Use of unsafe calls should be audited"
217221
path: .*(api|types|test)\/.*\/.*conversion.*\.go$
218222
- linters:
219223
- staticcheck
220-
text: 'QF1008: could remove embedded field .*'
224+
text: "QF1008: could remove embedded field .*"
221225
# TODO: change to use time.Time.Equal
222226
- linters:
223227
- staticcheck
224-
text: 'QF1009: probably want to use time.Time.Equal instead'
228+
text: "QF1009: probably want to use time.Time.Equal instead"
225229
- linters:
226230
- revive
227231
# Ignoring stylistic checks for generated code
@@ -233,13 +237,13 @@ linters:
233237
# Ignoring stylistic checks for generated code
234238
path: .*(api|types)\/.*\/.*conversion.*\.go$
235239
# By convention, receiver names in a method should reflect their identity.
236-
text: 'receiver-naming: receiver name (.+) should be consistent with previous receiver name (.+)'
240+
text: "receiver-naming: receiver name (.+) should be consistent with previous receiver name (.+)"
237241
- linters:
238242
- revive
239243
# Ignoring stylistic checks for generated code
240244
path: .*(api|types|test)\/.*\/.*conversion.*\.go$
241245
# Checking if an error is nil to just after return the error or nil is redundant
242-
text: 'if-return: redundant if ...; err != nil check, just return error instead'
246+
text: "if-return: redundant if ...; err != nil check, just return error instead"
243247
- linters:
244248
- revive
245249
text: 'exported: exported method .*\.(Reconcile|SetupWithManager|SetupWebhookWithManager) should have comment or be unexported'
@@ -268,7 +272,7 @@ linters:
268272
text: Error return value of (.+) is not checked
269273
- linters:
270274
- gosec
271-
text: 'G108: Profiling endpoint is automatically exposed on /debug/pprof'
275+
text: "G108: Profiling endpoint is automatically exposed on /debug/pprof"
272276
- linters:
273277
- godot
274278
path: (.*)/(v1beta1|v1beta2)/(.*)types.go
@@ -282,17 +286,17 @@ linters:
282286
- linters:
283287
- revive
284288
path: .*/defaults.go
285-
text: 'var-naming: don''t use underscores in Go names; func (.+) should be (.+)'
289+
text: "var-naming: don't use underscores in Go names; func (.+) should be (.+)"
286290
- linters:
287291
- revive
288292
path: .*/.*(mock|gc_).*/.+\.go
289-
text: 'var-naming: don''t use an underscore in package name'
293+
text: "var-naming: don't use an underscore in package name"
290294
- linters:
291295
- revive
292296
# Ignoring stylistic checks for generated code
293297
path: .*(api|types|test)\/.*\/.*conversion.*\.go$
294298
# This rule warns when initialism, variable or package naming conventions are not followed.
295-
text: 'var-naming: don''t use underscores in Go names'
299+
text: "var-naming: don't use underscores in Go names"
296300
- linters:
297301
- unparam
298302
text: always receives
@@ -309,20 +313,23 @@ linters:
309313
text: cyclomatic complexity
310314
- linters:
311315
- gocritic
312-
text: 'appendAssign: append result not assigned to the same slice'
316+
text: "appendAssign: append result not assigned to the same slice"
313317
- path: (.+)\.go$
314318
text: (Expect directory permissions to be 0750 or less|Expect file permissions to be 0600 or less)
315319
- path: (.+)\.go$
316-
text: 'exported: (func|type) name will be used as (.+) by other packages, and that stutters; consider calling this (.+)'
320+
text: "exported: (func|type) name will be used as (.+) by other packages, and that stutters; consider calling this (.+)"
317321
- path: (.+)\.go$
318322
text: (G104|G107|G404|G505|ST1000)
319323
- path: (.+)\.go$
320-
text: 'G108: Profiling endpoint is automatically exposed on /debug/pprof'
324+
text: "G108: Profiling endpoint is automatically exposed on /debug/pprof"
321325
- path: (.+)\.go$
322326
text: net/http.Get must not be called
323327
- linters:
324328
- goconst
325329
path: (.+)_test\.go
330+
- linters:
331+
- staticcheck
332+
text: 'SA1019: "sigs.k8s.io/cluster-api/(.*)" is deprecated: This package is deprecated and is going to be removed when support for v1beta1 will be dropped.'
326333
paths:
327334
- third_party$
328335
- builtin$

Makefile

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ include $(ROOT_DIR_RELATIVE)/common.mk
2121

2222
# Go
2323
GO_VERSION ?=1.24.7
24+
GO_DIRECTIVE_VERSION ?= 1.24.0
2425
GO_CONTAINER_IMAGE ?= golang:$(GO_VERSION)
2526

2627
# Directories.
@@ -204,7 +205,7 @@ endif
204205
.PHONY: defaulters
205206
defaulters: $(DEFAULTER_GEN) ## Generate all Go types
206207
$(DEFAULTER_GEN) \
207-
--extra-peer-dirs=sigs.k8s.io/cluster-api/api/v1beta1 \
208+
--extra-peer-dirs=sigs.k8s.io/cluster-api/api/core/v1beta2 \
208209
--v=0 \
209210
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt \
210211
--output-file=zz_generated.defaults.go \
@@ -262,36 +263,36 @@ generate-go-apis: ## Alias for .build/generate-go-apis
262263
$(MAKE) defaulters
263264

264265
$(CONVERSION_GEN) \
265-
--extra-peer-dirs=sigs.k8s.io/cluster-api/api/v1beta1 \
266+
--extra-peer-dirs=sigs.k8s.io/cluster-api/api/core/v1beta2 \
266267
--output-file=zz_generated.conversion.go \
267268
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt \
268269
./api/v1beta1 \
269270
./cmd/clusterawsadm/api/bootstrap/v1alpha1
270271

271272
$(CONVERSION_GEN) \
272273
--extra-peer-dirs=sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta1 \
273-
--extra-peer-dirs=sigs.k8s.io/cluster-api/api/v1beta1 \
274+
--extra-peer-dirs=sigs.k8s.io/cluster-api/api/core/v1beta2 \
274275
--output-file=zz_generated.conversion.go \
275276
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt \
276277
./$(EXP_DIR)/api/v1beta1
277278

278279
$(CONVERSION_GEN) \
279280
--extra-peer-dirs=sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta1 \
280-
--extra-peer-dirs=sigs.k8s.io/cluster-api/api/v1beta1 \
281+
--extra-peer-dirs=sigs.k8s.io/cluster-api/api/core/v1beta2 \
281282
--output-file=zz_generated.conversion.go \
282283
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt \
283284
./bootstrap/eks/api/v1beta1
284285

285286
$(CONVERSION_GEN) \
286287
--extra-peer-dirs=sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta1 \
287-
--extra-peer-dirs=sigs.k8s.io/cluster-api/api/v1beta1 \
288+
--extra-peer-dirs=sigs.k8s.io/cluster-api/api/core/v1beta2 \
288289
--output-file=zz_generated.conversion.go \
289290
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt \
290291
./controlplane/eks/api/v1beta1
291292

292293
$(CONVERSION_GEN) \
293294
--extra-peer-dirs=sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta1 \
294-
--extra-peer-dirs=sigs.k8s.io/cluster-api/api/v1beta1 \
295+
--extra-peer-dirs=sigs.k8s.io/cluster-api/api/core/v1beta2 \
295296
--output-file=zz_generated.conversion.go \
296297
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt \
297298
./controlplane/rosa/api/v1beta2
@@ -329,7 +330,7 @@ modules: ## Runs go mod to ensure proper vendoring.
329330
cd $(TOOLS_DIR); go mod tidy
330331

331332
.PHONY: verify ## Verify ties together the rest of the verification targets into one target
332-
verify: verify-boilerplate verify-modules verify-gen verify-conversions verify-shellcheck verify-book-links release-manifests
333+
verify: verify-boilerplate verify-modules verify-gen verify-conversions verify-shellcheck verify-book-links release-manifests verify-go-directive
333334

334335
.PHONY: verify-boilerplate
335336
verify-boilerplate: ## Verify boilerplate
@@ -367,6 +368,12 @@ verify-gen: generate ## Verify generated files
367368
verify-container-images: ## Verify container images
368369
TRACE=$(TRACE) ./hack/verify-container-images.sh
369370

371+
.PHONY: verify-go-directive
372+
verify-go-directive:
373+
# use the core Cluster API script directly to verify the go directive matches the desired one.
374+
# ref: https://github.com/kubernetes-sigs/cluster-api/blob/v1.10.7/hack/verify-go-directive.sh
375+
curl --retry 3 -fsL https://raw.githubusercontent.com/kubernetes-sigs/cluster-api/refs/tags/v1.10.7/hack/verify-go-directive.sh | bash -s -- -g $(GO_DIRECTIVE_VERSION)
376+
370377
.PHONY: apidiff
371378
apidiff: APIDIFF_OLD_COMMIT ?= $(shell git rev-parse origin/main)
372379
apidiff: $(GO_APIDIFF) ## Check for API differences

api/v1beta1/awscluster_conversion.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ func (src *AWSCluster) ConvertTo(dstRaw conversion.Hub) error {
6767
dst.Status.Bastion.HostID = restored.Status.Bastion.HostID
6868
dst.Status.Bastion.CapacityReservationPreference = restored.Status.Bastion.CapacityReservationPreference
6969
dst.Status.Bastion.CPUOptions = restored.Status.Bastion.CPUOptions
70+
if restored.Status.Bastion.DynamicHostAllocation != nil {
71+
dst.Status.Bastion.DynamicHostAllocation = restored.Status.Bastion.DynamicHostAllocation
72+
}
7073
}
7174
dst.Spec.Partition = restored.Spec.Partition
7275

api/v1beta1/awscluster_types.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package v1beta1
1919
import (
2020
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2121

22-
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
22+
clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
2323
)
2424

2525
const (
@@ -45,7 +45,7 @@ type AWSClusterSpec struct {
4545

4646
// ControlPlaneEndpoint represents the endpoint used to communicate with the control plane.
4747
// +optional
48-
ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint"`
48+
ControlPlaneEndpoint clusterv1beta1.APIEndpoint `json:"controlPlaneEndpoint"`
4949

5050
// AdditionalTags is an optional set of tags to add to AWS resources managed by the AWS provider, in addition to the
5151
// ones added by default.
@@ -200,11 +200,11 @@ type AWSLoadBalancerSpec struct {
200200
// AWSClusterStatus defines the observed state of AWSCluster.
201201
type AWSClusterStatus struct {
202202
// +kubebuilder:default=false
203-
Ready bool `json:"ready"`
204-
Network NetworkStatus `json:"networkStatus,omitempty"`
205-
FailureDomains clusterv1.FailureDomains `json:"failureDomains,omitempty"`
206-
Bastion *Instance `json:"bastion,omitempty"`
207-
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
203+
Ready bool `json:"ready"`
204+
Network NetworkStatus `json:"networkStatus,omitempty"`
205+
FailureDomains clusterv1beta1.FailureDomains `json:"failureDomains,omitempty"`
206+
Bastion *Instance `json:"bastion,omitempty"`
207+
Conditions clusterv1beta1.Conditions `json:"conditions,omitempty"`
208208
}
209209

210210
// S3Bucket defines a supporting S3 bucket for the cluster, currently can be optionally used for Ignition.
@@ -254,12 +254,12 @@ type AWSClusterList struct {
254254
}
255255

256256
// GetConditions returns the observations of the operational state of the AWSCluster resource.
257-
func (r *AWSCluster) GetConditions() clusterv1.Conditions {
257+
func (r *AWSCluster) GetConditions() clusterv1beta1.Conditions {
258258
return r.Status.Conditions
259259
}
260260

261-
// SetConditions sets the underlying service state of the AWSCluster to the predescribed clusterv1.Conditions.
262-
func (r *AWSCluster) SetConditions(conditions clusterv1.Conditions) {
261+
// SetConditions sets the underlying service state of the AWSCluster to the predescribed clusterv1beta1.Conditions.
262+
func (r *AWSCluster) SetConditions(conditions clusterv1beta1.Conditions) {
263263
r.Status.Conditions = conditions
264264
}
265265

api/v1beta1/awsclustertemplate_types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package v1beta1
1919
import (
2020
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2121

22-
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
22+
clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
2323
)
2424

2525
// AWSClusterTemplateSpec defines the desired state of AWSClusterTemplate.
@@ -58,6 +58,6 @@ type AWSClusterTemplateResource struct {
5858
// Standard object's metadata.
5959
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
6060
// +optional
61-
ObjectMeta clusterv1.ObjectMeta `json:"metadata,omitempty"`
62-
Spec AWSClusterSpec `json:"spec"`
61+
ObjectMeta clusterv1beta1.ObjectMeta `json:"metadata,omitempty"`
62+
Spec AWSClusterSpec `json:"spec"`
6363
}

api/v1beta1/awsmachine_conversion.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ func (src *AWSMachine) ConvertTo(dstRaw conversion.Hub) error {
4949
dst.Spec.CapacityReservationPreference = restored.Spec.CapacityReservationPreference
5050
dst.Spec.NetworkInterfaceType = restored.Spec.NetworkInterfaceType
5151
dst.Spec.CPUOptions = restored.Spec.CPUOptions
52+
if restored.Spec.DynamicHostAllocation != nil {
53+
dst.Spec.DynamicHostAllocation = restored.Spec.DynamicHostAllocation
54+
}
5255
if restored.Spec.ElasticIPPool != nil {
5356
if dst.Spec.ElasticIPPool == nil {
5457
dst.Spec.ElasticIPPool = &infrav1.ElasticIPPool{}
@@ -61,6 +64,7 @@ func (src *AWSMachine) ConvertTo(dstRaw conversion.Hub) error {
6164
}
6265
}
6366

67+
dst.Status.DedicatedHost = restored.Status.DedicatedHost
6468
return nil
6569
}
6670

@@ -117,6 +121,9 @@ func (r *AWSMachineTemplate) ConvertTo(dstRaw conversion.Hub) error {
117121
dst.Spec.Template.Spec.CapacityReservationPreference = restored.Spec.Template.Spec.CapacityReservationPreference
118122
dst.Spec.Template.Spec.NetworkInterfaceType = restored.Spec.Template.Spec.NetworkInterfaceType
119123
dst.Spec.Template.Spec.CPUOptions = restored.Spec.Template.Spec.CPUOptions
124+
if restored.Spec.Template.Spec.DynamicHostAllocation != nil {
125+
dst.Spec.Template.Spec.DynamicHostAllocation = restored.Spec.Template.Spec.DynamicHostAllocation
126+
}
120127
if restored.Spec.Template.Spec.ElasticIPPool != nil {
121128
if dst.Spec.Template.Spec.ElasticIPPool == nil {
122129
dst.Spec.Template.Spec.ElasticIPPool = &infrav1.ElasticIPPool{}
@@ -129,6 +136,10 @@ func (r *AWSMachineTemplate) ConvertTo(dstRaw conversion.Hub) error {
129136
}
130137
}
131138

139+
// Restore Status fields that don't exist in v1beta1.
140+
dst.Status.NodeInfo = restored.Status.NodeInfo
141+
dst.Status.Conditions = restored.Status.Conditions
142+
132143
return nil
133144
}
134145

api/v1beta1/awsmachine_types.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package v1beta1
1919
import (
2020
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2121

22-
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
22+
clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
2323
)
2424

2525
const (
@@ -207,7 +207,7 @@ type AWSMachineStatus struct {
207207
Interruptible bool `json:"interruptible,omitempty"`
208208

209209
// Addresses contains the AWS instance associated addresses.
210-
Addresses []clusterv1.MachineAddress `json:"addresses,omitempty"`
210+
Addresses []clusterv1beta1.MachineAddress `json:"addresses,omitempty"`
211211

212212
// InstanceState is the state of the AWS instance for this machine.
213213
// +optional
@@ -253,7 +253,7 @@ type AWSMachineStatus struct {
253253

254254
// Conditions defines current service state of the AWSMachine.
255255
// +optional
256-
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
256+
Conditions clusterv1beta1.Conditions `json:"conditions,omitempty"`
257257
}
258258

259259
// +kubebuilder:object:root=true
@@ -276,12 +276,12 @@ type AWSMachine struct {
276276
}
277277

278278
// GetConditions returns the observations of the operational state of the AWSMachine resource.
279-
func (r *AWSMachine) GetConditions() clusterv1.Conditions {
279+
func (r *AWSMachine) GetConditions() clusterv1beta1.Conditions {
280280
return r.Status.Conditions
281281
}
282282

283-
// SetConditions sets the underlying service state of the AWSMachine to the predescribed clusterv1.Conditions.
284-
func (r *AWSMachine) SetConditions(conditions clusterv1.Conditions) {
283+
// SetConditions sets the underlying service state of the AWSMachine to the predescribed clusterv1beta1.Conditions.
284+
func (r *AWSMachine) SetConditions(conditions clusterv1beta1.Conditions) {
285285
r.Status.Conditions = conditions
286286
}
287287

api/v1beta1/awsmachinetemplate_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
corev1 "k8s.io/api/core/v1"
2121
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2222

23-
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
23+
clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
2424
)
2525

2626
// AWSMachineTemplateStatus defines a status for an AWSMachineTemplate.
@@ -65,7 +65,7 @@ type AWSMachineTemplateResource struct {
6565
// Standard object's metadata.
6666
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
6767
// +optional
68-
ObjectMeta clusterv1.ObjectMeta `json:"metadata,omitempty"`
68+
ObjectMeta clusterv1beta1.ObjectMeta `json:"metadata,omitempty"`
6969

7070
// Spec is the specification of the desired behavior of the machine.
7171
Spec AWSMachineSpec `json:"spec"`

0 commit comments

Comments
 (0)