Skip to content

Commit 1145aa8

Browse files
authored
upgraded controller runtime to 0.20.4 (#6)
1 parent 436e8b9 commit 1145aa8

File tree

6 files changed

+219
-176
lines changed

6 files changed

+219
-176
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ ifeq ($(FIPS_ENABLE),yes)
5656
RELEASE_LOC := release-fips
5757
endif
5858

59-
SPECTRO_VERSION ?= 4.7.0-dev
59+
SPECTRO_VERSION ?= 4.8.0-dev
6060
TAG ?= v0.6.1-spectro-${SPECTRO_VERSION}
6161
ARCH ?= amd64
6262
ALL_ARCH = amd64 arm64

api/v1beta3/cloudstackcluster_webhook.go

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package v1beta3
1818

1919
import (
20+
"context"
2021
"fmt"
2122

2223
"k8s.io/apimachinery/pkg/api/errors"
@@ -36,25 +37,36 @@ var cloudstackclusterlog = logf.Log.WithName("cloudstackcluster-resource")
3637
func (r *CloudStackCluster) SetupWebhookWithManager(mgr ctrl.Manager) error {
3738
return ctrl.NewWebhookManagedBy(mgr).
3839
For(r).
40+
WithDefaulter(r). // registers webhook.CustomDefaulter
41+
WithValidator(r). // registers webhook.CustomValidator
3942
Complete()
4043
}
4144

4245
//+kubebuilder:webhook:path=/mutate-infrastructure-cluster-x-k8s-io-v1beta3-cloudstackcluster,mutating=true,failurePolicy=fail,sideEffects=None,groups=infrastructure.cluster.x-k8s.io,resources=cloudstackclusters,verbs=create;update,versions=v1beta3,name=mcloudstackcluster.kb.io,admissionReviewVersions=v1;v1beta1
4346

44-
var _ webhook.Defaulter = &CloudStackCluster{}
47+
var _ webhook.CustomDefaulter = &CloudStackCluster{}
4548

4649
// Default implements webhook.Defaulter so a webhook will be registered for the type
47-
func (r *CloudStackCluster) Default() {
50+
func (r *CloudStackCluster) Default(_ context.Context, obj runtime.Object) error {
51+
r, ok := obj.(*CloudStackCluster)
52+
if !ok {
53+
return fmt.Errorf("expected *CloudStackCluster, got %T", obj)
54+
}
4855
cloudstackclusterlog.V(1).Info("entered api default setting webhook", "api resource name", r.Name)
4956
// No defaulted values supported yet.
57+
return nil
5058
}
5159

5260
// +kubebuilder:webhook:name=vcloudstackcluster.kb.io,groups=infrastructure.cluster.x-k8s.io,resources=cloudstackclusters,versions=v1beta3,verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta3-cloudstackcluster,mutating=false,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1
5361

54-
var _ webhook.Validator = &CloudStackCluster{}
62+
var _ webhook.CustomValidator = &CloudStackCluster{}
5563

5664
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
57-
func (r *CloudStackCluster) ValidateCreate() (admission.Warnings, error) {
65+
func (r *CloudStackCluster) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) {
66+
r, ok := obj.(*CloudStackCluster)
67+
if !ok {
68+
return nil, fmt.Errorf("expected *CloudStackCluster, got %T", obj)
69+
}
5870
cloudstackclusterlog.V(1).Info("entered validate create webhook", "api resource name", r.Name)
5971

6072
var errorList field.ErrorList
@@ -85,7 +97,11 @@ func (r *CloudStackCluster) ValidateCreate() (admission.Warnings, error) {
8597
}
8698

8799
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
88-
func (r *CloudStackCluster) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
100+
func (r *CloudStackCluster) ValidateUpdate(_ context.Context, old runtime.Object, new runtime.Object) (admission.Warnings, error) {
101+
r, ok := new.(*CloudStackCluster)
102+
if !ok {
103+
return nil, fmt.Errorf("expected *CloudStackCluster, got %T", new)
104+
}
89105
cloudstackclusterlog.V(1).Info("entered validate update webhook", "api resource name", r.Name)
90106

91107
spec := r.Spec
@@ -151,7 +167,7 @@ func FailureDomainsEqual(fd1, fd2 CloudStackFailureDomainSpec) bool {
151167
}
152168

153169
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
154-
func (r *CloudStackCluster) ValidateDelete() (admission.Warnings, error) {
170+
func (r *CloudStackCluster) ValidateDelete(_ context.Context, _ runtime.Object) (admission.Warnings, error) {
155171
cloudstackclusterlog.V(1).Info("entered validate delete webhook", "api resource name", r.Name)
156172
// No deletion validations. Deletion webhook not enabled.
157173
return nil, nil

api/v1beta3/cloudstackmachine_webhook.go

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package v1beta3
1818

1919
import (
20+
"context"
2021
"fmt"
2122
"reflect"
2223

@@ -36,25 +37,36 @@ var cloudstackmachinelog = logf.Log.WithName("cloudstackmachine-resource")
3637
func (r *CloudStackMachine) SetupWebhookWithManager(mgr ctrl.Manager) error {
3738
return ctrl.NewWebhookManagedBy(mgr).
3839
For(r).
40+
WithDefaulter(r). // registers webhook.CustomDefaulter
41+
WithValidator(r). // registers webhook.CustomValidator
3942
Complete()
4043
}
4144

4245
//+kubebuilder:webhook:path=/mutate-infrastructure-cluster-x-k8s-io-v1beta3-cloudstackmachine,mutating=true,failurePolicy=fail,sideEffects=None,groups=infrastructure.cluster.x-k8s.io,resources=cloudstackmachines,verbs=create;update,versions=v1beta3,name=mcloudstackmachine.kb.io,admissionReviewVersions=v1;v1beta1
4346

44-
var _ webhook.Defaulter = &CloudStackMachine{}
47+
var _ webhook.CustomDefaulter = &CloudStackMachine{}
4548

4649
// Default implements webhook.Defaulter so a webhook will be registered for the type
47-
func (r *CloudStackMachine) Default() {
50+
func (r *CloudStackMachine) Default(_ context.Context, obj runtime.Object) error {
51+
r, ok := obj.(*CloudStackMachine)
52+
if !ok {
53+
return fmt.Errorf("expected *CloudStackCluster, got %T", obj)
54+
}
4855
cloudstackmachinelog.V(1).Info("entered api default setting webhook, no defaults to set", "api resource name", r.Name)
4956
// No defaulted values supported yet.
57+
return nil
5058
}
5159

5260
//+kubebuilder:webhook:path=/validate-infrastructure-cluster-x-k8s-io-v1beta3-cloudstackmachine,mutating=false,failurePolicy=fail,sideEffects=None,groups=infrastructure.cluster.x-k8s.io,resources=cloudstackmachines,verbs=create;update,versions=v1beta3,name=vcloudstackmachine.kb.io,admissionReviewVersions=v1;v1beta1
5361

54-
var _ webhook.Validator = &CloudStackMachine{}
62+
var _ webhook.CustomValidator = &CloudStackMachine{}
5563

5664
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
57-
func (r *CloudStackMachine) ValidateCreate() (admission.Warnings, error) {
65+
func (r *CloudStackMachine) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) {
66+
r, ok := obj.(*CloudStackMachine)
67+
if !ok {
68+
return nil, fmt.Errorf("expected *CloudStackMachine, got %T", obj)
69+
}
5870
cloudstackmachinelog.V(1).Info("entered validate create webhook", "api resource name", r.Name)
5971

6072
var errorList field.ErrorList
@@ -69,7 +81,11 @@ func (r *CloudStackMachine) ValidateCreate() (admission.Warnings, error) {
6981
}
7082

7183
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
72-
func (r *CloudStackMachine) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
84+
func (r *CloudStackMachine) ValidateUpdate(_ context.Context, old runtime.Object, new runtime.Object) (admission.Warnings, error) {
85+
r, ok := new.(*CloudStackMachine)
86+
if !ok {
87+
return nil, fmt.Errorf("expected *CloudStackMachine, got %T", new)
88+
}
7389
cloudstackmachinelog.V(1).Info("entered validate update webhook", "api resource name", r.Name)
7490

7591
var errorList field.ErrorList
@@ -103,7 +119,7 @@ func (r *CloudStackMachine) ValidateUpdate(old runtime.Object) (admission.Warnin
103119
}
104120

105121
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
106-
func (r *CloudStackMachine) ValidateDelete() (admission.Warnings, error) {
122+
func (r *CloudStackMachine) ValidateDelete(_ context.Context, _ runtime.Object) (admission.Warnings, error) {
107123
cloudstackmachinelog.V(1).Info("entered validate delete webhook", "api resource name", r.Name)
108124
// No deletion validations. Deletion webhook not enabled.
109125
return nil, nil

api/v1beta3/cloudstackmachinetemplate_webhook.go

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package v1beta3
1818

1919
import (
20+
"context"
2021
"fmt"
2122
"reflect"
2223
"strings"
@@ -37,25 +38,36 @@ var cloudstackmachinetemplatelog = logf.Log.WithName("cloudstackmachinetemplate-
3738
func (r *CloudStackMachineTemplate) SetupWebhookWithManager(mgr ctrl.Manager) error {
3839
return ctrl.NewWebhookManagedBy(mgr).
3940
For(r).
41+
WithDefaulter(r). // registers webhook.CustomDefaulter
42+
WithValidator(r). // registers webhook.CustomValidator
4043
Complete()
4144
}
4245

4346
// +kubebuilder:webhook:path=/mutate-infrastructure-cluster-x-k8s-io-v1beta3-cloudstackmachinetemplate,mutating=true,failurePolicy=fail,sideEffects=None,groups=infrastructure.cluster.x-k8s.io,resources=cloudstackmachinetemplates,verbs=create;update,versions=v1beta3,name=mcloudstackmachinetemplate.kb.io,admissionReviewVersions=v1;v1beta1
4447

45-
var _ webhook.Defaulter = &CloudStackMachineTemplate{}
48+
var _ webhook.CustomDefaulter = &CloudStackMachineTemplate{}
4649

4750
// Default implements webhook.Defaulter so a webhook will be registered for the type
48-
func (r *CloudStackMachineTemplate) Default() {
51+
func (r *CloudStackMachineTemplate) Default(_ context.Context, obj runtime.Object) error {
52+
r, ok := obj.(*CloudStackMachineTemplate)
53+
if !ok {
54+
return fmt.Errorf("expected *CloudStackMachineTemplate, got %T", obj)
55+
}
4956
cloudstackmachinetemplatelog.V(1).Info("entered default setting webhook", "api resource name", r.Name)
5057
// No defaulted values supported yet.
58+
return nil
5159
}
5260

5361
// +kubebuilder:webhook:path=/validate-infrastructure-cluster-x-k8s-io-v1beta3-cloudstackmachinetemplate,mutating=false,failurePolicy=fail,sideEffects=None,groups=infrastructure.cluster.x-k8s.io,resources=cloudstackmachinetemplates,verbs=create;update,versions=v1beta3,name=vcloudstackmachinetemplate.kb.io,admissionReviewVersions=v1;v1beta1
5462

55-
var _ webhook.Validator = &CloudStackMachineTemplate{}
63+
var _ webhook.CustomValidator = &CloudStackMachineTemplate{}
5664

5765
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
58-
func (r *CloudStackMachineTemplate) ValidateCreate() (admission.Warnings, error) {
66+
func (r *CloudStackMachineTemplate) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) {
67+
r, ok := obj.(*CloudStackMachineTemplate)
68+
if !ok {
69+
return nil, fmt.Errorf("expected *CloudStackMachineTemplate, got %T", obj)
70+
}
5971
cloudstackmachinetemplatelog.V(1).Info("entered validate create webhook", "api resource name", r.Name)
6072

6173
var errorList field.ErrorList
@@ -80,7 +92,11 @@ func (r *CloudStackMachineTemplate) ValidateCreate() (admission.Warnings, error)
8092
}
8193

8294
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
83-
func (r *CloudStackMachineTemplate) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
95+
func (r *CloudStackMachineTemplate) ValidateUpdate(_ context.Context, old runtime.Object, new runtime.Object) (admission.Warnings, error) {
96+
r, ok := new.(*CloudStackMachineTemplate)
97+
if !ok {
98+
return nil, fmt.Errorf("expected *CloudStackMachineTemplate, got %T", new)
99+
}
84100
cloudstackmachinetemplatelog.V(1).Info("entered validate update webhook", "api resource name", r.Name)
85101

86102
oldMachineTemplate, ok := old.(*CloudStackMachineTemplate)
@@ -111,7 +127,7 @@ func (r *CloudStackMachineTemplate) ValidateUpdate(old runtime.Object) (admissio
111127
}
112128

113129
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
114-
func (r *CloudStackMachineTemplate) ValidateDelete() (admission.Warnings, error) {
130+
func (r *CloudStackMachineTemplate) ValidateDelete(_ context.Context, _ runtime.Object) (admission.Warnings, error) {
115131
cloudstackmachinetemplatelog.V(1).Info("entered validate delete webhook", "api resource name", r.Name)
116132
// No deletion validations. Deletion webhook not enabled.
117133
return nil, nil

go.mod

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,27 @@ require (
99
github.com/go-logr/logr v1.4.2
1010
github.com/hashicorp/go-multierror v1.1.1
1111
github.com/jellydator/ttlcache/v3 v3.2.0
12-
github.com/onsi/ginkgo/v2 v2.22.2
13-
github.com/onsi/gomega v1.36.2
12+
github.com/onsi/ginkgo/v2 v2.23.3
13+
github.com/onsi/gomega v1.36.3
1414
github.com/pkg/errors v0.9.1
1515
github.com/prometheus/client_golang v1.19.1
1616
github.com/smallfish/simpleyaml v0.1.0
17-
github.com/spf13/pflag v1.0.5
17+
github.com/spf13/pflag v1.0.6
1818
go.uber.org/mock v0.5.1
1919
golang.org/x/text v0.23.0
2020
gopkg.in/yaml.v3 v3.0.1
21-
k8s.io/api v0.31.3
22-
k8s.io/apimachinery v0.31.3
23-
k8s.io/client-go v0.31.3
24-
k8s.io/component-base v0.31.3
21+
k8s.io/api v0.32.3
22+
k8s.io/apimachinery v0.32.3
23+
k8s.io/client-go v0.32.3
24+
k8s.io/component-base v0.32.3
2525
k8s.io/klog/v2 v2.130.1
26-
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8
27-
sigs.k8s.io/cluster-api v1.9.6
28-
sigs.k8s.io/controller-runtime v0.19.6
26+
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738
27+
sigs.k8s.io/cluster-api v1.10.4
28+
sigs.k8s.io/controller-runtime v0.20.4
2929
)
3030

3131
require (
32+
cel.dev/expr v0.18.0 // indirect
3233
github.com/NYTimes/gziphandler v1.1.1 // indirect
3334
github.com/antlr4-go/antlr/v4 v4.13.0 // indirect
3435
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
@@ -37,29 +38,28 @@ require (
3738
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
3839
github.com/cespare/xxhash/v2 v2.3.0 // indirect
3940
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
40-
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
41-
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
41+
github.com/emicklei/go-restful/v3 v3.12.2 // indirect
42+
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
4243
github.com/felixge/httpsnoop v1.0.4 // indirect
43-
github.com/fsnotify/fsnotify v1.7.0 // indirect
44+
github.com/fsnotify/fsnotify v1.8.0 // indirect
4445
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
4546
github.com/go-logr/stdr v1.2.2 // indirect
46-
github.com/go-openapi/jsonpointer v0.19.6 // indirect
47+
github.com/go-openapi/jsonpointer v0.21.0 // indirect
4748
github.com/go-openapi/jsonreference v0.20.2 // indirect
48-
github.com/go-openapi/swag v0.22.4 // indirect
49+
github.com/go-openapi/swag v0.23.0 // indirect
4950
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
5051
github.com/gobuffalo/flect v1.0.3 // indirect
5152
github.com/gogo/protobuf v1.3.2 // indirect
52-
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
5353
github.com/golang/protobuf v1.5.4 // indirect
54-
github.com/google/cel-go v0.20.1 // indirect
54+
github.com/google/btree v1.1.3 // indirect
55+
github.com/google/cel-go v0.22.0 // indirect
5556
github.com/google/gnostic-models v0.6.8 // indirect
56-
github.com/google/go-cmp v0.6.0 // indirect
57+
github.com/google/go-cmp v0.7.0 // indirect
5758
github.com/google/gofuzz v1.2.0 // indirect
5859
github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad // indirect
5960
github.com/google/uuid v1.6.0 // indirect
6061
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
6162
github.com/hashicorp/errwrap v1.0.0 // indirect
62-
github.com/imdario/mergo v0.3.13 // indirect
6363
github.com/inconshreveable/mousetrap v1.1.0 // indirect
6464
github.com/josharian/intern v1.0.0 // indirect
6565
github.com/json-iterator/go v1.1.12 // indirect
@@ -70,40 +70,40 @@ require (
7070
github.com/prometheus/client_model v0.6.1 // indirect
7171
github.com/prometheus/common v0.55.0 // indirect
7272
github.com/prometheus/procfs v0.15.1 // indirect
73-
github.com/spf13/cobra v1.8.1 // indirect
74-
github.com/stoewer/go-strcase v1.2.0 // indirect
73+
github.com/spf13/cobra v1.9.1 // indirect
74+
github.com/stoewer/go-strcase v1.3.0 // indirect
7575
github.com/x448/float16 v0.8.4 // indirect
76-
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect
77-
go.opentelemetry.io/otel v1.28.0 // indirect
76+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect
77+
go.opentelemetry.io/otel v1.29.0 // indirect
7878
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 // indirect
7979
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0 // indirect
80-
go.opentelemetry.io/otel/metric v1.28.0 // indirect
81-
go.opentelemetry.io/otel/sdk v1.28.0 // indirect
82-
go.opentelemetry.io/otel/trace v1.28.0 // indirect
80+
go.opentelemetry.io/otel/metric v1.29.0 // indirect
81+
go.opentelemetry.io/otel/sdk v1.29.0 // indirect
82+
go.opentelemetry.io/otel/trace v1.29.0 // indirect
8383
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
8484
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
8585
golang.org/x/net v0.38.0 // indirect
86-
golang.org/x/oauth2 v0.24.0 // indirect
86+
golang.org/x/oauth2 v0.28.0 // indirect
8787
golang.org/x/sync v0.12.0 // indirect
8888
golang.org/x/sys v0.31.0 // indirect
8989
golang.org/x/term v0.30.0 // indirect
90-
golang.org/x/time v0.5.0 // indirect
91-
golang.org/x/tools v0.28.0 // indirect
92-
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
93-
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect
94-
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect
95-
google.golang.org/grpc v1.65.1 // indirect
96-
google.golang.org/protobuf v1.36.1 // indirect
90+
golang.org/x/time v0.8.0 // indirect
91+
golang.org/x/tools v0.30.0 // indirect
92+
gomodules.xyz/jsonpatch/v2 v2.5.0 // indirect
93+
google.golang.org/genproto/googleapis/api v0.0.0-20241209162323-e6fa225c2576 // indirect
94+
google.golang.org/genproto/googleapis/rpc v0.0.0-20241223144023-3abc09e42ca8 // indirect
95+
google.golang.org/grpc v1.67.3 // indirect
96+
google.golang.org/protobuf v1.36.5 // indirect
9797
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
9898
gopkg.in/inf.v0 v0.9.1 // indirect
9999
gopkg.in/yaml.v2 v2.4.0 // indirect
100-
k8s.io/apiextensions-apiserver v0.31.3 // indirect
101-
k8s.io/apiserver v0.31.3 // indirect
102-
k8s.io/cluster-bootstrap v0.31.3 // indirect
103-
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
104-
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.30.3 // indirect
105-
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
106-
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
100+
k8s.io/apiextensions-apiserver v0.32.3 // indirect
101+
k8s.io/apiserver v0.32.3 // indirect
102+
k8s.io/cluster-bootstrap v0.32.3 // indirect
103+
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect
104+
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.0 // indirect
105+
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect
106+
sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect
107107
sigs.k8s.io/yaml v1.4.0 // indirect
108108
)
109109

0 commit comments

Comments
 (0)