A better structure for config-api
This commit is contained in:
parent
6335090092
commit
006aea300d
104 changed files with 277 additions and 527 deletions
10
.github/workflows/operator-ci.yml
vendored
10
.github/workflows/operator-ci.yml
vendored
|
@ -76,7 +76,7 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
eval $(minikube -p minikube docker-env)
|
eval $(minikube -p minikube docker-env)
|
||||||
(cd quarkus/container && docker build --build-arg KEYCLOAK_DIST=$(ls keycloak-*.tar.gz) . -t keycloak:${{ steps.vars.outputs.version }})
|
(cd quarkus/container && docker build --build-arg KEYCLOAK_DIST=$(ls keycloak-*.tar.gz) . -t keycloak:${{ steps.vars.outputs.version }})
|
||||||
(cd operator/app && ./scripts/build-testing-docker-images.sh ${{ steps.vars.outputs.version }} keycloak custom-keycloak)
|
(cd operator && ./scripts/build-testing-docker-images.sh ${{ steps.vars.outputs.version }} keycloak custom-keycloak)
|
||||||
|
|
||||||
- name: Test operator running locally
|
- name: Test operator running locally
|
||||||
run: |
|
run: |
|
||||||
|
@ -121,7 +121,7 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
eval $(minikube -p minikube docker-env)
|
eval $(minikube -p minikube docker-env)
|
||||||
(cd quarkus/container && docker build --build-arg KEYCLOAK_DIST=$(ls keycloak-*.tar.gz) . -t keycloak:${{ steps.vars.outputs.version }})
|
(cd quarkus/container && docker build --build-arg KEYCLOAK_DIST=$(ls keycloak-*.tar.gz) . -t keycloak:${{ steps.vars.outputs.version }})
|
||||||
(cd operator/app && ./scripts/build-testing-docker-images.sh ${{ steps.vars.outputs.version }} keycloak custom-keycloak)
|
(cd operator && ./scripts/build-testing-docker-images.sh ${{ steps.vars.outputs.version }} keycloak custom-keycloak)
|
||||||
|
|
||||||
- name: Test operator running in cluster
|
- name: Test operator running in cluster
|
||||||
run: |
|
run: |
|
||||||
|
@ -163,7 +163,7 @@ jobs:
|
||||||
- name: Install Yq
|
- name: Install Yq
|
||||||
run: sudo snap install yq
|
run: sudo snap install yq
|
||||||
- name: Install OLM
|
- name: Install OLM
|
||||||
working-directory: operator/app
|
working-directory: operator
|
||||||
run: ./scripts/install-olm.sh
|
run: ./scripts/install-olm.sh
|
||||||
- name: Download keycloak distribution
|
- name: Download keycloak distribution
|
||||||
id: download-keycloak-dist
|
id: download-keycloak-dist
|
||||||
|
@ -172,13 +172,13 @@ jobs:
|
||||||
name: keycloak-distribution
|
name: keycloak-distribution
|
||||||
path: quarkus/container
|
path: quarkus/container
|
||||||
- name: Arrange OLM test installation
|
- name: Arrange OLM test installation
|
||||||
working-directory: operator/app
|
working-directory: operator
|
||||||
run: |
|
run: |
|
||||||
eval $(minikube -p minikube docker-env)
|
eval $(minikube -p minikube docker-env)
|
||||||
./scripts/olm-testing.sh ${GITHUB_SHA::6}
|
./scripts/olm-testing.sh ${GITHUB_SHA::6}
|
||||||
|
|
||||||
- name: Deploy an example Keycloak and wait for it to be ready
|
- name: Deploy an example Keycloak and wait for it to be ready
|
||||||
working-directory: operator/app
|
working-directory: operator
|
||||||
run: |
|
run: |
|
||||||
kubectl apply -f src/main/resources/example-postgres.yaml
|
kubectl apply -f src/main/resources/example-postgres.yaml
|
||||||
./scripts/check-crds-installed.sh
|
./scripts/check-crds-installed.sh
|
||||||
|
|
|
@ -1,292 +0,0 @@
|
||||||
<?xml version="1.0"?>
|
|
||||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<artifactId>keycloak-operator-parent</artifactId>
|
|
||||||
<groupId>org.keycloak</groupId>
|
|
||||||
<version>999-SNAPSHOT</version>
|
|
||||||
<relativePath>../pom.xml</relativePath>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<name>Keycloak Operator</name>
|
|
||||||
<artifactId>keycloak-operator</artifactId>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<!--
|
|
||||||
Override versions based on Quarkus dependencies.
|
|
||||||
Make sure to update these dependencies when Quarkus version changes.
|
|
||||||
See https://github.com/quarkusio/quarkus/blob/<versionTag>/bom/application/pom.xml
|
|
||||||
for reference
|
|
||||||
-->
|
|
||||||
<resteasy.version>4.7.5.Final</resteasy.version>
|
|
||||||
<wildfly.common.version>1.5.4.Final-format-001</wildfly.common.version>
|
|
||||||
<jackson.version>2.13.3</jackson.version>
|
|
||||||
<jackson.databind.version>2.13.3</jackson.databind.version>
|
|
||||||
<kubernetes-client.version>5.12.2</kubernetes-client.version>
|
|
||||||
|
|
||||||
<compiler-plugin.version>3.8.1</compiler-plugin.version>
|
|
||||||
<maven.compiler.parameters>true</maven.compiler.parameters>
|
|
||||||
<maven.compiler.release>11</maven.compiler.release>
|
|
||||||
<maven.compiler.source>11</maven.compiler.source>
|
|
||||||
<maven.compiler.target>11</maven.compiler.target>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
|
||||||
<quarkus.operator.sdk.version>3.0.8</quarkus.operator.sdk.version>
|
|
||||||
<quarkus.version>2.7.6.Final</quarkus.version>
|
|
||||||
<quarkus.container-image.group>keycloak</quarkus.container-image.group>
|
|
||||||
<quarkus.jib.base-jvm-image>registry.access.redhat.com/ubi8/openjdk-11-runtime</quarkus.jib.base-jvm-image>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencyManagement>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.quarkiverse.operatorsdk</groupId>
|
|
||||||
<artifactId>quarkus-operator-sdk-bom</artifactId>
|
|
||||||
<version>${quarkus.operator.sdk.version}</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</dependencyManagement>
|
|
||||||
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<!-- Fabric8 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.fabric8</groupId>
|
|
||||||
<artifactId>crd-generator-api</artifactId>
|
|
||||||
<version>${kubernetes-client.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.fabric8</groupId>
|
|
||||||
<artifactId>crd-generator-apt</artifactId>
|
|
||||||
<version>${kubernetes-client.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Quarkus -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.quarkiverse.operatorsdk</groupId>
|
|
||||||
<artifactId>quarkus-operator-sdk</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.quarkiverse.operatorsdk</groupId>
|
|
||||||
<artifactId>quarkus-operator-sdk-csv-generator</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.quarkus</groupId>
|
|
||||||
<artifactId>quarkus-resteasy-jackson</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.quarkus</groupId>
|
|
||||||
<artifactId>quarkus-rest-client</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.quarkus</groupId>
|
|
||||||
<artifactId>quarkus-rest-client-jackson</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.quarkus</groupId>
|
|
||||||
<artifactId>quarkus-openshift</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.quarkus</groupId>
|
|
||||||
<artifactId>quarkus-minikube</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.quarkus</groupId>
|
|
||||||
<artifactId>quarkus-kubernetes-client</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- This dependency is needed only to ensure proper building order so that this module is build after the CSV extension -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.quarkiverse.operatorsdk</groupId>
|
|
||||||
<artifactId>quarkus-operator-sdk-csv-generator-deployment</artifactId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Keycloak -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.keycloak</groupId>
|
|
||||||
<artifactId>keycloak-config-api</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Test -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.quarkus</groupId>
|
|
||||||
<artifactId>quarkus-test-common</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.quarkus</groupId>
|
|
||||||
<artifactId>quarkus-junit5</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.assertj</groupId>
|
|
||||||
<artifactId>assertj-core</artifactId>
|
|
||||||
<version>${assertj-core.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.awaitility</groupId>
|
|
||||||
<artifactId>awaitility</artifactId>
|
|
||||||
<version>${awaitility.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.rest-assured</groupId>
|
|
||||||
<artifactId>rest-assured</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<pluginManagement>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>io.quarkus</groupId>
|
|
||||||
<artifactId>quarkus-maven-plugin</artifactId>
|
|
||||||
<version>${quarkus.version}</version>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<version>${compiler-plugin.version}</version>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</pluginManagement>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.keycloak</groupId>
|
|
||||||
<artifactId>keycloak-operator-maven-plugin</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>generate-server-config</id>
|
|
||||||
<phase>generate-sources</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>keycloak-operator-codegen</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</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>
|
|
||||||
<artifactId>maven-resources-plugin</artifactId>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>copy-resources</id>
|
|
||||||
<phase>validate</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>copy-resources</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<outputDirectory>${basedir}/target</outputDirectory>
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<directory>src/main/kubernetes</directory>
|
|
||||||
<filtering>true</filtering>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
<execution>
|
|
||||||
<id>import-keycloak-core</id>
|
|
||||||
<phase>validate</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>copy-resources</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<outputDirectory>${basedir}/target/keycloak-core</outputDirectory>
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<directory>${basedir}/../../core/src/main/java</directory>
|
|
||||||
<filtering>true</filtering>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
|
||||||
<artifactId>build-helper-maven-plugin</artifactId>
|
|
||||||
<version>3.2.0</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>generate-sources</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>add-source</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<sources>
|
|
||||||
<source>${basedir}/target/keycloak-core</source>
|
|
||||||
<source>${basedir}/target/generated-sources/java</source>
|
|
||||||
</sources>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<artifactId>exec-maven-plugin</artifactId>
|
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
|
||||||
<version>1.6.0</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>patch-core-sources</id>
|
|
||||||
<phase>generate-sources</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>exec</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<executable>${basedir}/patch-sources.sh</executable>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<executions>
|
|
||||||
<!--
|
|
||||||
need to run at "verify" to support testing with images (which are built at "package")
|
|
||||||
using surefire instead of failsafe to align with rest of the KC project
|
|
||||||
-->
|
|
||||||
<execution>
|
|
||||||
<id>default-test</id>
|
|
||||||
<phase>verify</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>test</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
|
|
||||||
<profiles>
|
|
||||||
<profile>
|
|
||||||
<id>native</id>
|
|
||||||
<properties>
|
|
||||||
<quarkus.package.type>native</quarkus.package.type>
|
|
||||||
</properties>
|
|
||||||
</profile>
|
|
||||||
</profiles>
|
|
||||||
</project>
|
|
|
@ -1,66 +0,0 @@
|
||||||
|
|
||||||
<!--
|
|
||||||
~ Copyright 2016 Red Hat, Inc. and/or its affiliates
|
|
||||||
~ and other contributors as indicated by the @author tags.
|
|
||||||
~
|
|
||||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
~ you may not use this file except in compliance with the License.
|
|
||||||
~ You may obtain a copy of the License at
|
|
||||||
~
|
|
||||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
~
|
|
||||||
~ Unless required by applicable law or agreed to in writing, software
|
|
||||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
~ See the License for the specific language governing permissions and
|
|
||||||
~ limitations under the License.
|
|
||||||
-->
|
|
||||||
<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/maven-v4_0_0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>keycloak-operator-parent</artifactId>
|
|
||||||
<groupId>org.keycloak</groupId>
|
|
||||||
<version>999-SNAPSHOT</version>
|
|
||||||
<relativePath>../pom.xml</relativePath>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<name>Keycloak Operator Maven Plugin</name>
|
|
||||||
<artifactId>keycloak-operator-maven-plugin</artifactId>
|
|
||||||
<description>Keycloak Operator Maven Plugin</description>
|
|
||||||
<packaging>maven-plugin</packaging>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<!-- Maven Plugin Dependencies -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.maven</groupId>
|
|
||||||
<artifactId>maven-plugin-api</artifactId>
|
|
||||||
<version>3.6.3</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.maven.plugin-tools</groupId>
|
|
||||||
<artifactId>maven-plugin-annotations</artifactId>
|
|
||||||
<version>3.6.0</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.maven</groupId>
|
|
||||||
<artifactId>maven-project</artifactId>
|
|
||||||
<version>2.2.1</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Keycloak Dependencies -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.keycloak</groupId>
|
|
||||||
<artifactId>keycloak-config-api</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Codegen Dependencies -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.javaparser</groupId>
|
|
||||||
<artifactId>javaparser-core</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
</project>
|
|
|
@ -1,32 +0,0 @@
|
||||||
package org.keycloak.operator.maven;
|
|
||||||
|
|
||||||
import org.apache.maven.plugin.AbstractMojo;
|
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
|
||||||
import org.apache.maven.plugin.MojoFailureException;
|
|
||||||
import org.apache.maven.plugin.logging.Log;
|
|
||||||
import org.apache.maven.plugins.annotations.LifecyclePhase;
|
|
||||||
import org.apache.maven.plugins.annotations.Mojo;
|
|
||||||
import org.apache.maven.plugins.annotations.Parameter;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
@Mojo(name = "keycloak-operator-codegen", defaultPhase = LifecyclePhase.GENERATE_SOURCES)
|
|
||||||
public class CodegenMojo extends AbstractMojo {
|
|
||||||
|
|
||||||
@Parameter(property = "operator.codegen.target", defaultValue = "${basedir}/target/generated-sources/java")
|
|
||||||
private File target;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute() throws MojoExecutionException, MojoFailureException {
|
|
||||||
try {
|
|
||||||
Log log = getLog();
|
|
||||||
|
|
||||||
ServerConfigGen serverConfigGen = new ServerConfigGen();
|
|
||||||
|
|
||||||
serverConfigGen.generate(log, target);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
throw new MojoFailureException("Failed to generate code", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,85 +0,0 @@
|
||||||
package org.keycloak.operator.maven;
|
|
||||||
|
|
||||||
import com.github.javaparser.ast.CompilationUnit;
|
|
||||||
import com.github.javaparser.ast.Modifier;
|
|
||||||
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration;
|
|
||||||
import com.github.javaparser.ast.body.FieldDeclaration;
|
|
||||||
import com.github.javaparser.ast.expr.StringLiteralExpr;
|
|
||||||
import com.github.javaparser.utils.StringEscapeUtils;
|
|
||||||
import org.apache.maven.plugin.logging.Log;
|
|
||||||
import org.keycloak.config.AllOptions;
|
|
||||||
import org.keycloak.config.Option;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class ServerConfigGen {
|
|
||||||
|
|
||||||
public static final String ANNOTATION_JSON_PROPERTY = "com.fasterxml.jackson.annotation.JsonProperty";
|
|
||||||
public static final String ANNOTATION_JSON_PROPERTY_DESCRIPTION = "com.fasterxml.jackson.annotation.JsonPropertyDescription";
|
|
||||||
|
|
||||||
public void generate(Log log, File destination) {
|
|
||||||
String className = "ServerConfig";
|
|
||||||
String[] packageName = new String[]{"org", "keycloak", "operator", "codegen", "configuration"};
|
|
||||||
CompilationUnit cu = new CompilationUnit();
|
|
||||||
cu.setPackageDeclaration(String.join(".", packageName));
|
|
||||||
|
|
||||||
ClassOrInterfaceDeclaration serverConfig = cu.addClass(className);
|
|
||||||
|
|
||||||
Path dest = Paths.get(destination.getAbsolutePath(), packageName);
|
|
||||||
dest.toFile().mkdirs();
|
|
||||||
|
|
||||||
AllOptions.ALL_OPTIONS.forEach(o -> {
|
|
||||||
if (o.getSupportedRuntimes().contains(Option.Runtime.OPERATOR)) {
|
|
||||||
String fieldName = toCamelCase(o.getKey());
|
|
||||||
|
|
||||||
FieldDeclaration field = serverConfig.addField(o.getType().getCanonicalName(), fieldName, Modifier.Keyword.PRIVATE);
|
|
||||||
field.addSingleMemberAnnotation(
|
|
||||||
ANNOTATION_JSON_PROPERTY,
|
|
||||||
new StringLiteralExpr(o.getKey()));
|
|
||||||
if (o.getDescription() != null) {
|
|
||||||
field.addSingleMemberAnnotation(
|
|
||||||
ANNOTATION_JSON_PROPERTY_DESCRIPTION,
|
|
||||||
new StringLiteralExpr(StringEscapeUtils.escapeJava(o.getDescription())));
|
|
||||||
}
|
|
||||||
field.createGetter();
|
|
||||||
field.createSetter();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
writeToFile(dest.resolve(className + ".java").toFile(), cu.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void writeToFile(File file, String str) {
|
|
||||||
try (FileWriter fileWriter = new FileWriter(file);
|
|
||||||
PrintWriter printWriter = new PrintWriter(fileWriter)) {
|
|
||||||
printWriter.println(str);
|
|
||||||
} catch (IOException ex) {
|
|
||||||
throw new RuntimeException(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String toCamelCase(String original) {
|
|
||||||
boolean convertNext = false;
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
for (int i = 0; i < original.length(); i++) {
|
|
||||||
char currentChar = original.charAt(i);
|
|
||||||
if (currentChar == '-') {
|
|
||||||
convertNext = true;
|
|
||||||
} else if (convertNext) {
|
|
||||||
builder.append(Character.toUpperCase(currentChar));
|
|
||||||
convertNext = false;
|
|
||||||
} else {
|
|
||||||
builder.append(Character.toLowerCase(currentChar));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
295
operator/pom.xml
Executable file → Normal file
295
operator/pom.xml
Executable file → Normal file
|
@ -1,36 +1,277 @@
|
||||||
<!--
|
<?xml version="1.0"?>
|
||||||
~ Copyright 2016 Red Hat, Inc. and/or its affiliates
|
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||||
~ and other contributors as indicated by the @author tags.
|
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
~
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
<modelVersion>4.0.0</modelVersion>
|
||||||
~ you may not use this file except in compliance with the License.
|
|
||||||
~ You may obtain a copy of the License at
|
|
||||||
~
|
|
||||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
~
|
|
||||||
~ Unless required by applicable law or agreed to in writing, software
|
|
||||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
~ See the License for the specific language governing permissions and
|
|
||||||
~ limitations under the License.
|
|
||||||
-->
|
|
||||||
<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/maven-v4_0_0.xsd">
|
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-parent</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>999-SNAPSHOT</version>
|
<version>999-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<name>Keycloak Operator Parent</name>
|
|
||||||
<description/>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>keycloak-operator-parent</artifactId>
|
<name>Keycloak Operator</name>
|
||||||
<packaging>pom</packaging>
|
<artifactId>keycloak-operator</artifactId>
|
||||||
|
|
||||||
<modules>
|
<properties>
|
||||||
<module>maven-plugin</module>
|
<!--
|
||||||
<module>app</module>
|
Override versions based on Quarkus dependencies.
|
||||||
</modules>
|
Make sure to update these dependencies when Quarkus version changes.
|
||||||
|
See https://github.com/quarkusio/quarkus/blob/<versionTag>/bom/application/pom.xml
|
||||||
|
for reference
|
||||||
|
-->
|
||||||
|
<resteasy.version>4.7.5.Final</resteasy.version>
|
||||||
|
<wildfly.common.version>1.5.4.Final-format-001</wildfly.common.version>
|
||||||
|
<jackson.version>2.13.3</jackson.version>
|
||||||
|
<jackson.databind.version>2.13.3</jackson.databind.version>
|
||||||
|
<kubernetes-client.version>5.12.2</kubernetes-client.version>
|
||||||
|
|
||||||
|
<compiler-plugin.version>3.8.1</compiler-plugin.version>
|
||||||
|
<maven.compiler.parameters>true</maven.compiler.parameters>
|
||||||
|
<maven.compiler.release>11</maven.compiler.release>
|
||||||
|
<maven.compiler.source>11</maven.compiler.source>
|
||||||
|
<maven.compiler.target>11</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
<quarkus.operator.sdk.version>3.0.8</quarkus.operator.sdk.version>
|
||||||
|
<quarkus.version>2.7.6.Final</quarkus.version>
|
||||||
|
<quarkus.container-image.group>keycloak</quarkus.container-image.group>
|
||||||
|
<quarkus.jib.base-jvm-image>registry.access.redhat.com/ubi8/openjdk-11-runtime</quarkus.jib.base-jvm-image>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.quarkiverse.operatorsdk</groupId>
|
||||||
|
<artifactId>quarkus-operator-sdk-bom</artifactId>
|
||||||
|
<version>${quarkus.operator.sdk.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<!-- Fabric8 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.fabric8</groupId>
|
||||||
|
<artifactId>crd-generator-api</artifactId>
|
||||||
|
<version>${kubernetes-client.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.fabric8</groupId>
|
||||||
|
<artifactId>crd-generator-apt</artifactId>
|
||||||
|
<version>${kubernetes-client.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Quarkus -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.quarkiverse.operatorsdk</groupId>
|
||||||
|
<artifactId>quarkus-operator-sdk</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.quarkiverse.operatorsdk</groupId>
|
||||||
|
<artifactId>quarkus-operator-sdk-csv-generator</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.quarkus</groupId>
|
||||||
|
<artifactId>quarkus-resteasy-jackson</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.quarkus</groupId>
|
||||||
|
<artifactId>quarkus-rest-client</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.quarkus</groupId>
|
||||||
|
<artifactId>quarkus-rest-client-jackson</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.quarkus</groupId>
|
||||||
|
<artifactId>quarkus-openshift</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.quarkus</groupId>
|
||||||
|
<artifactId>quarkus-minikube</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.quarkus</groupId>
|
||||||
|
<artifactId>quarkus-kubernetes-client</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- This dependency is needed only to ensure proper building order so that this module is build after the CSV extension -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.quarkiverse.operatorsdk</groupId>
|
||||||
|
<artifactId>quarkus-operator-sdk-csv-generator-deployment</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Keycloak -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.keycloak</groupId>
|
||||||
|
<artifactId>keycloak-common</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Test -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.quarkus</groupId>
|
||||||
|
<artifactId>quarkus-test-common</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.quarkus</groupId>
|
||||||
|
<artifactId>quarkus-junit5</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.assertj</groupId>
|
||||||
|
<artifactId>assertj-core</artifactId>
|
||||||
|
<version>${assertj-core.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.awaitility</groupId>
|
||||||
|
<artifactId>awaitility</artifactId>
|
||||||
|
<version>${awaitility.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.rest-assured</groupId>
|
||||||
|
<artifactId>rest-assured</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<pluginManagement>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>io.quarkus</groupId>
|
||||||
|
<artifactId>quarkus-maven-plugin</artifactId>
|
||||||
|
<version>${quarkus.version}</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>${compiler-plugin.version}</version>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</pluginManagement>
|
||||||
|
<plugins>
|
||||||
|
<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>
|
||||||
|
<artifactId>maven-resources-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>copy-resources</id>
|
||||||
|
<phase>validate</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy-resources</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>${basedir}/target</outputDirectory>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/kubernetes</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>import-keycloak-core</id>
|
||||||
|
<phase>validate</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy-resources</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>${basedir}/target/keycloak-core</outputDirectory>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>${basedir}/../core/src/main/java</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>build-helper-maven-plugin</artifactId>
|
||||||
|
<version>3.2.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>generate-sources</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>add-source</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<sources>
|
||||||
|
<source>${basedir}/target/keycloak-core</source>
|
||||||
|
<source>${basedir}/target/generated-sources/java</source>
|
||||||
|
</sources>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<version>1.6.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>patch-core-sources</id>
|
||||||
|
<phase>generate-sources</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<executable>${basedir}/patch-sources.sh</executable>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<!--
|
||||||
|
need to run at "verify" to support testing with images (which are built at "package")
|
||||||
|
using surefire instead of failsafe to align with rest of the KC project
|
||||||
|
-->
|
||||||
|
<execution>
|
||||||
|
<id>default-test</id>
|
||||||
|
<phase>verify</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>test</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>native</id>
|
||||||
|
<properties>
|
||||||
|
<quarkus.package.type>native</quarkus.package.type>
|
||||||
|
</properties>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -10,7 +10,7 @@ VERSION="86400000.0.0"
|
||||||
|
|
||||||
# Build Keycloak Docker image (the keycloak tar.gz should already be in the container folder)
|
# Build Keycloak Docker image (the keycloak tar.gz should already be in the container folder)
|
||||||
(
|
(
|
||||||
cd $SCRIPT_DIR/../../../quarkus/container
|
cd $SCRIPT_DIR/../../quarkus/container
|
||||||
|
|
||||||
docker build --build-arg KEYCLOAK_DIST=$(ls keycloak-*.tar.gz) . -t "ttl.sh/${UUID}keycloak:${VERSION}"
|
docker build --build-arg KEYCLOAK_DIST=$(ls keycloak-*.tar.gz) . -t "ttl.sh/${UUID}keycloak:${VERSION}"
|
||||||
docker push "ttl.sh/${UUID}keycloak:${VERSION}"
|
docker push "ttl.sh/${UUID}keycloak:${VERSION}"
|
||||||
|
@ -18,7 +18,7 @@ VERSION="86400000.0.0"
|
||||||
|
|
||||||
# Build the operator Docker image
|
# Build the operator Docker image
|
||||||
(
|
(
|
||||||
cd $SCRIPT_DIR/../../../
|
cd $SCRIPT_DIR/../../
|
||||||
mvn clean package -Poperator -pl :keycloak-operator -am \
|
mvn clean package -Poperator -pl :keycloak-operator -am \
|
||||||
-Dquarkus.container-image.build=true \
|
-Dquarkus.container-image.build=true \
|
||||||
-Dquarkus.container-image.image="ttl.sh/${UUID}keycloak-operator:${VERSION}" \
|
-Dquarkus.container-image.image="ttl.sh/${UUID}keycloak-operator:${VERSION}" \
|
10
pom.xml
10
pom.xml
|
@ -1930,16 +1930,6 @@
|
||||||
</properties>
|
</properties>
|
||||||
</profile>
|
</profile>
|
||||||
|
|
||||||
<profile>
|
|
||||||
<id>config-api</id>
|
|
||||||
<activation>
|
|
||||||
<jdk>[11,)</jdk>
|
|
||||||
</activation>
|
|
||||||
<modules>
|
|
||||||
<module>config-api</module>
|
|
||||||
</modules>
|
|
||||||
</profile>
|
|
||||||
|
|
||||||
<profile>
|
<profile>
|
||||||
<id>quarkus</id>
|
<id>quarkus</id>
|
||||||
<activation>
|
<activation>
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<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/maven-v4_0_0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>keycloak-parent</artifactId>
|
<artifactId>keycloak-quarkus-parent</artifactId>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<version>999-SNAPSHOT</version>
|
<version>999-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
@ -31,13 +31,6 @@
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<description/>
|
<description/>
|
||||||
|
|
||||||
<properties>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
<maven.compiler.release>11</maven.compiler.release>
|
|
||||||
<maven.compiler.source>11</maven.compiler.source>
|
|
||||||
<maven.compiler.target>11</maven.compiler.target>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue