Skip to content

Commit f524e1a

Browse files
committed
chore: bump CAPI to v1.5.0
This change bumps CAPI to v1.5.0 and also controller runtime. Signed-off-by: Richard Case <[email protected]>
1 parent db41de4 commit f524e1a

27 files changed

+308
-321
lines changed

.github/workflows/lint.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
name: Lint
2-
on: [ pull_request ]
2+
on: [pull_request]
3+
4+
permissions:
5+
contents: read
36

47
jobs:
58
golangci:
69
name: lint
710
runs-on: ubuntu-latest
811
steps:
912
- uses: actions/checkout@v3
10-
- uses: actions/setup-go@v3
13+
- uses: actions/setup-go@v4
1114
with:
12-
go-version: 1.19
15+
go-version: "1.20"
1316
check-latest: true
17+
cache: false
1418
- name: golangci-lint
15-
uses: golangci/golangci-lint-action@v3.2.0
19+
uses: golangci/golangci-lint-action@v3
1620
with:
17-
version: v1.50.1
21+
version: "v1.53"

.golangci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ linters-settings:
5959
go: "1.18"
6060
stylecheck:
6161
go: "1.18"
62+
depguard:
63+
rules:
64+
main:
65+
deny:
66+
- pkg: "io/ioutil"
67+
desc: "ioutil is deprecated starting with Go 1.16"
68+
6269

6370
issues:
6471
max-same-issues: 0

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
# Build the manager binary
16-
FROM golang:1.19.10@sha256:83f9f840072d05ad4d90ce4ac7cb2427632d6b89d5ffc558f18f9577ec8188c0 as builder
16+
FROM golang:1.20.6@sha256:b6c53162b13ec2ac1c725078671dbff289d9e723c045c27d73eacf0a50893598 as builder
1717
WORKDIR /workspace
1818

1919
# Run this with docker build --build_arg $(go env GOPROXY) to override the goproxy

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ ENVSUBST_VER := v1.4.2
7171
ENVSUBST_BIN := envsubst
7272
ENVSUBST := $(TOOLS_BIN_DIR)/$(ENVSUBST_BIN)
7373

74-
GOLANGCI_LINT_VER := v1.52.1
74+
GOLANGCI_LINT_VER := v1.53.3
7575
GOLANGCI_LINT_BIN := golangci-lint
7676
GOLANGCI_LINT := $(TOOLS_BIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER)
7777

@@ -140,7 +140,7 @@ endif
140140
# Build time versioning details.
141141
LDFLAGS := $(shell hack/version.sh)
142142

143-
GOLANG_VERSION := 1.19.10
143+
GOLANG_VERSION := 1.20.6
144144

145145
# CI
146146
CAPG_WORKER_CLUSTER_KUBECONFIG ?= "/tmp/kubeconfig"
@@ -473,7 +473,7 @@ create-management-cluster: $(KUSTOMIZE) $(ENVSUBST) $(KIND) $(KUBECTL)
473473
./hack/install-cert-manager.sh
474474

475475
# Deploy CAPI
476-
curl --retry $(CURL_RETRIES) -sSL https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.4.4/cluster-api-components.yaml | $(ENVSUBST) | $(KUBECTL) apply -f -
476+
curl --retry $(CURL_RETRIES) -sSL https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.5.0/cluster-api-components.yaml | $(ENVSUBST) | $(KUBECTL) apply -f -
477477

478478
# Deploy CAPG
479479
$(KIND) load docker-image $(CONTROLLER_IMG)-$(ARCH):$(TAG) --name=clusterapi

Tiltfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ settings = {
1818
"deploy_cert_manager": True,
1919
"preload_images_for_kind": True,
2020
"kind_cluster_name": "capg",
21-
"capi_version": "v1.4.4",
21+
"capi_version": "v1.5.0",
2222
"cert_manager_version": "v1.11.0",
2323
"kubernetes_version": "v1.26.1",
2424
}

api/v1beta1/gcpcluster_webhook.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
ctrl "sigs.k8s.io/controller-runtime"
2626
logf "sigs.k8s.io/controller-runtime/pkg/log"
2727
"sigs.k8s.io/controller-runtime/pkg/webhook"
28+
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
2829
)
2930

3031
// clusterlog is for logging in this package.
@@ -49,14 +50,14 @@ func (c *GCPCluster) Default() {
4950
}
5051

5152
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
52-
func (c *GCPCluster) ValidateCreate() error {
53+
func (c *GCPCluster) ValidateCreate() (admission.Warnings, error) {
5354
clusterlog.Info("validate create", "name", c.Name)
5455

55-
return nil
56+
return nil, nil
5657
}
5758

5859
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
59-
func (c *GCPCluster) ValidateUpdate(oldRaw runtime.Object) error {
60+
func (c *GCPCluster) ValidateUpdate(oldRaw runtime.Object) (admission.Warnings, error) {
6061
clusterlog.Info("validate update", "name", c.Name)
6162
var allErrs field.ErrorList
6263
old := oldRaw.(*GCPCluster)
@@ -83,15 +84,15 @@ func (c *GCPCluster) ValidateUpdate(oldRaw runtime.Object) error {
8384
}
8485

8586
if len(allErrs) == 0 {
86-
return nil
87+
return nil, nil
8788
}
8889

89-
return apierrors.NewInvalid(GroupVersion.WithKind("GCPCluster").GroupKind(), c.Name, allErrs)
90+
return nil, apierrors.NewInvalid(GroupVersion.WithKind("GCPCluster").GroupKind(), c.Name, allErrs)
9091
}
9192

9293
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
93-
func (c *GCPCluster) ValidateDelete() error {
94+
func (c *GCPCluster) ValidateDelete() (admission.Warnings, error) {
9495
clusterlog.Info("validate delete", "name", c.Name)
9596

96-
return nil
97+
return nil, nil
9798
}

api/v1beta1/gcpclustertemplate_webhook.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
ctrl "sigs.k8s.io/controller-runtime"
2626
logf "sigs.k8s.io/controller-runtime/pkg/log"
2727
"sigs.k8s.io/controller-runtime/pkg/webhook"
28+
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
2829
)
2930

3031
// log is for logging in this package.
@@ -49,27 +50,27 @@ func (r *GCPClusterTemplate) Default() {
4950
var _ webhook.Validator = &GCPClusterTemplate{}
5051

5152
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
52-
func (r *GCPClusterTemplate) ValidateCreate() error {
53+
func (r *GCPClusterTemplate) ValidateCreate() (admission.Warnings, error) {
5354
gcpclustertemplatelog.Info("validate create", "name", r.Name)
5455

55-
return nil
56+
return nil, nil
5657
}
5758

5859
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
59-
func (r *GCPClusterTemplate) ValidateUpdate(oldRaw runtime.Object) error {
60+
func (r *GCPClusterTemplate) ValidateUpdate(oldRaw runtime.Object) (admission.Warnings, error) {
6061
old, ok := oldRaw.(*GCPClusterTemplate)
6162
if !ok {
62-
return apierrors.NewBadRequest(fmt.Sprintf("expected an GCPClusterTemplate but got a %T", oldRaw))
63+
return nil, apierrors.NewBadRequest(fmt.Sprintf("expected an GCPClusterTemplate but got a %T", oldRaw))
6364
}
6465

6566
if !reflect.DeepEqual(r.Spec, old.Spec) {
66-
return apierrors.NewBadRequest("GCPClusterTemplate.Spec is immutable")
67+
return nil, apierrors.NewBadRequest("GCPClusterTemplate.Spec is immutable")
6768
}
68-
return nil
69+
return nil, nil
6970
}
7071

7172
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
72-
func (r *GCPClusterTemplate) ValidateDelete() error {
73+
func (r *GCPClusterTemplate) ValidateDelete() (admission.Warnings, error) {
7374
gcpclustertemplatelog.Info("validate delete", "name", r.Name)
74-
return nil
75+
return nil, nil
7576
}

api/v1beta1/gcpclustertemplate_webhook_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,13 @@ func TestGCPClusterTemplate_ValidateUpdate(t *testing.T) {
8080
test := test
8181
t.Run(test.name, func(t *testing.T) {
8282
t.Parallel()
83-
err := test.newTemplate.ValidateUpdate(test.oldTemplate)
83+
warn, err := test.newTemplate.ValidateUpdate(test.oldTemplate)
8484
if test.wantErr {
8585
g.Expect(err).To(HaveOccurred())
8686
} else {
8787
g.Expect(err).NotTo(HaveOccurred())
8888
}
89+
g.Expect(warn).To(BeNil())
8990
})
9091
}
9192
}

api/v1beta1/gcpmachine_webhook.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
ctrl "sigs.k8s.io/controller-runtime"
3131
logf "sigs.k8s.io/controller-runtime/pkg/log"
3232
"sigs.k8s.io/controller-runtime/pkg/webhook"
33+
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
3334
)
3435

3536
// log is for logging in this package.
@@ -47,22 +48,22 @@ func (m *GCPMachine) SetupWebhookWithManager(mgr ctrl.Manager) error {
4748
var _ webhook.Validator = &GCPMachine{}
4849

4950
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
50-
func (m *GCPMachine) ValidateCreate() error {
51+
func (m *GCPMachine) ValidateCreate() (admission.Warnings, error) {
5152
clusterlog.Info("validate create", "name", m.Name)
52-
return validateConfidentialCompute(m.Spec)
53+
return nil, validateConfidentialCompute(m.Spec)
5354
}
5455

5556
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
56-
func (m *GCPMachine) ValidateUpdate(old runtime.Object) error {
57+
func (m *GCPMachine) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
5758
newGCPMachine, err := runtime.DefaultUnstructuredConverter.ToUnstructured(m)
5859
if err != nil {
59-
return apierrors.NewInvalid(GroupVersion.WithKind("GCPMachine").GroupKind(), m.Name, field.ErrorList{
60+
return nil, apierrors.NewInvalid(GroupVersion.WithKind("GCPMachine").GroupKind(), m.Name, field.ErrorList{
6061
field.InternalError(nil, errors.Wrap(err, "failed to convert new GCPMachine to unstructured object")),
6162
})
6263
}
6364
oldGCPMachine, err := runtime.DefaultUnstructuredConverter.ToUnstructured(old)
6465
if err != nil {
65-
return apierrors.NewInvalid(GroupVersion.WithKind("GCPMachine").GroupKind(), m.Name, field.ErrorList{
66+
return nil, apierrors.NewInvalid(GroupVersion.WithKind("GCPMachine").GroupKind(), m.Name, field.ErrorList{
6667
field.InternalError(nil, errors.Wrap(err, "failed to convert old GCPMachine to unstructured object")),
6768
})
6869
}
@@ -83,19 +84,19 @@ func (m *GCPMachine) ValidateUpdate(old runtime.Object) error {
8384
delete(newGCPMachineSpec, "additionalNetworkTags")
8485

8586
if !reflect.DeepEqual(oldGCPMachineSpec, newGCPMachineSpec) {
86-
return apierrors.NewInvalid(GroupVersion.WithKind("GCPMachine").GroupKind(), m.Name, field.ErrorList{
87+
return nil, apierrors.NewInvalid(GroupVersion.WithKind("GCPMachine").GroupKind(), m.Name, field.ErrorList{
8788
field.Forbidden(field.NewPath("spec"), "cannot be modified"),
8889
})
8990
}
9091

91-
return nil
92+
return nil, nil
9293
}
9394

9495
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
95-
func (m *GCPMachine) ValidateDelete() error {
96+
func (m *GCPMachine) ValidateDelete() (admission.Warnings, error) {
9697
clusterlog.Info("validate delete", "name", m.Name)
9798

98-
return nil
99+
return nil, nil
99100
}
100101

101102
// Default implements webhookutil.defaulter so a webhook will be registered for the type.

api/v1beta1/gcpmachine_webhook_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,13 @@ func TestGCPMachine_ValidateCreate(t *testing.T) {
9090
test := test
9191
t.Run(test.name, func(t *testing.T) {
9292
t.Parallel()
93-
err := test.GCPMachine.ValidateCreate()
93+
warn, err := test.GCPMachine.ValidateCreate()
9494
if test.wantErr {
9595
g.Expect(err).To(HaveOccurred())
9696
} else {
9797
g.Expect(err).NotTo(HaveOccurred())
9898
}
99+
g.Expect(warn).To(BeNil())
99100
})
100101
}
101102
}

0 commit comments

Comments
 (0)