Skip to content

Commit

Permalink
wip: add more logging
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Laprun <[email protected]>
  • Loading branch information
metacosm committed Jan 8, 2025
1 parent c9063d9 commit f122de8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,13 @@ public void applyCrd(Class<? extends CustomResource> crClass) {
*/
public void applyCrd(String resourceTypeName) {
// first attempt to use a manually defined CRD
final var path = crdMappings.get(resourceTypeName);
if (path != null) {
final var pathAsString = crdMappings.get(resourceTypeName);
if (pathAsString != null) {
final var path = Path.of(pathAsString);
try {
applyCrd(Files.readString(Path.of(path)), path, getKubernetesClient());
applyCrd(Files.readString(path), pathAsString, getKubernetesClient());
} catch (IOException e) {
throw new IllegalStateException("Cannot open CRD file at " + path, e);
throw new IllegalStateException("Cannot open CRD file at " + path.toAbsolutePath(), e);
}
} else {
// if no manually defined CRD matches the resource type, apply the generated one
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.javaoperatorsdk.operator.junit;

import java.nio.file.Path;
import java.util.List;

import org.junit.jupiter.api.Test;
Expand All @@ -12,6 +13,8 @@ class LocallyRunOperatorExtensionTest {

@Test
void getAdditionalCRDsFromFiles() {
System.out.println(Path.of("").toAbsolutePath());
System.out.println(Path.of("src/test/crd/test.crd").toAbsolutePath());
final var crds = LocallyRunOperatorExtension.getAdditionalCRDsFromFiles(
List.of("src/test/resources/crd/test.crd", "src/test/crd/test.crd"),
new KubernetesClientBuilder().build());
Expand Down
16 changes: 16 additions & 0 deletions operator-framework-junit5/src/test/resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration name="TestConfig" status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d %threadId %-30c{1.} [%-5level] %msg%n%throwable"/>
</Console>
</Appenders>
<Loggers>
<Logger level="debug" name="io.javaoperatorsdk.operator" additivity="false">
<AppenderRef ref="Console"/>
</Logger>
<Root level="info">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>

0 comments on commit f122de8

Please sign in to comment.