Skip to content

Commit b8b3fb7

Browse files
committed
fix: make sure generated CRDs are applied
Signed-off-by: Chris Laprun <[email protected]>
1 parent 73c03ed commit b8b3fb7

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

operator-framework-junit5/src/main/java/io/javaoperatorsdk/operator/junit/LocallyRunOperatorExtension.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ public void applyCrd(String resourceTypeName) {
186186
} catch (IOException e) {
187187
throw new IllegalStateException("Cannot open CRD file at " + path.toAbsolutePath(), e);
188188
}
189+
crdMappings.remove(resourceTypeName);
189190
} else {
190191
// if no manually defined CRD matches the resource type, apply the generated one
191192
applyCrd(resourceTypeName, getKubernetesClient());
@@ -263,10 +264,7 @@ protected void before(ExtensionContext context) {
263264
final var resourceTypeName = ReconcilerUtils.getResourceTypeName(resourceClass);
264265
// only try to apply a CRD for the reconciler if it is associated to a CR
265266
if (CustomResource.class.isAssignableFrom(resourceClass)) {
266-
if (crdMappings.get(resourceTypeName) != null) {
267-
applyCrd(resourceTypeName);
268-
crdMappings.remove(resourceTypeName);
269-
}
267+
applyCrd(resourceTypeName);
270268
}
271269

272270
// apply yet unapplied CRDs
@@ -282,6 +280,7 @@ protected void before(ExtensionContext context) {
282280
}
283281
applyCrd(crdString, path, getKubernetesClient());
284282
});
283+
crdMappings.clear();
285284

286285
LOGGER.debug("Starting the operator locally");
287286
this.operator.start();

0 commit comments

Comments
 (0)