Skip to content

controller-gen v0.9.0 does not generate CRDs for additional paths #680

@sbueringer

Description

@sbueringer

The new controller-gen version only generates CRDs for the first specified path.

An example:

controller-gen-v0.9.0 \
                paths=./api/... \
                paths=./exp/api/... \
                crd:crdVersions=v1 \
                output:crd:dir=./config/crd/bases

Only CRDs from the ./api/ folder are generated/updated none of ./exp/api/... (i.e. the MachinePool CRD).

I took a closer look at the code and it looks like the metav1Pkg does not match when checking if MachinePool has ObjectMeta and TypeMeta:

if fieldPkg != metav1Pkg {

Not sure if it would be a correct fix, but by changing the line to

			if fieldPkg != nil && fieldPkg.PkgPath != metav1Pkg.PkgPath {

controller-gen was updating the MachinePool CRD again.

I think it's an additional issue, but after introducing this fix controller-gen did update the MachinePool CRD but it ignored the +kubebuilder:validation:MinLength=1 annotation (i.e. it didn't include minLength in the CRD anymore).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions