Skip to content

⚠️ Rename runtime extension fields in ClusterClass ExternalPatchDefinition #12281

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions api/core/v1beta1/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -912,3 +912,23 @@ func Convert_v1beta2_ClusterClassVariable_To_v1beta1_ClusterClassVariable(in *cl
}
return autoConvert_v1beta2_ClusterClassVariableMetadata_To_v1beta1_ClusterClassVariableMetadata(&in.DeprecatedV1Beta1Metadata, &out.Metadata, s)
}

func Convert_v1beta1_ExternalPatchDefinition_To_v1beta2_ExternalPatchDefinition(in *ExternalPatchDefinition, out *clusterv1.ExternalPatchDefinition, s apimachineryconversion.Scope) error {
if err := autoConvert_v1beta1_ExternalPatchDefinition_To_v1beta2_ExternalPatchDefinition(in, out, s); err != nil {
return err
}

out.GeneratePatchesExtension = in.GenerateExtension
out.ValidateTopologyExtension = in.ValidateExtension
return nil
}

func Convert_v1beta2_ExternalPatchDefinition_To_v1beta1_ExternalPatchDefinition(in *clusterv1.ExternalPatchDefinition, out *ExternalPatchDefinition, s apimachineryconversion.Scope) error {
if err := autoConvert_v1beta2_ExternalPatchDefinition_To_v1beta1_ExternalPatchDefinition(in, out, s); err != nil {
return err
}

out.GenerateExtension = in.GeneratePatchesExtension
out.ValidateExtension = in.ValidateTopologyExtension
return nil
}
82 changes: 54 additions & 28 deletions api/core/v1beta1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions api/core/v1beta2/clusterclass_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1104,19 +1104,19 @@ type JSONPatchValue struct {
}

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

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

// discoverVariablesExtension references an extension which is called to discover variables.
// +optional
Expand Down
8 changes: 4 additions & 4 deletions api/core/v1beta2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions api/core/v1beta2/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ proposal because most of the changes described below are a consequence of the wo
### ClusterClass

- See changes that apply to [all CRDs](#all-crds)
- The `spec.patches[].external.generateExtension` and `spec.patches[].external.validateExtension` fields have been renamed to
`spec.patches[].external.generatePatchesExtension` and `spec.patches[].external.validateTopologyExtension`
- The `unhealthyConditions` field has been renamed to `unhealthyNodeConditions` in following struct:
- `spec.controlPlane.machineHealthCheck`
- `spec.workers.machineDeployments[].machineHealthCheck`
Expand Down
4 changes: 2 additions & 2 deletions internal/controllers/topology/cluster/patches/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (e *engine) Apply(ctx context.Context, blueprint *scope.ClusterBlueprint, d
for i := range blueprint.ClusterClass.Spec.Patches {
clusterClassPatch := blueprint.ClusterClass.Spec.Patches[i]

if clusterClassPatch.External == nil || clusterClassPatch.External.ValidateExtension == nil {
if clusterClassPatch.External == nil || clusterClassPatch.External.ValidateTopologyExtension == nil {
continue
}

Expand Down Expand Up @@ -408,7 +408,7 @@ func createPatchGenerator(runtimeClient runtimeclient.Client, patch *clusterv1.C
return inline.NewGenerator(patch), nil
}
// Return an externalPatchGenerator if there is an external configuration in the patch.
if patch.External != nil && patch.External.GenerateExtension != nil {
if patch.External != nil && patch.External.GeneratePatchesExtension != nil {
if !feature.Gates.Enabled(feature.RuntimeSDK) {
return nil, errors.Errorf("can not use external patch %q if RuntimeSDK feature flag is disabled", patch.Name)
}
Expand Down
12 changes: 6 additions & 6 deletions internal/controllers/topology/cluster/patches/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,8 @@ func TestApply(t *testing.T) {
{
Name: "fake-patch1",
External: &clusterv1.ExternalPatchDefinition{
GenerateExtension: ptr.To("patch-infrastructureCluster"),
ValidateExtension: ptr.To("validate-infrastructureCluster"),
GeneratePatchesExtension: ptr.To("patch-infrastructureCluster"),
ValidateTopologyExtension: ptr.To("validate-infrastructureCluster"),
},
},
},
Expand Down Expand Up @@ -444,8 +444,8 @@ func TestApply(t *testing.T) {
{
Name: "fake-patch1",
External: &clusterv1.ExternalPatchDefinition{
GenerateExtension: ptr.To("patch-infrastructureCluster"),
ValidateExtension: ptr.To("validate-infrastructureCluster"),
GeneratePatchesExtension: ptr.To("patch-infrastructureCluster"),
ValidateTopologyExtension: ptr.To("validate-infrastructureCluster"),
},
},
},
Expand Down Expand Up @@ -478,13 +478,13 @@ func TestApply(t *testing.T) {
{
Name: "fake-patch1",
External: &clusterv1.ExternalPatchDefinition{
GenerateExtension: ptr.To("patch-infrastructureCluster"),
GeneratePatchesExtension: ptr.To("patch-infrastructureCluster"),
},
},
{
Name: "fake-patch2",
External: &clusterv1.ExternalPatchDefinition{
GenerateExtension: ptr.To("patch-controlPlane"),
GeneratePatchesExtension: ptr.To("patch-controlPlane"),
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func NewGenerator(runtimeClient runtimeclient.Client, patch *clusterv1.ClusterCl

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

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

resp := &runtimehooksv1.GeneratePatchesResponse{}
err := e.runtimeClient.CallExtension(ctx, runtimehooksv1.GeneratePatches, forObject, *e.patch.External.GenerateExtension, req, resp)
err := e.runtimeClient.CallExtension(ctx, runtimehooksv1.GeneratePatches, forObject, *e.patch.External.GeneratePatchesExtension, req, resp)
if err != nil {
return nil, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ func TestExternalPatchGenerator_Generate(t *testing.T) {
EnabledIf: nil,
Definitions: nil,
External: &clusterv1.ExternalPatchDefinition{
GenerateExtension: ptr.To("test-generate-extension"),
Settings: nil,
GeneratePatchesExtension: ptr.To("test-generate-extension"),
Settings: nil,
},
},
request: &runtimehooksv1.GeneratePatchesRequest{},
Expand All @@ -72,7 +72,7 @@ func TestExternalPatchGenerator_Generate(t *testing.T) {
EnabledIf: nil,
Definitions: nil,
External: &clusterv1.ExternalPatchDefinition{
GenerateExtension: ptr.To("test-generate-extension"),
GeneratePatchesExtension: ptr.To("test-generate-extension"),
Settings: map[string]string{
"key1": "value1",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func NewValidator(runtimeClient runtimeclient.Client, patch *clusterv1.ClusterCl

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

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

resp := &runtimehooksv1.ValidateTopologyResponse{}
err := e.runtimeClient.CallExtension(ctx, runtimehooksv1.ValidateTopology, forObject, *e.patch.External.ValidateExtension, req, resp)
err := e.runtimeClient.CallExtension(ctx, runtimehooksv1.ValidateTopology, forObject, *e.patch.External.ValidateTopologyExtension, req, resp)
if err != nil {
return nil, err
}
Expand Down
Loading
Loading