Skip to content

Commit ad9cb00

Browse files
committed
improve: add meta-inf to run processor
This commit also adds an example sample annotation to the CRDMappingInTestExtensionIT class to test the sample annotation processor.
1 parent 7e9be4a commit ad9cb00

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
io.javaoperatorsdk.processor.SampleProcessor

operator-framework/pom.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@
8484
<artifactId>kube-api-test-client-inject</artifactId>
8585
<scope>test</scope>
8686
</dependency>
87+
<dependency>
88+
<groupId>io.javaoperatorsdk</groupId>
89+
<artifactId>operator-annotations</artifactId>
90+
<version>5.1.3-SNAPSHOT</version>
91+
<scope>test</scope>
92+
</dependency>
8793
</dependencies>
8894

8995
<build>
@@ -106,6 +112,26 @@
106112
</compilerArgs>
107113
</configuration>
108114
</execution>
115+
<!-- During test compilation we need to enable the annotation processors -->
116+
<execution>
117+
<id>default-testCompile</id>
118+
<goals>
119+
<goal>testCompile</goal>
120+
</goals>
121+
<phase>test-compile</phase>
122+
<configuration>
123+
<annotationProcessorPaths>
124+
<path>
125+
<groupId>io.javaoperatorsdk</groupId>
126+
<artifactId>operator-annotations</artifactId>
127+
<version>${project.version}</version>
128+
</path>
129+
</annotationProcessorPaths>
130+
<compilerArgs>
131+
<arg>-proc:full</arg>
132+
</compilerArgs>
133+
</configuration>
134+
</execution>
109135
</executions>
110136
</plugin>
111137
<plugin>

operator-framework/src/test/java/io/javaoperatorsdk/operator/CRDMappingInTestExtensionIT.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import io.fabric8.kubernetes.model.annotation.Group;
1313
import io.fabric8.kubernetes.model.annotation.Kind;
1414
import io.fabric8.kubernetes.model.annotation.Version;
15+
import io.javaoperatorsdk.annotation.Sample;
1516
import io.javaoperatorsdk.operator.api.reconciler.Context;
1617
import io.javaoperatorsdk.operator.api.reconciler.ControllerConfiguration;
1718
import io.javaoperatorsdk.operator.api.reconciler.Reconciler;
@@ -21,6 +22,12 @@
2122
import static org.assertj.core.api.Assertions.assertThat;
2223
import static org.awaitility.Awaitility.await;
2324

25+
@Sample(
26+
tldr = "Shows how to use the test extension to load CRDs from files.",
27+
description =
28+
"Shows how to use the test extension to load CRDs from files. This is useful when you want"
29+
+ " to test your operator with real CRDs, for example when you want to test validation"
30+
+ " or defaulting.")
2431
public class CRDMappingInTestExtensionIT {
2532
private final KubernetesClient client = new KubernetesClientBuilder().build();
2633

operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/changenamespace/ChangeNamespaceIT.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,20 @@
1414
import io.fabric8.kubernetes.api.model.NamespaceBuilder;
1515
import io.fabric8.kubernetes.api.model.ObjectMetaBuilder;
1616
import io.fabric8.kubernetes.client.KubernetesClient;
17+
import io.javaoperatorsdk.annotation.Sample;
1718
import io.javaoperatorsdk.operator.RegisteredController;
1819
import io.javaoperatorsdk.operator.api.reconciler.Constants;
1920
import io.javaoperatorsdk.operator.junit.LocallyRunOperatorExtension;
2021

2122
import static org.assertj.core.api.Assertions.assertThat;
2223
import static org.awaitility.Awaitility.await;
2324

25+
@Sample(
26+
tldr = "Changing the namespaces being watched at runtime",
27+
description =
28+
"Demonstrates how to change the namespaces being watched by a controller at runtime,"
29+
+ " including adding and removing namespaces as well as switching to watch all"
30+
+ " namespaces.")
2431
class ChangeNamespaceIT {
2532

2633
public static final String TEST_RESOURCE_NAME_1 = "test1";

0 commit comments

Comments
 (0)