Skip to content

Conversation

@robobario
Copy link
Contributor

Adds withAdditionalCustomResourceDefinition(CustomResourceDefinition definition) to LocallyRunOperatorExtension#Builder. These definitions are applied at the same time as the existing additionalCustomResourceDefinitions. The definitions are deleted according to the existing lifecycle.

Resolves #3004

Why:
In some cases we may wish to apply a CustomResourceDefinition that has no corresponding CRD file. For example, some frameworks publish fabric8-based api modules which contain only the java classes for their CRDs, and no CRD files.

Adds withAdditionalCustomResourceDefinition(CustomResourceDefinition definition) to
LocallyRunOperatorExtension#Builder. These definitions are applied at the same time
as additionalCustomResourceDefinitions. The definitions are deleted
according to the existing lifecycle.

Why:
In some cases we may wish to apply a CustomResourceDefinition that has
no corresponding CRD file. For example, some frameworks publish
fabric8-based api modules which contain only the java classes and no CRD files.

Signed-off-by: Robert Young <robertyoungnz@gmail.com>
@openshift-ci openshift-ci bot requested review from csviri and xstefank February 8, 2026 23:10
public void applyCrd(CustomResourceDefinition customResourceDefinition) {
try {
String resourceTypeName = customResourceDefinition.getMetadata().getName();
final var pathAsString = crdMappings.get(resourceTypeName);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am unsure whether this logic should be applied.

For the other mechanism withAdditionalCustomResourceDefinition(Class<? extends CustomResource> customResource) { it checks the custom crdMappings first and prefers to apply a CRD supplied there, else it looks in the standard location.

What should we do if the crdMappings contains a CRD with the same name as this CustomResourceDefinition?

Copy link
Collaborator

@csviri csviri Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO, we should check if we already applied CRD with same name, if yes throw an exception, since probably that is not what user intends. This can be a separate PR.

@csviri
Copy link
Collaborator

csviri commented Feb 9, 2026

@xstefank pls take a look also

Copy link
Collaborator

@csviri csviri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

public void applyCrd(CustomResourceDefinition customResourceDefinition) {
try {
String resourceTypeName = customResourceDefinition.getMetadata().getName();
final var pathAsString = crdMappings.get(resourceTypeName);
Copy link
Collaborator

@csviri csviri Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO, we should check if we already applied CRD with same name, if yes throw an exception, since probably that is not what user intends. This can be a separate PR.

@csviri csviri merged commit cbceae8 into operator-framework:main Feb 9, 2026
25 checks passed
@csviri
Copy link
Collaborator

csviri commented Feb 9, 2026

@robobario @xstefank if you have the bandwidth and could do the duplicate detection would be great, but mainly thank you for this PR.

@csviri
Copy link
Collaborator

csviri commented Feb 9, 2026

@robobario if that helps we can have a patch release this week for you

@robobario
Copy link
Contributor Author

thanks @csviri we have a workaround in place so there's no urgency to release, whenever suits you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LocallyRunOperatorExtension issue with loading CRD from file

3 participants