Skip to content

Commit cc790c7

Browse files
authored
Update golang, k8s and cluster-api (#1274)
1 parent eb957ae commit cc790c7

30 files changed

+351
-414
lines changed

.golangci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ linters-settings:
101101
allow-leading-space: false
102102
require-specific: true
103103
staticcheck:
104-
go: "1.19"
104+
go: "1.20"
105105
stylecheck:
106-
go: "1.19"
106+
go: "1.20"
107107
gosec:
108108
excludes:
109109
- G307 # Deferring unsafe method "Close" on type "\*os.File"
@@ -126,7 +126,7 @@ linters-settings:
126126
- whyNoLint
127127
- wrapperFunc
128128
unused:
129-
go: "1.19"
129+
go: "1.20"
130130
issues:
131131
max-same-issues: 0
132132
max-issues-per-linter: 0

api/v1beta2/ibmpowervscluster_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
// log is for logging in this package.
@@ -51,33 +52,33 @@ func (r *IBMPowerVSCluster) Default() {
5152
var _ webhook.Validator = &IBMPowerVSCluster{}
5253

5354
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
54-
func (r *IBMPowerVSCluster) ValidateCreate() error {
55+
func (r *IBMPowerVSCluster) ValidateCreate() (admission.Warnings, error) {
5556
ibmpowervsclusterlog.Info("validate create", "name", r.Name)
5657
return r.validateIBMPowerVSCluster()
5758
}
5859

5960
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
60-
func (r *IBMPowerVSCluster) ValidateUpdate(_ runtime.Object) error {
61+
func (r *IBMPowerVSCluster) ValidateUpdate(_ runtime.Object) (admission.Warnings, error) {
6162
ibmpowervsclusterlog.Info("validate update", "name", r.Name)
6263
return r.validateIBMPowerVSCluster()
6364
}
6465

6566
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
66-
func (r *IBMPowerVSCluster) ValidateDelete() error {
67+
func (r *IBMPowerVSCluster) ValidateDelete() (admission.Warnings, error) {
6768
ibmpowervsclusterlog.Info("validate delete", "name", r.Name)
68-
return nil
69+
return nil, nil
6970
}
7071

71-
func (r *IBMPowerVSCluster) validateIBMPowerVSCluster() error {
72+
func (r *IBMPowerVSCluster) validateIBMPowerVSCluster() (admission.Warnings, error) {
7273
var allErrs field.ErrorList
7374
if err := r.validateIBMPowerVSClusterNetwork(); err != nil {
7475
allErrs = append(allErrs, err)
7576
}
7677
if len(allErrs) == 0 {
77-
return nil
78+
return nil, nil
7879
}
7980

80-
return apierrors.NewInvalid(
81+
return nil, apierrors.NewInvalid(
8182
schema.GroupKind{Group: "infrastructure.cluster.x-k8s.io", Kind: "IBMPowerVSCluster"},
8283
r.Name, allErrs)
8384
}

api/v1beta2/ibmpowervsclustertemplate_webhook.go

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

3132
// log is for logging in this package.
@@ -51,28 +52,28 @@ func (r *IBMPowerVSClusterTemplate) Default() {
5152
var _ webhook.Validator = &IBMPowerVSClusterTemplate{}
5253

5354
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
54-
func (r *IBMPowerVSClusterTemplate) ValidateCreate() error {
55+
func (r *IBMPowerVSClusterTemplate) ValidateCreate() (admission.Warnings, error) {
5556
ibmpowervsclustertemplatelog.Info("validate create", "name", r.Name)
5657

57-
return nil
58+
return nil, nil
5859
}
5960

6061
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
61-
func (r *IBMPowerVSClusterTemplate) ValidateUpdate(oldRaw runtime.Object) error {
62+
func (r *IBMPowerVSClusterTemplate) ValidateUpdate(oldRaw runtime.Object) (admission.Warnings, error) {
6263
ibmpowervsclustertemplatelog.Info("validate update", "name", r.Name)
6364
old, ok := oldRaw.(*IBMPowerVSClusterTemplate)
6465
if !ok {
65-
return apierrors.NewBadRequest(fmt.Sprintf("expected an IBMPowerVSClusterTemplate but got a %T", oldRaw))
66+
return nil, apierrors.NewBadRequest(fmt.Sprintf("expected an IBMPowerVSClusterTemplate but got a %T", oldRaw))
6667
}
6768
if !reflect.DeepEqual(r.Spec, old.Spec) {
68-
return apierrors.NewBadRequest("IBMPowerVSClusterTemplate.Spec is immutable")
69+
return nil, apierrors.NewBadRequest("IBMPowerVSClusterTemplate.Spec is immutable")
6970
}
70-
return nil
71+
return nil, nil
7172
}
7273

7374
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
74-
func (r *IBMPowerVSClusterTemplate) ValidateDelete() error {
75+
func (r *IBMPowerVSClusterTemplate) ValidateDelete() (admission.Warnings, error) {
7576
ibmpowervsclustertemplatelog.Info("validate delete", "name", r.Name)
7677

77-
return nil
78+
return nil, nil
7879
}

api/v1beta2/ibmpowervsclustertemplate_webhook_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func TestIBMPowerVSClusterTemplate_ValidateUpdate(t *testing.T) {
7878
}
7979
for _, test := range tests {
8080
t.Run(test.name, func(t *testing.T) {
81-
err := test.newTemplate.ValidateUpdate(test.oldTemplate)
81+
_, err := test.newTemplate.ValidateUpdate(test.oldTemplate)
8282
if test.wantErr {
8383
g.Expect(err).To(HaveOccurred())
8484
} else {

api/v1beta2/ibmpowervsimage_webhook.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
ctrl "sigs.k8s.io/controller-runtime"
2323
logf "sigs.k8s.io/controller-runtime/pkg/log"
2424
"sigs.k8s.io/controller-runtime/pkg/webhook"
25+
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
2526
)
2627

2728
// log is for logging in this package.
@@ -48,19 +49,19 @@ func (r *IBMPowerVSImage) Default() {
4849
var _ webhook.Validator = &IBMPowerVSImage{}
4950

5051
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
51-
func (r *IBMPowerVSImage) ValidateCreate() error {
52+
func (r *IBMPowerVSImage) ValidateCreate() (admission.Warnings, error) {
5253
ibmpowervsimagelog.Info("validate create", "name", r.Name)
53-
return nil
54+
return nil, nil
5455
}
5556

5657
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
57-
func (r *IBMPowerVSImage) ValidateUpdate(_ runtime.Object) error {
58+
func (r *IBMPowerVSImage) ValidateUpdate(_ runtime.Object) (admission.Warnings, error) {
5859
ibmpowervsimagelog.Info("validate update", "name", r.Name)
59-
return nil
60+
return nil, nil
6061
}
6162

6263
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
63-
func (r *IBMPowerVSImage) ValidateDelete() error {
64+
func (r *IBMPowerVSImage) ValidateDelete() (admission.Warnings, error) {
6465
ibmpowervsimagelog.Info("validate delete", "name", r.Name)
65-
return nil
66+
return nil, nil
6667
}

api/v1beta2/ibmpowervsmachine_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
// log is for logging in this package.
@@ -51,24 +52,24 @@ func (r *IBMPowerVSMachine) Default() {
5152
var _ webhook.Validator = &IBMPowerVSMachine{}
5253

5354
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
54-
func (r *IBMPowerVSMachine) ValidateCreate() error {
55+
func (r *IBMPowerVSMachine) ValidateCreate() (admission.Warnings, error) {
5556
ibmpowervsmachinelog.Info("validate create", "name", r.Name)
5657
return r.validateIBMPowerVSMachine()
5758
}
5859

5960
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
60-
func (r *IBMPowerVSMachine) ValidateUpdate(_ runtime.Object) error {
61+
func (r *IBMPowerVSMachine) ValidateUpdate(_ runtime.Object) (admission.Warnings, error) {
6162
ibmpowervsmachinelog.Info("validate update", "name", r.Name)
6263
return r.validateIBMPowerVSMachine()
6364
}
6465

6566
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
66-
func (r *IBMPowerVSMachine) ValidateDelete() error {
67+
func (r *IBMPowerVSMachine) ValidateDelete() (admission.Warnings, error) {
6768
ibmpowervsmachinelog.Info("validate delete", "name", r.Name)
68-
return nil
69+
return nil, nil
6970
}
7071

71-
func (r *IBMPowerVSMachine) validateIBMPowerVSMachine() error {
72+
func (r *IBMPowerVSMachine) validateIBMPowerVSMachine() (admission.Warnings, error) {
7273
var allErrs field.ErrorList
7374
if err := r.validateIBMPowerVSMachineNetwork(); err != nil {
7475
allErrs = append(allErrs, err)
@@ -83,10 +84,10 @@ func (r *IBMPowerVSMachine) validateIBMPowerVSMachine() error {
8384
allErrs = append(allErrs, err)
8485
}
8586
if len(allErrs) == 0 {
86-
return nil
87+
return nil, nil
8788
}
8889

89-
return apierrors.NewInvalid(
90+
return nil, apierrors.NewInvalid(
9091
schema.GroupKind{Group: "infrastructure.cluster.x-k8s.io", Kind: "IBMPowerVSMachine"},
9192
r.Name, allErrs)
9293
}

api/v1beta2/ibmpowervsmachinetemplate_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
// log is for logging in this package.
@@ -51,24 +52,24 @@ func (r *IBMPowerVSMachineTemplate) Default() {
5152
var _ webhook.Validator = &IBMPowerVSMachineTemplate{}
5253

5354
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
54-
func (r *IBMPowerVSMachineTemplate) ValidateCreate() error {
55+
func (r *IBMPowerVSMachineTemplate) ValidateCreate() (admission.Warnings, error) {
5556
ibmpowervsmachinetemplatelog.Info("validate create", "name", r.Name)
5657
return r.validateIBMPowerVSMachineTemplate()
5758
}
5859

5960
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
60-
func (r *IBMPowerVSMachineTemplate) ValidateUpdate(_ runtime.Object) error {
61+
func (r *IBMPowerVSMachineTemplate) ValidateUpdate(_ runtime.Object) (admission.Warnings, error) {
6162
ibmpowervsmachinetemplatelog.Info("validate update", "name", r.Name)
6263
return r.validateIBMPowerVSMachineTemplate()
6364
}
6465

6566
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
66-
func (r *IBMPowerVSMachineTemplate) ValidateDelete() error {
67+
func (r *IBMPowerVSMachineTemplate) ValidateDelete() (admission.Warnings, error) {
6768
ibmpowervsmachinetemplatelog.Info("validate delete", "name", r.Name)
68-
return nil
69+
return nil, nil
6970
}
7071

71-
func (r *IBMPowerVSMachineTemplate) validateIBMPowerVSMachineTemplate() error {
72+
func (r *IBMPowerVSMachineTemplate) validateIBMPowerVSMachineTemplate() (admission.Warnings, error) {
7273
var allErrs field.ErrorList
7374
if err := r.validateIBMPowerVSMachineTemplateNetwork(); err != nil {
7475
allErrs = append(allErrs, err)
@@ -83,10 +84,10 @@ func (r *IBMPowerVSMachineTemplate) validateIBMPowerVSMachineTemplate() error {
8384
allErrs = append(allErrs, err)
8485
}
8586
if len(allErrs) == 0 {
86-
return nil
87+
return nil, nil
8788
}
8889

89-
return apierrors.NewInvalid(
90+
return nil, apierrors.NewInvalid(
9091
schema.GroupKind{Group: "infrastructure.cluster.x-k8s.io", Kind: "IBMPowerVSMachineTemplate"},
9192
r.Name, allErrs)
9293
}

api/v1beta2/ibmvpccluster_webhook.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
ctrl "sigs.k8s.io/controller-runtime"
2323
logf "sigs.k8s.io/controller-runtime/pkg/log"
2424
"sigs.k8s.io/controller-runtime/pkg/webhook"
25+
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
2526
)
2627

2728
// log is for logging in this package.
@@ -48,19 +49,19 @@ func (r *IBMVPCCluster) Default() {
4849
var _ webhook.Validator = &IBMVPCCluster{}
4950

5051
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
51-
func (r *IBMVPCCluster) ValidateCreate() error {
52+
func (r *IBMVPCCluster) ValidateCreate() (admission.Warnings, error) {
5253
ibmvpcclusterlog.Info("validate create", "name", r.Name)
53-
return nil
54+
return nil, nil
5455
}
5556

5657
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
57-
func (r *IBMVPCCluster) ValidateUpdate(_ runtime.Object) error {
58+
func (r *IBMVPCCluster) ValidateUpdate(_ runtime.Object) (admission.Warnings, error) {
5859
ibmvpcclusterlog.Info("validate update", "name", r.Name)
59-
return nil
60+
return nil, nil
6061
}
6162

6263
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
63-
func (r *IBMVPCCluster) ValidateDelete() error {
64+
func (r *IBMVPCCluster) ValidateDelete() (admission.Warnings, error) {
6465
ibmvpcclusterlog.Info("validate delete", "name", r.Name)
65-
return nil
66+
return nil, nil
6667
}

api/v1beta2/ibmvpcmachine_webhook.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
ctrl "sigs.k8s.io/controller-runtime"
2424
logf "sigs.k8s.io/controller-runtime/pkg/log"
2525
"sigs.k8s.io/controller-runtime/pkg/webhook"
26+
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
2627
)
2728

2829
// log is for logging in this package.
@@ -50,25 +51,25 @@ func (r *IBMVPCMachine) Default() {
5051
var _ webhook.Validator = &IBMVPCMachine{}
5152

5253
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
53-
func (r *IBMVPCMachine) ValidateCreate() error {
54+
func (r *IBMVPCMachine) ValidateCreate() (admission.Warnings, error) {
5455
ibmvpcmachinelog.Info("validate create", "name", r.Name)
5556

5657
var allErrs field.ErrorList
5758
allErrs = append(allErrs, r.validateIBMVPCMachineBootVolume()...)
5859

59-
return aggregateObjErrors(r.GroupVersionKind().GroupKind(), r.Name, allErrs)
60+
return nil, aggregateObjErrors(r.GroupVersionKind().GroupKind(), r.Name, allErrs)
6061
}
6162

6263
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
63-
func (r *IBMVPCMachine) ValidateUpdate(_ runtime.Object) error {
64+
func (r *IBMVPCMachine) ValidateUpdate(_ runtime.Object) (admission.Warnings, error) {
6465
ibmvpcmachinelog.Info("validate update", "name", r.Name)
65-
return nil
66+
return nil, nil
6667
}
6768

6869
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
69-
func (r *IBMVPCMachine) ValidateDelete() error {
70+
func (r *IBMVPCMachine) ValidateDelete() (admission.Warnings, error) {
7071
ibmvpcmachinelog.Info("validate delete", "name", r.Name)
71-
return nil
72+
return nil, nil
7273
}
7374

7475
func (r *IBMVPCMachine) validateIBMVPCMachineBootVolume() field.ErrorList {

api/v1beta2/ibmvpcmachinetemplate_webhook.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
ctrl "sigs.k8s.io/controller-runtime"
2424
logf "sigs.k8s.io/controller-runtime/pkg/log"
2525
"sigs.k8s.io/controller-runtime/pkg/webhook"
26+
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
2627
)
2728

2829
// log is for logging in this package.
@@ -50,24 +51,24 @@ func (r *IBMVPCMachineTemplate) Default() {
5051
var _ webhook.Validator = &IBMVPCMachineTemplate{}
5152

5253
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
53-
func (r *IBMVPCMachineTemplate) ValidateCreate() error {
54+
func (r *IBMVPCMachineTemplate) ValidateCreate() (admission.Warnings, error) {
5455
ibmvpcmachinetemplatelog.Info("validate create", "name", r.Name)
5556
var allErrs field.ErrorList
5657
allErrs = append(allErrs, r.validateIBMVPCMachineBootVolume()...)
5758

58-
return aggregateObjErrors(r.GroupVersionKind().GroupKind(), r.Name, allErrs)
59+
return nil, aggregateObjErrors(r.GroupVersionKind().GroupKind(), r.Name, allErrs)
5960
}
6061

6162
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
62-
func (r *IBMVPCMachineTemplate) ValidateUpdate(_ runtime.Object) error {
63+
func (r *IBMVPCMachineTemplate) ValidateUpdate(_ runtime.Object) (admission.Warnings, error) {
6364
ibmvpcmachinetemplatelog.Info("validate update", "name", r.Name)
64-
return nil
65+
return nil, nil
6566
}
6667

6768
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
68-
func (r *IBMVPCMachineTemplate) ValidateDelete() error {
69+
func (r *IBMVPCMachineTemplate) ValidateDelete() (admission.Warnings, error) {
6970
ibmvpcmachinetemplatelog.Info("validate delete", "name", r.Name)
70-
return nil
71+
return nil, nil
7172
}
7273

7374
func (r *IBMVPCMachineTemplate) validateIBMVPCMachineBootVolume() field.ErrorList {

0 commit comments

Comments
 (0)