Skip to content

Commit 7850a2b

Browse files
authored
Merge pull request #386 from mboersma/capi-one-ten
🌱 Bump CAPI to v1.10.5
2 parents e766080 + 4ad876b commit 7850a2b

File tree

23 files changed

+456
-446
lines changed

23 files changed

+456
-446
lines changed

Makefile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ BUILD_CONTAINER_ADDITIONAL_ARGS ?=
5151
#
5252
# Kubebuilder.
5353
#
54-
export KUBEBUILDER_ENVTEST_KUBERNETES_VERSION ?= 1.32.0
54+
export KUBEBUILDER_ENVTEST_KUBERNETES_VERSION ?= 1.33.0
5555
export KUBEBUILDER_CONTROLPLANE_START_TIMEOUT ?= 60s
5656
export KUBEBUILDER_CONTROLPLANE_STOP_TIMEOUT ?= 60s
5757

@@ -115,7 +115,7 @@ get_go_version = $(shell go list -m $1 | rev | cut -d' ' -f1 | rev)
115115
# curl retries
116116
CURL_RETRIES=3
117117

118-
KUSTOMIZE_VER := v5.3.0
118+
KUSTOMIZE_VER := v5.6.0
119119
KUSTOMIZE_BIN := kustomize
120120
KUSTOMIZE := $(abspath $(TOOLS_BIN_DIR)/$(KUSTOMIZE_BIN)-$(KUSTOMIZE_VER))
121121
KUSTOMIZE_PKG := sigs.k8s.io/kustomize/kustomize/v5
@@ -128,12 +128,12 @@ MOCKGEN_VER := $(call get_go_version,$(MOCKGEN_PKG))
128128
MOCKGEN_BIN := mockgen
129129
MOCKGEN := $(TOOLS_BIN_DIR)/$(MOCKGEN_BIN)-$(MOCKGEN_VER)
130130

131-
SETUP_ENVTEST_VER := release-0.19
131+
SETUP_ENVTEST_VER := release-0.20
132132
SETUP_ENVTEST_BIN := setup-envtest
133133
SETUP_ENVTEST := $(abspath $(TOOLS_BIN_DIR)/$(SETUP_ENVTEST_BIN)-$(SETUP_ENVTEST_VER))
134134
SETUP_ENVTEST_PKG := sigs.k8s.io/controller-runtime/tools/setup-envtest
135135

136-
CONTROLLER_GEN_VER := v0.16.1
136+
CONTROLLER_GEN_VER := v0.17.2
137137
CONTROLLER_GEN_BIN := controller-gen
138138
CONTROLLER_GEN := $(abspath $(TOOLS_BIN_DIR)/$(CONTROLLER_GEN_BIN)-$(CONTROLLER_GEN_VER))
139139
CONTROLLER_GEN_PKG := sigs.k8s.io/controller-tools/cmd/controller-gen
@@ -143,7 +143,7 @@ GOTESTSUM_BIN := gotestsum
143143
GOTESTSUM := $(abspath $(TOOLS_BIN_DIR)/$(GOTESTSUM_BIN)-$(GOTESTSUM_VER))
144144
GOTESTSUM_PKG := gotest.tools/gotestsum
145145

146-
CONVERSION_GEN_VER := v0.31.0
146+
CONVERSION_GEN_VER := v0.32.2
147147
CONVERSION_GEN_BIN := conversion-gen
148148
# We are intentionally using the binary without version suffix, to avoid the version
149149
# in generated files.
@@ -165,12 +165,12 @@ HADOLINT_FAILURE_THRESHOLD = warning
165165

166166
SHELLCHECK_VER := v0.9.0
167167

168-
KPROMO_VER := v4.0.5
168+
KPROMO_VER := 5ab0dbc74b0228c22a93d240596dff77464aee8f
169169
KPROMO_BIN := kpromo
170170
KPROMO := $(abspath $(TOOLS_BIN_DIR)/$(KPROMO_BIN)-$(KPROMO_VER))
171171
KPROMO_PKG := sigs.k8s.io/promo-tools/v4/cmd/kpromo
172172

173-
RELEASE_NOTES_VER := v0.12.0
173+
RELEASE_NOTES_VER := v0.18.0
174174
RELEASE_NOTES_BIN := release-notes
175175
RELEASE_NOTES := $(TOOLS_BIN_DIR)/$(RELEASE_NOTES_BIN)-$(RELEASE_NOTES_VER)
176176

@@ -187,7 +187,7 @@ GINKGO_PKG := github.com/onsi/ginkgo/v2/ginkgo
187187
CONVERSION_VERIFIER_BIN := conversion-verifier
188188
CONVERSION_VERIFIER := $(abspath $(TOOLS_BIN_DIR)/$(CONVERSION_VERIFIER_BIN))
189189

190-
OPENAPI_GEN_VER := dc4e619 # main branch as of 22.04.2024
190+
OPENAPI_GEN_VER := 2c72e55 # main branch as of 03.01.2025
191191
OPENAPI_GEN_BIN := openapi-gen
192192
# We are intentionally using the binary without version suffix, to avoid the version
193193
# in generated files.

api/v1alpha1/helmchartproxy_webhook.go

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

1919
import (
20+
"context"
2021
"fmt"
2122
"net/url"
2223
"time"
@@ -35,96 +36,119 @@ import (
3536
var helmchartproxylog = logf.Log.WithName("helmchartproxy-resource")
3637

3738
func (r *HelmChartProxy) SetupWebhookWithManager(mgr ctrl.Manager) error {
39+
w := new(helmChartProxyWebhook)
40+
3841
return ctrl.NewWebhookManagedBy(mgr).
3942
For(r).
43+
WithDefaulter(w).
44+
WithValidator(w).
4045
Complete()
4146
}
4247

43-
// TODO(user): EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
44-
4548
//+kubebuilder:webhook:path=/mutate-addons-cluster-x-k8s-io-v1alpha1-helmchartproxy,mutating=true,failurePolicy=fail,sideEffects=None,groups=addons.cluster.x-k8s.io,resources=helmchartproxies,verbs=create;update,versions=v1alpha1,name=helmchartproxy.kb.io,admissionReviewVersions=v1
4649

47-
var _ webhook.Defaulter = &HelmChartProxy{}
50+
type helmChartProxyWebhook struct{}
51+
52+
var (
53+
_ webhook.CustomValidator = &helmChartProxyWebhook{}
54+
_ webhook.CustomDefaulter = &helmChartProxyWebhook{}
55+
)
4856

4957
const helmTimeout = 10 * time.Minute
5058

5159
// Default implements webhook.Defaulter so a webhook will be registered for the type.
52-
func (p *HelmChartProxy) Default() {
53-
helmchartproxylog.Info("default", "name", p.Name)
60+
func (*helmChartProxyWebhook) Default(_ context.Context, objRaw runtime.Object) error {
61+
newObj, ok := objRaw.(*HelmChartProxy)
62+
if !ok {
63+
return apierrors.NewBadRequest(fmt.Sprintf("expected a HelmChartProxy but got a %T", objRaw))
64+
}
65+
helmchartproxylog.Info("default", "name", newObj.Name)
5466

55-
if p.Spec.ReleaseNamespace == "" {
56-
p.Spec.ReleaseNamespace = "default"
67+
if newObj.Spec.ReleaseNamespace == "" {
68+
newObj.Spec.ReleaseNamespace = "default"
5769
}
5870

59-
if p.Spec.Options.Atomic {
60-
p.Spec.Options.Wait = true
71+
if newObj.Spec.Options.Atomic {
72+
newObj.Spec.Options.Wait = true
6173
}
6274

6375
// Note: timeout is also needed to ensure that Spec.Options.Wait works.
64-
if p.Spec.Options.Timeout == nil {
65-
p.Spec.Options.Timeout = &metav1.Duration{Duration: helmTimeout}
76+
if newObj.Spec.Options.Timeout == nil {
77+
newObj.Spec.Options.Timeout = &metav1.Duration{Duration: helmTimeout}
6678
}
79+
80+
return nil
6781
}
6882

69-
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
7083
//+kubebuilder:webhook:path=/validate-addons-cluster-x-k8s-io-v1alpha1-helmchartproxy,mutating=false,failurePolicy=fail,sideEffects=None,groups=addons.cluster.x-k8s.io,resources=helmchartproxies,verbs=create;update,versions=v1alpha1,name=vhelmchartproxy.kb.io,admissionReviewVersions=v1
7184

72-
var _ webhook.Validator = &HelmChartProxy{}
73-
7485
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
75-
func (p *HelmChartProxy) ValidateCreate() (admission.Warnings, error) {
76-
helmchartproxylog.Info("validate create", "name", p.Name)
86+
func (*helmChartProxyWebhook) ValidateCreate(_ context.Context, objRaw runtime.Object) (admission.Warnings, error) {
87+
newObj, ok := objRaw.(*HelmChartProxy)
88+
if !ok {
89+
return nil, apierrors.NewBadRequest(fmt.Sprintf("expected a HelmChartProxy but got a %T", objRaw))
90+
}
91+
92+
helmchartproxylog.Info("validate create", "name", newObj.Name)
7793

78-
if err := isUrlValid(p.Spec.RepoURL); err != nil {
94+
if err := isUrlValid(newObj.Spec.RepoURL); err != nil {
7995
return nil, err
8096
}
8197

8298
return nil, nil
8399
}
84100

85101
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
86-
func (p *HelmChartProxy) ValidateUpdate(oldRaw runtime.Object) (admission.Warnings, error) {
87-
helmchartproxylog.Info("validate update", "name", p.Name)
88-
102+
func (*helmChartProxyWebhook) ValidateUpdate(_ context.Context, oldRaw, newRaw runtime.Object) (admission.Warnings, error) {
89103
var allErrs field.ErrorList
90-
old, ok := oldRaw.(*HelmChartProxy)
104+
oldObj, ok := oldRaw.(*HelmChartProxy)
105+
if !ok {
106+
return nil, apierrors.NewBadRequest(fmt.Sprintf("expected a HelmChartProxy but got a %T", oldRaw))
107+
}
108+
newObj, ok := newRaw.(*HelmChartProxy)
91109
if !ok {
92-
return nil, apierrors.NewBadRequest(fmt.Sprintf("expected a HelmChartProxy but got a %T", old))
110+
return nil, apierrors.NewBadRequest(fmt.Sprintf("expected a HelmChartProxy but got a %T", newRaw))
93111
}
94112

95-
if err := isUrlValid(p.Spec.RepoURL); err != nil {
113+
helmchartproxylog.Info("validate update", "name", newObj.Name)
114+
115+
if err := isUrlValid(newObj.Spec.RepoURL); err != nil {
96116
allErrs = append(allErrs,
97117
field.Invalid(field.NewPath("spec", "RepoURL"),
98-
p.Spec.ReleaseNamespace, err.Error()),
118+
newObj.Spec.ReleaseNamespace, err.Error()),
99119
)
100120
}
101121

102-
if p.Spec.ReconcileStrategy != old.Spec.ReconcileStrategy {
122+
if newObj.Spec.ReconcileStrategy != oldObj.Spec.ReconcileStrategy {
103123
allErrs = append(allErrs,
104124
field.Invalid(field.NewPath("spec", "ReconcileStrategy"),
105-
p.Spec.ReconcileStrategy, "field is immutable"),
125+
newObj.Spec.ReconcileStrategy, "field is immutable"),
106126
)
107127
}
108128

109129
if len(allErrs) > 0 {
110-
return nil, apierrors.NewInvalid(GroupVersion.WithKind("HelmChartProxy").GroupKind(), p.Name, allErrs)
130+
return nil, apierrors.NewInvalid(GroupVersion.WithKind("HelmChartProxy").GroupKind(), newObj.Name, allErrs)
111131
}
112132

113133
return nil, nil
114134
}
115135

116136
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
117-
func (p *HelmChartProxy) ValidateDelete() (admission.Warnings, error) {
118-
helmchartproxylog.Info("validate delete", "name", p.Name)
137+
func (*helmChartProxyWebhook) ValidateDelete(_ context.Context, objRaw runtime.Object) (admission.Warnings, error) {
138+
obj, ok := objRaw.(*HelmChartProxy)
139+
if !ok {
140+
return nil, fmt.Errorf("expected a HelmChartProxy object but got %T", objRaw)
141+
}
142+
143+
helmchartproxylog.Info("validate delete", "name", obj.Name)
119144

120145
// TODO(user): fill in your validation logic upon object deletion.
121146
return nil, nil
122147
}
123148

124149
// isUrlValid returns true if specified repoURL is valid as per go doc https://pkg.go.dev/net/url#ParseRequestURI.
125150
func isUrlValid(repoURL string) error {
126-
_, err := url.ParseRequestURI(repoURL)
127-
if err != nil {
151+
if _, err := url.ParseRequestURI(repoURL); err != nil {
128152
return fmt.Errorf("specified repoURL %s is not valid: %w", repoURL, err)
129153
}
130154

api/v1alpha1/helmreleaseproxy_webhook.go

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

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

@@ -33,89 +34,113 @@ import (
3334
var helmreleaseproxylog = logf.Log.WithName("helmreleaseproxy-resource")
3435

3536
func (r *HelmReleaseProxy) SetupWebhookWithManager(mgr ctrl.Manager) error {
37+
w := new(helmReleaseProxyWebhook)
38+
3639
return ctrl.NewWebhookManagedBy(mgr).
3740
For(r).
41+
WithDefaulter(w).
42+
WithValidator(w).
3843
Complete()
3944
}
4045

41-
// TODO(user): EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
42-
4346
//+kubebuilder:webhook:path=/mutate-addons-cluster-x-k8s-io-v1alpha1-helmreleaseproxy,mutating=true,failurePolicy=fail,sideEffects=None,groups=addons.cluster.x-k8s.io,resources=helmreleaseproxies,verbs=create;update,versions=v1alpha1,name=helmreleaseproxy.kb.io,admissionReviewVersions=v1
4447

45-
var _ webhook.Defaulter = &HelmReleaseProxy{}
48+
type helmReleaseProxyWebhook struct{}
49+
50+
var (
51+
_ webhook.CustomValidator = &helmReleaseProxyWebhook{}
52+
_ webhook.CustomDefaulter = &helmReleaseProxyWebhook{}
53+
)
4654

4755
// Default implements webhook.Defaulter so a webhook will be registered for the type.
48-
func (p *HelmReleaseProxy) Default() {
49-
helmreleaseproxylog.Info("default", "name", p.Name)
56+
func (*helmReleaseProxyWebhook) Default(_ context.Context, objRaw runtime.Object) error {
57+
obj, ok := objRaw.(*HelmReleaseProxy)
58+
if !ok {
59+
return apierrors.NewBadRequest(fmt.Sprintf("expected a HelmReleaseProxy but got a %T", objRaw))
60+
}
61+
helmreleaseproxylog.Info("default", "name", obj.Name)
5062

51-
if p.Spec.ReleaseNamespace == "" {
52-
p.Spec.ReleaseNamespace = "default"
63+
if obj.Spec.ReleaseNamespace == "" {
64+
obj.Spec.ReleaseNamespace = "default"
5365
}
66+
67+
return nil
5468
}
5569

5670
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
5771
//+kubebuilder:webhook:path=/validate-addons-cluster-x-k8s-io-v1alpha1-helmreleaseproxy,mutating=false,failurePolicy=fail,sideEffects=None,groups=addons.cluster.x-k8s.io,resources=helmreleaseproxies,verbs=create;update,versions=v1alpha1,name=vhelmreleaseproxy.kb.io,admissionReviewVersions=v1
5872

59-
var _ webhook.Validator = &HelmReleaseProxy{}
60-
6173
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
62-
func (p *HelmReleaseProxy) ValidateCreate() (admission.Warnings, error) {
63-
helmreleaseproxylog.Info("validate create", "name", p.Name)
74+
func (*helmReleaseProxyWebhook) ValidateCreate(_ context.Context, objRaw runtime.Object) (admission.Warnings, error) {
75+
newObj, ok := objRaw.(*HelmReleaseProxy)
76+
if !ok {
77+
return nil, apierrors.NewBadRequest(fmt.Sprintf("expected a HelmReleaseProxy but got a %T", objRaw))
78+
}
79+
80+
helmreleaseproxylog.Info("validate create", "name", newObj.Name)
6481

6582
// TODO(user): fill in your validation logic upon object creation.
6683
return nil, nil
6784
}
6885

6986
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
70-
func (p *HelmReleaseProxy) ValidateUpdate(oldRaw runtime.Object) (admission.Warnings, error) {
71-
helmreleaseproxylog.Info("validate update", "name", p.Name)
72-
87+
func (*helmReleaseProxyWebhook) ValidateUpdate(_ context.Context, oldRaw, newRaw runtime.Object) (admission.Warnings, error) {
7388
var allErrs field.ErrorList
74-
old, ok := oldRaw.(*HelmReleaseProxy)
89+
oldObj, ok := oldRaw.(*HelmReleaseProxy)
90+
if !ok {
91+
return nil, apierrors.NewBadRequest(fmt.Sprintf("expected a HelmReleaseProxy but got a %T", oldRaw))
92+
}
93+
newObj, ok := newRaw.(*HelmReleaseProxy)
7594
if !ok {
76-
return nil, apierrors.NewBadRequest(fmt.Sprintf("expected a HelmReleaseProxy but got a %T", old))
95+
return nil, apierrors.NewBadRequest(fmt.Sprintf("expected a HelmReleaseProxy but got a %T", newRaw))
7796
}
7897

79-
if !reflect.DeepEqual(p.Spec.RepoURL, old.Spec.RepoURL) {
98+
helmreleaseproxylog.Info("validate update", "name", newObj.Name)
99+
100+
if !reflect.DeepEqual(newObj.Spec.RepoURL, oldObj.Spec.RepoURL) {
80101
allErrs = append(allErrs,
81102
field.Invalid(field.NewPath("spec", "RepoURL"),
82-
p.Spec.RepoURL, "field is immutable"),
103+
newObj.Spec.RepoURL, "field is immutable"),
83104
)
84105
}
85106

86-
if !reflect.DeepEqual(p.Spec.ChartName, old.Spec.ChartName) {
107+
if !reflect.DeepEqual(newObj.Spec.ChartName, oldObj.Spec.ChartName) {
87108
allErrs = append(allErrs,
88109
field.Invalid(field.NewPath("spec", "ChartName"),
89-
p.Spec.ChartName, "field is immutable"),
110+
newObj.Spec.ChartName, "field is immutable"),
90111
)
91112
}
92113

93-
if !reflect.DeepEqual(p.Spec.ReleaseNamespace, old.Spec.ReleaseNamespace) {
114+
if !reflect.DeepEqual(newObj.Spec.ReleaseNamespace, oldObj.Spec.ReleaseNamespace) {
94115
allErrs = append(allErrs,
95116
field.Invalid(field.NewPath("spec", "ReleaseNamespace"),
96-
p.Spec.ReleaseNamespace, "field is immutable"),
117+
newObj.Spec.ReleaseNamespace, "field is immutable"),
97118
)
98119
}
99120

100-
if p.Spec.ReconcileStrategy != old.Spec.ReconcileStrategy {
121+
if newObj.Spec.ReconcileStrategy != oldObj.Spec.ReconcileStrategy {
101122
allErrs = append(allErrs,
102123
field.Invalid(field.NewPath("spec", "ReconcileStrategy"),
103-
p.Spec.ReconcileStrategy, "field is immutable"),
124+
newObj.Spec.ReconcileStrategy, "field is immutable"),
104125
)
105126
}
106127

107128
// TODO: add webhook for ReleaseName. Currently it's being set if the release name is generated.
108129

109130
if len(allErrs) > 0 {
110-
return nil, apierrors.NewInvalid(GroupVersion.WithKind("HelmReleaseProxy").GroupKind(), p.Name, allErrs)
131+
return nil, apierrors.NewInvalid(GroupVersion.WithKind("HelmReleaseProxy").GroupKind(), newObj.Name, allErrs)
111132
}
112133

113134
return nil, nil
114135
}
115136

116137
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
117-
func (r *HelmReleaseProxy) ValidateDelete() (admission.Warnings, error) {
118-
helmreleaseproxylog.Info("validate delete", "name", r.Name)
138+
func (*helmReleaseProxyWebhook) ValidateDelete(_ context.Context, objRaw runtime.Object) (admission.Warnings, error) {
139+
obj, ok := objRaw.(*HelmReleaseProxy)
140+
if !ok {
141+
return nil, fmt.Errorf("expected a HelmReleaseProxy object but got %T", objRaw)
142+
}
143+
helmreleaseproxylog.Info("validate delete", "name", obj.Name)
119144

120145
// TODO(user): fill in your validation logic upon object deletion.
121146
return nil, nil

config/certmanager/kustomization.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
13
resources:
24
- certificate.yaml
35

0 commit comments

Comments
 (0)