Skip to content

controller-gen does not deduplicate/flatten MinProperties with embedded struct #1234

@sbueringer

Description

@sbueringer

controller-gen doesn't deduplicate/flatten MinProperties if a struct is embedded in a struct and both have MinProperties set.

Example

// +kubebuilder:validation:MinProperties=1
type MachineHealthCheckTopology struct {
	// +optional
	Enable *bool `json:"enable,omitempty"`

	MachineHealthCheckClass `json:",inline"`
}

// +kubebuilder:validation:MinProperties=1
type MachineHealthCheckClass struct {
	UnhealthyNodeConditions []UnhealthyNodeCondition `json:"unhealthyNodeConditions,omitempty"`
...
}

Resulting CRD YAML:

                      machineHealthCheck:
                        allOf:
                        - minProperties: 1
                        - minProperties: 1

(The resulting CRD YAML is valid and works, would be just better if we would deduplicate like in other cases)

Metadata

Metadata

Assignees

No one assigned

    Labels

    lifecycle/frozenIndicates that an issue or PR should not be auto-closed due to staleness.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions