-
Notifications
You must be signed in to change notification settings - Fork 1.4k
⚠️ Add v1beta2 API for ExtensionConfig #12197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
k8s-ci-robot
merged 13 commits into
kubernetes-sigs:main
from
chrischdi:pr-extensionconfig-v1beta2
May 19, 2025
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f6485ca
Introduce ExtensionConfig v1beta2
chrischdi ff246a3
change import to v1beta2
chrischdi f90a0e5
implement conversion
chrischdi 943695e
fixup webhook
chrischdi ab29912
rename deprecated status to v1beta1
chrischdi ed71966
fixup linter
chrischdi b214359
fixup conversion tests
chrischdi 4c5aa21
remove again binary
chrischdi ceae2bb
fixup
chrischdi 95f2916
delete import restrictions for runtime v1alpha1
chrischdi b88fd90
fix
chrischdi d266169
generate
chrischdi 6f7a122
extensionconfig: fixes and revert v1beta1 related changes suited only…
chrischdi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
352 changes: 352 additions & 0 deletions
352
config/crd/bases/runtime.cluster.x-k8s.io_extensionconfigs.yaml
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# The following patch enables conversion webhook for CRD | ||
# CRD conversion requires k8s 1.13 or later. | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
name: extensionconfigs.runtime.cluster.x-k8s.io | ||
spec: | ||
conversion: | ||
strategy: Webhook | ||
webhook: | ||
conversionReviewVersions: ["v1", "v1beta1"] | ||
clientConfig: | ||
service: | ||
namespace: system | ||
name: webhook-service | ||
path: /convert |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
Copyright 2025 The Kubernetes Authors. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
apimachineryconversion "k8s.io/apimachinery/pkg/conversion" | ||
"sigs.k8s.io/controller-runtime/pkg/conversion" | ||
|
||
clusterv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1" | ||
runtimev1 "sigs.k8s.io/cluster-api/exp/runtime/api/v1beta2" | ||
) | ||
|
||
func (src *ExtensionConfig) ConvertTo(dstRaw conversion.Hub) error { | ||
dst := dstRaw.(*runtimev1.ExtensionConfig) | ||
|
||
return Convert_v1alpha1_ExtensionConfig_To_v1beta2_ExtensionConfig(src, dst, nil) | ||
} | ||
|
||
func (dst *ExtensionConfig) ConvertFrom(srcRaw conversion.Hub) error { | ||
src := srcRaw.(*runtimev1.ExtensionConfig) | ||
|
||
return Convert_v1beta2_ExtensionConfig_To_v1alpha1_ExtensionConfig(src, dst, nil) | ||
} | ||
|
||
func Convert_v1beta2_ExtensionConfigStatus_To_v1alpha1_ExtensionConfigStatus(in *runtimev1.ExtensionConfigStatus, out *ExtensionConfigStatus, s apimachineryconversion.Scope) error { | ||
if err := autoConvert_v1beta2_ExtensionConfigStatus_To_v1alpha1_ExtensionConfigStatus(in, out, s); err != nil { | ||
return err | ||
} | ||
|
||
// Reset conditions from autogenerated conversions | ||
// NOTE: v1beta2 conditions should not be automatically be converted into legacy conditions (v1beta1). | ||
out.Conditions = nil | ||
|
||
// Retrieve legacy conditions (v1beta1) from the deprecated field. | ||
if in.Deprecated != nil && in.Deprecated.V1Beta1 != nil { | ||
if in.Deprecated.V1Beta1.Conditions != nil { | ||
clusterv1beta1.Convert_v1beta2_Deprecated_V1Beta1_Conditions_To_v1beta1_Conditions(&in.Deprecated.V1Beta1.Conditions, &out.Conditions) | ||
} | ||
} | ||
|
||
// Move new conditions (v1beta2) to the v1beta2 field. | ||
if in.Conditions == nil { | ||
return nil | ||
} | ||
out.V1Beta2 = &ExtensionConfigV1Beta2Status{} | ||
out.V1Beta2.Conditions = in.Conditions | ||
return nil | ||
} | ||
|
||
func Convert_v1alpha1_ExtensionConfigStatus_To_v1beta2_ExtensionConfigStatus(in *ExtensionConfigStatus, out *runtimev1.ExtensionConfigStatus, s apimachineryconversion.Scope) error { | ||
if err := autoConvert_v1alpha1_ExtensionConfigStatus_To_v1beta2_ExtensionConfigStatus(in, out, s); err != nil { | ||
return err | ||
} | ||
|
||
// Reset conditions from autogenerated conversions | ||
// NOTE: v1beta1 conditions should not be automatically be converted into v1beta2 conditions. | ||
out.Conditions = nil | ||
|
||
// Retrieve new conditions (v1beta2) from the v1beta2 field. | ||
if in.V1Beta2 != nil { | ||
out.Conditions = in.V1Beta2.Conditions | ||
} | ||
|
||
// Move legacy conditions (v1beta1) to the deprecated field. | ||
if in.Conditions == nil { | ||
return nil | ||
} | ||
|
||
if out.Deprecated == nil { | ||
out.Deprecated = &runtimev1.ExtensionConfigDeprecatedStatus{} | ||
} | ||
if out.Deprecated.V1Beta1 == nil { | ||
out.Deprecated.V1Beta1 = &runtimev1.ExtensionConfigV1Beta1DeprecatedStatus{} | ||
} | ||
if in.Conditions != nil { | ||
clusterv1beta1.Convert_v1beta1_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(&in.Conditions, &out.Deprecated.V1Beta1.Conditions) | ||
} | ||
return nil | ||
} | ||
|
||
func Convert_v1_Condition_To_v1beta1_Condition(in *metav1.Condition, out *clusterv1beta1.Condition, s apimachineryconversion.Scope) error { | ||
return clusterv1beta1.Convert_v1_Condition_To_v1beta1_Condition(in, out, s) | ||
} | ||
|
||
func Convert_v1beta1_Condition_To_v1_Condition(in *clusterv1beta1.Condition, out *metav1.Condition, s apimachineryconversion.Scope) error { | ||
return clusterv1beta1.Convert_v1beta1_Condition_To_v1_Condition(in, out, s) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
//go:build !race | ||
|
||
/* | ||
Copyright 2025 The Kubernetes Authors. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
fuzz "github.com/google/gofuzz" | ||
"k8s.io/apimachinery/pkg/api/apitesting/fuzzer" | ||
runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" | ||
|
||
runtimev1 "sigs.k8s.io/cluster-api/exp/runtime/api/v1beta2" | ||
utilconversion "sigs.k8s.io/cluster-api/util/conversion" | ||
) | ||
|
||
// Test is disabled when the race detector is enabled (via "//go:build !race" above) because otherwise the fuzz tests would just time out. | ||
|
||
func TestFuzzyConversion(t *testing.T) { | ||
t.Run("for ExtensionConfig", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ | ||
Hub: &runtimev1.ExtensionConfig{}, | ||
Spoke: &ExtensionConfig{}, | ||
FuzzerFuncs: []fuzzer.FuzzerFuncs{ExtensionConfigFuzzFuncs}, | ||
})) | ||
} | ||
|
||
func ExtensionConfigFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { | ||
return []interface{}{ | ||
hubExtensionConfigStatus, | ||
spokeExtensionConfigStatus, | ||
} | ||
} | ||
|
||
func hubExtensionConfigStatus(in *runtimev1.ExtensionConfigStatus, c fuzz.Continue) { | ||
c.FuzzNoCustom(in) | ||
// Drop empty structs with only omit empty fields. | ||
if in.Deprecated != nil { | ||
if in.Deprecated.V1Beta1 == nil || reflect.DeepEqual(in.Deprecated.V1Beta1, &runtimev1.ExtensionConfigV1Beta1DeprecatedStatus{}) { | ||
in.Deprecated = nil | ||
} | ||
} | ||
} | ||
|
||
func spokeExtensionConfigStatus(in *ExtensionConfigStatus, c fuzz.Continue) { | ||
c.FuzzNoCustom(in) | ||
// Drop empty structs with only omit empty fields. | ||
if in.V1Beta2 != nil { | ||
if reflect.DeepEqual(in.V1Beta2, &ExtensionConfigV1Beta2Status{}) { | ||
in.V1Beta2 = nil | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.