Skip to content

Commit 03babad

Browse files
committed
fix: allow keeping deleted CRDs in test with configuration
Signed-off-by: xstefank <[email protected]>
1 parent f5f0a60 commit 03babad

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

+6-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ public class LocallyRunOperatorExtension extends AbstractOperatorExtension {
4343

4444
private static final Logger LOGGER = LoggerFactory.getLogger(LocallyRunOperatorExtension.class);
4545
private static final int CRD_DELETE_TIMEOUT = 1000;
46+
private static final LinkedList<AppliedCRD> appliedCRDs = new LinkedList<>();
47+
private static final boolean deleteCRDs = Boolean.parseBoolean(System.getProperty("testsuite.deleteCRDs", "true"));
4648

4749
private final Operator operator;
4850
private final List<ReconcilerSpec> reconcilers;
@@ -51,7 +53,6 @@ public class LocallyRunOperatorExtension extends AbstractOperatorExtension {
5153
private final List<Class<? extends CustomResource>> additionalCustomResourceDefinitions;
5254
private final Map<Reconciler, RegisteredController> registeredControllers;
5355
private final Map<String, String> crdMappings;
54-
private static final LinkedList<AppliedCRD> appliedCRDs = new LinkedList<>();
5556

5657
private LocallyRunOperatorExtension(
5758
List<ReconcilerSpec> reconcilers,
@@ -320,6 +321,10 @@ protected void after(ExtensionContext context) {
320321
}
321322

322323
private void deleteCrd(AppliedCRD appliedCRD, KubernetesClient client) {
324+
if (!deleteCRDs) {
325+
LOGGER.debug("Skipping deleting CRD because of configuration: {}", appliedCRD);
326+
return;
327+
}
323328
try {
324329
LOGGER.debug("Deleting CRD: {}", appliedCRD.crdString);
325330
final var crd = client.load(new ByteArrayInputStream(appliedCRD.crdString.getBytes()));

0 commit comments

Comments
 (0)