Skip to content

Commit f6485ca

Browse files
committed
Introduce ExtensionConfig v1beta2
1 parent 6eabd27 commit f6485ca

18 files changed

+1463
-6
lines changed

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,12 @@ generate-go-conversions-core-runtime: $(CONVERSION_GEN) ## Generate conversions
494494
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt \
495495
./internal/runtime/test/v1alpha1 \
496496
./internal/runtime/test/v1alpha2
497+
$(MAKE) clean-generated-conversions SRC_DIRS="./$(EXP_DIR)/runtime/api/v1alpha1,./$(EXP_DIR)/runtime/api/v1beta2"
498+
$(CONVERSION_GEN) \
499+
--output-file=zz_generated.conversion.go \
500+
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt \
501+
./$(EXP_DIR)/runtime/api/v1alpha1 \
502+
./$(EXP_DIR)/runtime/api/v1beta2
497503

498504
.PHONY: generate-go-conversions-kubeadm-bootstrap
499505
generate-go-conversions-kubeadm-bootstrap: $(CONVERSION_GEN) ## Generate conversions go code for kubeadm bootstrap

config/crd/bases/runtime.cluster.x-k8s.io_extensionconfigs.yaml

Lines changed: 341 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/kustomization.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ patches:
3232
- path: patches/webhook_in_clusterresourcesetbindings.yaml
3333
- path: patches/webhook_in_ipaddresses.yaml
3434
- path: patches/webhook_in_ipaddressclaims.yaml
35+
- path: patches/webhook_in_extensionconfigs.yaml
3536
# +kubebuilder:scaffold:crdkustomizewebhookpatch
3637

3738
# the following config is for teaching kustomize how to do kustomization for CRDs.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# The following patch enables conversion webhook for CRD
2+
# CRD conversion requires k8s 1.13 or later.
3+
apiVersion: apiextensions.k8s.io/v1
4+
kind: CustomResourceDefinition
5+
metadata:
6+
name: extensionconfigs.runtime.cluster.x-k8s.io
7+
spec:
8+
conversion:
9+
strategy: Webhook
10+
webhook:
11+
conversionReviewVersions: ["v1", "v1beta1"]
12+
clientConfig:
13+
service:
14+
namespace: system
15+
name: webhook-service
16+
path: /convert

config/default/kustomization.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ replacements:
5757
delimiter: /
5858
select:
5959
kind: CustomResourceDefinition
60-
reject:
61-
- name: extensionconfigs.runtime.cluster.x-k8s.io
6260
- source:
6361
fieldPath: .metadata.name
6462
group: cert-manager.io
@@ -90,8 +88,6 @@ replacements:
9088
index: 1
9189
select:
9290
kind: CustomResourceDefinition
93-
reject:
94-
- name: extensionconfigs.runtime.cluster.x-k8s.io
9591
- source:
9692
fieldPath: .metadata.name
9793
kind: Service
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
Copyright 2025 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
import (
20+
"sigs.k8s.io/controller-runtime/pkg/conversion"
21+
22+
runtimev1 "sigs.k8s.io/cluster-api/exp/runtime/api/v1beta2"
23+
)
24+
25+
func (src *ExtensionConfig) ConvertTo(dstRaw conversion.Hub) error {
26+
dst := dstRaw.(*runtimev1.ExtensionConfig)
27+
28+
return Convert_v1alpha1_ExtensionConfig_To_v1beta2_ExtensionConfig(src, dst, nil)
29+
}
30+
31+
func (dst *ExtensionConfig) ConvertFrom(srcRaw conversion.Hub) error {
32+
src := srcRaw.(*runtimev1.ExtensionConfig)
33+
34+
return Convert_v1beta2_ExtensionConfig_To_v1alpha1_ExtensionConfig(src, dst, nil)
35+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//go:build !race
2+
3+
/*
4+
Copyright 2025 The Kubernetes Authors.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
18+
19+
package v1alpha1
20+
21+
import (
22+
"testing"
23+
24+
"k8s.io/apimachinery/pkg/api/apitesting/fuzzer"
25+
runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer"
26+
27+
runtimev1 "sigs.k8s.io/cluster-api/exp/runtime/api/v1beta2"
28+
utilconversion "sigs.k8s.io/cluster-api/util/conversion"
29+
)
30+
31+
// Test is disabled when the race detector is enabled (via "//go:build !race" above) because otherwise the fuzz tests would just time out.
32+
33+
func TestFuzzyConversion(t *testing.T) {
34+
t.Run("for ExtensionConfig", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{
35+
Hub: &runtimev1.ExtensionConfig{},
36+
Spoke: &ExtensionConfig{},
37+
FuzzerFuncs: []fuzzer.FuzzerFuncs{ExtensionConfigFuzzFuncs},
38+
}))
39+
}
40+
41+
func ExtensionConfigFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} {
42+
return []interface{}{}
43+
}

exp/runtime/api/v1alpha1/doc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ limitations under the License.
1515
*/
1616

1717
// Package v1alpha1 contains the v1alpha1 implementation of ExtensionConfig.
18+
// +k8s:conversion-gen=sigs.k8s.io/cluster-api/exp/runtime/api/v1beta2
1819
package v1alpha1

exp/runtime/api/v1alpha1/extensionconfig_types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ const (
203203
// +kubebuilder:object:root=true
204204
// +kubebuilder:resource:path=extensionconfigs,shortName=ext,scope=Cluster,categories=cluster-api
205205
// +kubebuilder:subresource:status
206-
// +kubebuilder:storageversion
207206
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of ExtensionConfig"
208207

209208
// ExtensionConfig is the Schema for the ExtensionConfig API.

exp/runtime/api/v1alpha1/groupversion_info.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ var (
3535
// AddToScheme adds the types in this group-version to the given scheme.
3636
AddToScheme = schemeBuilder.AddToScheme
3737

38+
// localSchemeBuilder is used for type conversions.
39+
localSchemeBuilder = schemeBuilder
40+
3841
objectTypes = []runtime.Object{}
3942
)
4043

0 commit comments

Comments
 (0)