Skip to content

fix: properly index otherwise ignored dependency #280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jan 7, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
import io.quarkus.deployment.builditem.FeatureBuildItem;
import io.quarkus.deployment.builditem.GeneratedClassBuildItem;
import io.quarkus.deployment.builditem.IndexDependencyBuildItem;
import io.quarkus.gizmo.ClassCreator;
import io.quarkus.gizmo.ClassOutput;
import io.quarkus.gizmo.MethodCreator;
Expand Down Expand Up @@ -55,6 +56,12 @@ FeatureBuildItem feature() {
return new FeatureBuildItem(FEATURE);
}

@BuildStep
void indexSDKDependencies(BuildProducer<IndexDependencyBuildItem> indexDependency) {
indexDependency.produce(
new IndexDependencyBuildItem("io.javaoperatorsdk", "operator-framework-core"));
}

@BuildStep
@Record(ExecutionTime.RUNTIME_INIT)
void createConfigurationServiceAndOperator(
Expand Down Expand Up @@ -132,6 +139,13 @@ private ControllerConfiguration createControllerConfiguration(

// generate configuration
final var controllerAnnotation = info.classAnnotation(CONTROLLER);
if (controllerAnnotation == null) {
throw new IllegalArgumentException(
resourceControllerClassName
+ " is missing the "
+ Controller.class.getCanonicalName()
+ " annotation");
}
final var crdName =
valueOrDefault(
controllerAnnotation, "crdName", AnnotationValue::asString, EXCEPTION_SUPPLIER);
Expand Down
5 changes: 5 additions & 0 deletions operator-framework-quarkus-extension/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<modules>
<module>deployment</module>
<module>runtime</module>
<module>tests</module>
</modules>
<dependencyManagement>
<dependencies>
Expand All @@ -47,6 +48,10 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.version}</version>
</plugin>
</plugins>
</pluginManagement>
</build>
Expand Down
11 changes: 0 additions & 11 deletions operator-framework-quarkus-extension/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
<groupId>io.javaoperatorsdk</groupId>
<artifactId>operator-framework-core</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
Expand Down Expand Up @@ -78,16 +77,6 @@
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.version}</version>
<configuration>
<systemPropertyVariables>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</project>
83 changes: 83 additions & 0 deletions operator-framework-quarkus-extension/tests/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>operator-framework-quarkus-extension-parent</artifactId>
<groupId>io.javaoperatorsdk</groupId>
<version>1.6.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>operator-framework-quarkus-tests</artifactId>
<name>Operator SDK - Quarkus Extension - Tests</name>


<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>io.javaoperatorsdk</groupId>
<artifactId>operator-framework-quarkus-extension</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5-internal</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<parameters>true</parameters>
</configuration>
</plugin>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus.version}</version>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<java.util.logging.manager>
org.jboss.logmanager.LogManager
</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.javaoperatorsdk.quarkus.it;

import io.javaoperatorsdk.operator.api.Context;
import io.javaoperatorsdk.operator.api.Controller;
import io.javaoperatorsdk.operator.api.DeleteControl;
import io.javaoperatorsdk.operator.api.ResourceController;
import io.javaoperatorsdk.operator.api.UpdateControl;

@Controller(crdName = TestController.CRD_NAME, name = TestController.NAME)
public class TestController implements ResourceController<TestResource> {
public static final String NAME = "test";
public static final String CRD_NAME = "test.example.com";

@Override
public DeleteControl deleteResource(TestResource resource, Context<TestResource> context) {
return null;
}

@Override
public UpdateControl<TestResource> createOrUpdateResource(
TestResource resource, Context<TestResource> context) {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package io.javaoperatorsdk.quarkus.it;

import io.javaoperatorsdk.operator.api.config.ConfigurationService;
import io.javaoperatorsdk.operator.api.config.ControllerConfiguration;
import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;

@Path("/operator")
public class TestOperatorApp {

@Inject TestController controller;
@Inject ConfigurationService configurationService;

@GET
@Path("{name}")
// @Produces(MediaType.TEXT_PLAIN)
public boolean getController(@PathParam("name") String name) {
return name.equals(controller.getName());
}

@GET
@Path("{name}/config")
public ControllerConfiguration getConfig(@PathParam("name") String name) {
return getController(name) ? configurationService.getConfigurationFor(controller) : null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package io.javaoperatorsdk.quarkus.it;

import io.fabric8.kubernetes.client.CustomResource;

public class TestResource extends CustomResource {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package io.javaoperatorsdk.quarkus.it;

import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;

import io.quarkus.test.QuarkusProdModeTest;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

/**
* This tests creates and starts an application accessed over REST to assess that injected values
* are present and what we expect.
*/
public class QuarkusExtensionProcessorTest {

@RegisterExtension
static final QuarkusProdModeTest config =
new QuarkusProdModeTest()
.setArchiveProducer(
() ->
ShrinkWrap.create(JavaArchive.class)
.addClasses(TestOperatorApp.class, TestController.class, TestResource.class))
.setApplicationName("basic-app")
.setApplicationVersion("0.1-SNAPSHOT")
.setRun(true);

@Test
void controllerShouldExist() {
// first check that we're not always returning true for any controller name :)
given().when().get("/operator/does_not_exist").then().statusCode(200).body(is("false"));

// given the name of the TestController, the app should reply true meaning that it is indeed
// injected
given().when().get("/operator/" + TestController.NAME).then().statusCode(200).body(is("true"));
}

@Test
void configurationForControllerShouldExist() {
// check that the config for the test controller can be retrieved and is conform to our
// expectations
final var resourceName = TestResource.class.getCanonicalName();
given()
.when()
.get("/operator/" + TestController.NAME + "/config")
.then()
.statusCode(200)
.body(
"customResourceClass", equalTo(resourceName),
"doneableClass", equalTo(resourceName + "Doneable"),
"name", equalTo(TestController.NAME),
"crdName", equalTo(TestController.CRD_NAME));
}
}
6 changes: 0 additions & 6 deletions operator-framework-spring-boot-starter-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@
</dependencyManagement>

<dependencies>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-server-mock</artifactId>
<version>4.12.0</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
Expand Down