Skip to content
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

feat: Quarkus codestart support #356

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions build-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<configuration>
<systemPropertyVariables>
<project.version>${project.version}</project.version>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</pluginManagement>
Expand Down
12 changes: 6 additions & 6 deletions integration-tests/pom.xml → core/integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.quarkiverse.operatorsdk</groupId>
<artifactId>quarkus-operator-sdk-build-parent</artifactId>
<artifactId>quarkus-operator-sdk-core-parent</artifactId>
<version>4.0.0-SNAPSHOT</version>
<relativePath>../build-parent/pom.xml</relativePath>
</parent>
<artifactId>quarkus-operator-sdk-integration-tests</artifactId>
<name>Quarkus - Operator SDK - Integration Tests</name>
Expand All @@ -21,10 +20,6 @@
<dependency>
<groupId>io.quarkiverse.operatorsdk</groupId>
<artifactId>quarkus-operator-sdk</artifactId>
</dependency>
<dependency>
<groupId>io.quarkiverse.operatorsdk</groupId>
<artifactId>quarkus-operator-sdk-bundle-generator</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
Expand Down Expand Up @@ -54,6 +49,11 @@
<artifactId>bcpkix-jdk15on</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-devtools-testing</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package io.quarkiverse.operatorsdk.it;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartCatalog.Language;
import io.quarkus.devtools.testing.codestarts.QuarkusCodestartTest;
import io.quarkus.maven.ArtifactCoords;

public class OperatorSDKCodestartTest {

@RegisterExtension
static QuarkusCodestartTest codestartTest = QuarkusCodestartTest.builder()
.standaloneExtensionCatalog()
.extension(ArtifactCoords
.fromString("io.quarkiverse.operatorsdk:quarkus-operator-sdk:" + System.getProperty("project.version")))
.languages(Language.JAVA)
.build();

@Test
void testContent() throws Throwable {
codestartTest.checkGeneratedSource("org.acme.MyCustomResourceReconciler");
codestartTest.checkGeneratedSource("org.acme.MyCustomResource");
codestartTest.checkGeneratedSource("org.acme.MyCustomResourceSpec");
codestartTest.checkGeneratedSource("org.acme.MyCustomResourceStatus");
}

@Test
void testBuild() throws Throwable {
codestartTest.buildAllProjects();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package ilove.quark.us;

import io.fabric8.kubernetes.client.CustomResource;

public class MyCustomResource extends CustomResource<MyCustomResourceSpec, MyCustomResourceStatus> {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package ilove.quark.us;

import io.javaoperatorsdk.operator.api.reconciler.Context;
import io.javaoperatorsdk.operator.api.reconciler.Reconciler;
import io.javaoperatorsdk.operator.api.reconciler.UpdateControl;

public class MyCustomResourceReconciler implements Reconciler<MyCustomResource> {

@Override
public UpdateControl<MyCustomResource> reconcile(MyCustomResource myCustomResource,
Context<MyCustomResource> context) throws Exception {
// implement reconciliation logic
return UpdateControl.noUpdate();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package ilove.quark.us;

public class MyCustomResourceSpec {
// add spec fields
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package ilove.quark.us;

public class MyCustomResourceStatus {
// add status fields
}
23 changes: 19 additions & 4 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,23 @@
<artifactId>quarkus-operator-sdk-core-parent</artifactId>
<packaging>pom</packaging>

<modules>
<module>deployment</module>
<module>runtime</module>
</modules>
<modules>
<module>deployment</module>
<module>runtime</module>
</modules>

<profiles>
<profile>
<id>it</id>
<activation>
<property>
<name>performRelease</name>
<value>!true</value>
</property>
</activation>
<modules>
<module>integration-tests</module>
</modules>
</profile>
</profiles>
</project>
20 changes: 20 additions & 0 deletions core/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,26 @@
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>generate-codestart-jar</id>
<phase>generate-resources</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classesDirectory>${project.basedir}/src/main</classesDirectory>
<includes>
<include>codestarts/**</include>
</includes>
<classifier>codestarts</classifier>
<skipIfEmpty>true</skipIfEmpty>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-bootstrap-maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{#include readme-header /}

FOO
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: operator-sdk-codestart
ref: quarkus-operator-sdk
type: code
tags: extension-codestart, operator, kubernetes
metadata:
title: Java Operator SDK Extension
description: This bootstraps an operator project using the Java Operator SDK project
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.acme;

import io.fabric8.kubernetes.client.CustomResource;

public class MyCustomResource extends CustomResource<MyCustomResourceSpec, MyCustomResourceStatus> {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.acme;

import io.javaoperatorsdk.operator.api.reconciler.Context;
import io.javaoperatorsdk.operator.api.reconciler.Reconciler;
import io.javaoperatorsdk.operator.api.reconciler.UpdateControl;

public class MyCustomResourceReconciler implements Reconciler<MyCustomResource> {

@Override
public UpdateControl<MyCustomResource> reconcile(MyCustomResource myCustomResource,
Context<MyCustomResource> context) throws Exception {
// implement reconciliation logic
return UpdateControl.noUpdate();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.acme;

public class MyCustomResourceSpec {
// add spec fields
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.acme;

public class MyCustomResourceStatus {
// add status fields
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ name: Quarkus - Operator SDK
description: Quarkus extension for the Java Operator SDK (https://javaoperatorsdk.io)
metadata:
keywords:
- operator
- kubernetes
- openshift
- operator
- kubernetes
- openshift
categories:
- "cloud"
- "cloud"
codestart:
name: "quarkus-operator-sdk"
languages:
- "java"
artifact: "io.quarkiverse.operatorsdk:quarkus-operator-sdk:codestarts:jar:${project.version}"
# status: "preview"

This file was deleted.

This file was deleted.

This file was deleted.

12 changes: 0 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,6 @@
<module>bundle-generator</module>
</modules>
</profile>
<profile>
<id>it</id>
<activation>
<property>
<name>performRelease</name>
<value>!true</value>
</property>
</activation>
<modules>
<module>integration-tests</module>
</modules>
</profile>
<profile>
<id>quick-build</id>
<activation>
Expand Down