Skip to content

Commit 448e8e0

Browse files
committed
Rename runtime extension fields in ClusterClass ExternalPatchDefinition
Signed-off-by: Stefan Büringer [email protected]
1 parent 70d67eb commit 448e8e0

File tree

15 files changed

+123
-75
lines changed

15 files changed

+123
-75
lines changed

api/core/v1beta1/conversion.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,3 +884,23 @@ func Convert_v1beta1_MachinePoolStatus_To_v1beta2_MachinePoolStatus(in *MachineP
884884
func Convert_v1beta1_MachinePoolSpec_To_v1beta2_MachinePoolSpec(in *MachinePoolSpec, out *clusterv1.MachinePoolSpec, s apimachineryconversion.Scope) error {
885885
return autoConvert_v1beta1_MachinePoolSpec_To_v1beta2_MachinePoolSpec(in, out, s)
886886
}
887+
888+
func Convert_v1beta1_ExternalPatchDefinition_To_v1beta2_ExternalPatchDefinition(in *ExternalPatchDefinition, out *clusterv1.ExternalPatchDefinition, s apimachineryconversion.Scope) error {
889+
if err := autoConvert_v1beta1_ExternalPatchDefinition_To_v1beta2_ExternalPatchDefinition(in, out, s); err != nil {
890+
return err
891+
}
892+
893+
out.GeneratePatchesExtension = in.GenerateExtension
894+
out.ValidateTopologyExtension = in.ValidateExtension
895+
return nil
896+
}
897+
898+
func Convert_v1beta2_ExternalPatchDefinition_To_v1beta1_ExternalPatchDefinition(in *clusterv1.ExternalPatchDefinition, out *ExternalPatchDefinition, s apimachineryconversion.Scope) error {
899+
if err := autoConvert_v1beta2_ExternalPatchDefinition_To_v1beta1_ExternalPatchDefinition(in, out, s); err != nil {
900+
return err
901+
}
902+
903+
out.GenerateExtension = in.GeneratePatchesExtension
904+
out.ValidateExtension = in.ValidateTopologyExtension
905+
return nil
906+
}

api/core/v1beta1/zz_generated.conversion.go

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

api/core/v1beta2/clusterclass_types.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,19 +1104,19 @@ type JSONPatchValue struct {
11041104
}
11051105

11061106
// ExternalPatchDefinition defines an external patch.
1107-
// Note: At least one of GenerateExtension or ValidateExtension must be set.
1107+
// Note: At least one of GeneratePatchesExtension or ValidateTopologyExtension must be set.
11081108
type ExternalPatchDefinition struct {
1109-
// generateExtension references an extension which is called to generate patches.
1109+
// generatePatchesExtension references an extension which is called to generate patches.
11101110
// +optional
11111111
// +kubebuilder:validation:MinLength=1
11121112
// +kubebuilder:validation:MaxLength=512
1113-
GenerateExtension *string `json:"generateExtension,omitempty"`
1113+
GeneratePatchesExtension *string `json:"generatePatchesExtension,omitempty"`
11141114

1115-
// validateExtension references an extension which is called to validate the topology.
1115+
// validateTopologyExtension references an extension which is called to validate the topology.
11161116
// +optional
11171117
// +kubebuilder:validation:MinLength=1
11181118
// +kubebuilder:validation:MaxLength=512
1119-
ValidateExtension *string `json:"validateExtension,omitempty"`
1119+
ValidateTopologyExtension *string `json:"validateTopologyExtension,omitempty"`
11201120

11211121
// discoverVariablesExtension references an extension which is called to discover variables.
11221122
// +optional

api/core/v1beta2/zz_generated.deepcopy.go

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

api/core/v1beta2/zz_generated.openapi.go

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

config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml

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

docs/book/src/developer/providers/migrations/v1.10-to-v1.11.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ proposal because most of the changes described below are a consequence of the wo
163163
### ClusterClass
164164

165165
- See changes that apply to [all CRDs](#all-crds)
166+
- The `spec.patches[].external.generateExtension` and `spec.patches[].external.validateExtension` fields have been renamed to
167+
`spec.patches[].external.generatePatchesExtension` and `spec.patches[].external.validateTopologyExtension`
166168
- The `unhealthyConditions` field has been renamed to `unhealthyNodeConditions` in following struct:
167169
- `spec.controlPlane.machineHealthCheck`
168170
- `spec.workers.machineDeployments[].machineHealthCheck`

internal/controllers/topology/cluster/patches/engine.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func (e *engine) Apply(ctx context.Context, blueprint *scope.ClusterBlueprint, d
124124
for i := range blueprint.ClusterClass.Spec.Patches {
125125
clusterClassPatch := blueprint.ClusterClass.Spec.Patches[i]
126126

127-
if clusterClassPatch.External == nil || clusterClassPatch.External.ValidateExtension == nil {
127+
if clusterClassPatch.External == nil || clusterClassPatch.External.ValidateTopologyExtension == nil {
128128
continue
129129
}
130130

@@ -408,7 +408,7 @@ func createPatchGenerator(runtimeClient runtimeclient.Client, patch *clusterv1.C
408408
return inline.NewGenerator(patch), nil
409409
}
410410
// Return an externalPatchGenerator if there is an external configuration in the patch.
411-
if patch.External != nil && patch.External.GenerateExtension != nil {
411+
if patch.External != nil && patch.External.GeneratePatchesExtension != nil {
412412
if !feature.Gates.Enabled(feature.RuntimeSDK) {
413413
return nil, errors.Errorf("can not use external patch %q if RuntimeSDK feature flag is disabled", patch.Name)
414414
}

internal/controllers/topology/cluster/patches/engine_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,8 @@ func TestApply(t *testing.T) {
407407
{
408408
Name: "fake-patch1",
409409
External: &clusterv1.ExternalPatchDefinition{
410-
GenerateExtension: ptr.To("patch-infrastructureCluster"),
411-
ValidateExtension: ptr.To("validate-infrastructureCluster"),
410+
GeneratePatchesExtension: ptr.To("patch-infrastructureCluster"),
411+
ValidateTopologyExtension: ptr.To("validate-infrastructureCluster"),
412412
},
413413
},
414414
},
@@ -444,8 +444,8 @@ func TestApply(t *testing.T) {
444444
{
445445
Name: "fake-patch1",
446446
External: &clusterv1.ExternalPatchDefinition{
447-
GenerateExtension: ptr.To("patch-infrastructureCluster"),
448-
ValidateExtension: ptr.To("validate-infrastructureCluster"),
447+
GeneratePatchesExtension: ptr.To("patch-infrastructureCluster"),
448+
ValidateTopologyExtension: ptr.To("validate-infrastructureCluster"),
449449
},
450450
},
451451
},
@@ -478,13 +478,13 @@ func TestApply(t *testing.T) {
478478
{
479479
Name: "fake-patch1",
480480
External: &clusterv1.ExternalPatchDefinition{
481-
GenerateExtension: ptr.To("patch-infrastructureCluster"),
481+
GeneratePatchesExtension: ptr.To("patch-infrastructureCluster"),
482482
},
483483
},
484484
{
485485
Name: "fake-patch2",
486486
External: &clusterv1.ExternalPatchDefinition{
487-
GenerateExtension: ptr.To("patch-controlPlane"),
487+
GeneratePatchesExtension: ptr.To("patch-controlPlane"),
488488
},
489489
},
490490
},

internal/controllers/topology/cluster/patches/external/external_patch_generator.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func NewGenerator(runtimeClient runtimeclient.Client, patch *clusterv1.ClusterCl
4646

4747
func (e externalPatchGenerator) Generate(ctx context.Context, forObject client.Object, req *runtimehooksv1.GeneratePatchesRequest) (*runtimehooksv1.GeneratePatchesResponse, error) {
4848
if !feature.Gates.Enabled(feature.RuntimeSDK) {
49-
return nil, errors.Errorf("can not use external patch %q if RuntimeSDK feature flag is disabled", *e.patch.External.GenerateExtension)
49+
return nil, errors.Errorf("can not use external patch %q if RuntimeSDK feature flag is disabled", *e.patch.External.GeneratePatchesExtension)
5050
}
5151

5252
// Set the settings defined in external patch definition on the request object.
@@ -59,7 +59,7 @@ func (e externalPatchGenerator) Generate(ctx context.Context, forObject client.O
5959
}()
6060

6161
resp := &runtimehooksv1.GeneratePatchesResponse{}
62-
err := e.runtimeClient.CallExtension(ctx, runtimehooksv1.GeneratePatches, forObject, *e.patch.External.GenerateExtension, req, resp)
62+
err := e.runtimeClient.CallExtension(ctx, runtimehooksv1.GeneratePatches, forObject, *e.patch.External.GeneratePatchesExtension, req, resp)
6363
if err != nil {
6464
return nil, err
6565
}

internal/controllers/topology/cluster/patches/external/external_patch_generator_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ func TestExternalPatchGenerator_Generate(t *testing.T) {
5353
EnabledIf: nil,
5454
Definitions: nil,
5555
External: &clusterv1.ExternalPatchDefinition{
56-
GenerateExtension: ptr.To("test-generate-extension"),
57-
Settings: nil,
56+
GeneratePatchesExtension: ptr.To("test-generate-extension"),
57+
Settings: nil,
5858
},
5959
},
6060
request: &runtimehooksv1.GeneratePatchesRequest{},
@@ -72,7 +72,7 @@ func TestExternalPatchGenerator_Generate(t *testing.T) {
7272
EnabledIf: nil,
7373
Definitions: nil,
7474
External: &clusterv1.ExternalPatchDefinition{
75-
GenerateExtension: ptr.To("test-generate-extension"),
75+
GeneratePatchesExtension: ptr.To("test-generate-extension"),
7676
Settings: map[string]string{
7777
"key1": "value1",
7878
},

internal/controllers/topology/cluster/patches/external/external_validator.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func NewValidator(runtimeClient runtimeclient.Client, patch *clusterv1.ClusterCl
4646

4747
func (e externalValidator) Validate(ctx context.Context, forObject client.Object, req *runtimehooksv1.ValidateTopologyRequest) (*runtimehooksv1.ValidateTopologyResponse, error) {
4848
if !feature.Gates.Enabled(feature.RuntimeSDK) {
49-
return nil, errors.Errorf("can not use external patch %q if RuntimeSDK feature flag is disabled", *e.patch.External.ValidateExtension)
49+
return nil, errors.Errorf("can not use external patch %q if RuntimeSDK feature flag is disabled", *e.patch.External.ValidateTopologyExtension)
5050
}
5151

5252
// Set the settings defined in external patch definition on the request object.
@@ -59,7 +59,7 @@ func (e externalValidator) Validate(ctx context.Context, forObject client.Object
5959
}()
6060

6161
resp := &runtimehooksv1.ValidateTopologyResponse{}
62-
err := e.runtimeClient.CallExtension(ctx, runtimehooksv1.ValidateTopology, forObject, *e.patch.External.ValidateExtension, req, resp)
62+
err := e.runtimeClient.CallExtension(ctx, runtimehooksv1.ValidateTopology, forObject, *e.patch.External.ValidateTopologyExtension, req, resp)
6363
if err != nil {
6464
return nil, err
6565
}

0 commit comments

Comments
 (0)