Skip to content

Commit

Permalink
DBZ-6738 Functional bundle can be generated during maven build
Browse files Browse the repository at this point in the history
This uses combination of maven resources plugin to perform property filtering and Fabric8 docker plugin to wire OLM and QOSDK configuration together.
  • Loading branch information
jcechace committed Sep 19, 2023
1 parent 730c834 commit 1e7a172
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,5 @@ nb-configuration.xml
kubernetes.json

# OLM build workspace
olm/
olm/*
!olm/bundles
8 changes: 8 additions & 0 deletions olm/bundles/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Debezium Operator OLM Bundle Manifests
For main branch this directory is expected to be empty. For release branches the raw OLM bundle manifests should be located here.

_Note that such OLM bundle requires further processing and without it the bundle is not usable._

To release this bundle follow the instruction is [Operator Bundle Manifests repository](https://github.com/debezium/debezium-operator-manifests).


92 changes: 91 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.release>17</maven.compiler.release>
<maven.compiler.testRelease>17</maven.compiler.testRelease>
<maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ss'Z'</maven.build.timestamp.format>

<!-- Debezium version -->
<version.debezium>${project.version}</version.debezium>
Expand All @@ -32,6 +33,9 @@
<version.buildhelper.plugin>3.4.0</version.buildhelper.plugin>
<version.surefire.version>3.0.0</version.surefire.version>
<version.compiler.plugin>3.11.0</version.compiler.plugin>
<version.resources.plugin>3.3.1</version.resources.plugin>
<version.docker.maven.plugin>0.43.4</version.docker.maven.plugin>


<!-- Dependency versions -->
<version.assertj>3.24.2</version.assertj>
Expand All @@ -44,14 +48,18 @@

<!-- Operator and Image configuration -->
<quarkus.operator-sdk.crd.validate>false</quarkus.operator-sdk.crd.validate>
<quarkus.operator-sdk.bundle.package-name>${project.artifactId}</quarkus.operator-sdk.bundle.package-name>
<quarkus.container-image.registry>quay.io</quarkus.container-image.registry>
<quarkus.container-image.group>debezium</quarkus.container-image.group>
<quarkus.container-image.name>operator</quarkus.container-image.name>
<quarkus.container-image.tag>nightly</quarkus.container-image.tag>
<quarkus.kubernetes.name>debezium-operator</quarkus.kubernetes.name>
<!-- OLM configuration -->
<version.debezium.channel>${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.x</version.debezium.channel>
<olm.bundle.version>${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}-nightly</olm.bundle.version>
<olm.bundle.name>debezium-operator.v${olm.bundle.version}</olm.bundle.name>
<olm.bundle.replaces></olm.bundle.replaces>
<olm.bundle.containerImage>${quarkus.container-image.registry}/${quarkus.container-image.group}/${quarkus.container-image.name}:${quarkus.container-image.tag}</olm.bundle.containerImage>
<olm.bundle.createdAt>${maven.build.timestamp}</olm.bundle.createdAt>
<!-- Formatting configuration -->
<format.imports.source.compliance>17</format.imports.source.compliance>
<!-- Example properties -->
Expand Down Expand Up @@ -216,6 +224,7 @@
<properties>
<quarkus.container-image.tag>${project.parent.version}</quarkus.container-image.tag>
<quarkus.operator-sdk.bundle.channels>debezium-${version.debezium.channel}</quarkus.operator-sdk.bundle.channels>
<olm.bundle.version>${project.parent.version}</olm.bundle.version>
</properties>
</profile>
<profile>
Expand All @@ -226,6 +235,87 @@
<quarkus.operator-sdk.bundle.channels>debezium-stable,debezium-${version.debezium.channel}</quarkus.operator-sdk.bundle.channels>
</properties>
</profile>
<profile>
<id>olmUpdate</id>
<properties>
<quarkus.kubernetes.idempotent>true</quarkus.kubernetes.idempotent>
<!-- Outputting dollar sign has to be done through property-->
<dollar>$$</dollar>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>${version.resources.plugin}</version>
<executions>
<execution>
<id>copy-olm</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.basedir}/olm/bundles/${olm.bundle.version}</outputDirectory>
<resources>
<resource>
<!-- Outputting ${olm.bundle.name} without actually expanding the property -->
<directory>${project.build.directory}/bundle/${dollar}{olm.bundle.name}</directory>
<include>**/*</include>
<filtering>true</filtering>
</resource>
</resources>
<fileNameFiltering>true</fileNameFiltering>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<!-- Wire OLM target namespaces and QOSDK configuration together-->
<!-- Required since QOSDK doesn't generate this!-->
<!-- OLM standard is to set the olm.targetNamespaces annotation on operator deployments-->
<!-- whereas QOSDK uses the QUARKUS_OPERATOR_SDK_NAMESPACES environment variable for the same purpose-->
<!-- This runs yq container and adds the variable to operator deployment in generated CSV-->
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>${version.docker.maven.plugin}</version>
<configuration>
<images>
<image>
<alias>yq</alias>
<name>mikefarah/yq:latest</name>
<run>
<autoRemove>true</autoRemove>
<volumes>
<bind>
<volume>${project.basedir}/olm/bundles/${olm.bundle.version}:/workdir</volume>
</bind>
</volumes>
<cmd>
<exec>
<arg>ea</arg>
<arg>-i</arg>
<arg>.spec.install.spec.deployments[0].spec.template.spec.containers[0].env += [{"name": "QUARKUS_OPERATOR_SDK_NAMESPACES", "valueFrom": {"fieldRef": {"fieldPath": "metadata.annotations['olm.targetNamespaces']"}}}]</arg>
<arg>manifests/${olm.bundle.name}.clusterserviceversion.yaml</arg>
</exec>
</cmd>
</run>
</image>
</images>
</configuration>
<executions>
<execution>
<id>wire-olm</id>
<phase>package</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>k8update</id>
<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,5 @@
"Start it up, point it at your databases, and your apps can start responding " +
"to all of the inserts, updates, and deletes that other apps commit to your databases")
public class DebeziumCsvMetadata implements SharedCSVMetadata {
public static final String NAME = "debezium-operator";
public static final String NAME = "${olm.bundle.name}";
}

0 comments on commit 1e7a172

Please sign in to comment.