Refactor dist config to a common module
This commit is contained in:
parent
bc59fad85b
commit
d66710205c
104 changed files with 920 additions and 381 deletions
14
.github/workflows/operator-ci.yml
vendored
14
.github/workflows/operator-ci.yml
vendored
|
@ -76,11 +76,11 @@ 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 && ./scripts/build-testing-docker-images.sh ${{ steps.vars.outputs.version }} keycloak custom-keycloak)
|
(cd operator/app && ./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: |
|
||||||
mvn -Poperator -pl operator -am clean verify \
|
mvn clean verify -Poperator -pl :keycloak-operator -am \
|
||||||
-Dquarkus.kubernetes.deployment-target=kubernetes \
|
-Dquarkus.kubernetes.deployment-target=kubernetes \
|
||||||
-Doperator.keycloak.image=keycloak:${{ steps.vars.outputs.version }} \
|
-Doperator.keycloak.image=keycloak:${{ steps.vars.outputs.version }} \
|
||||||
-Dtest.operator.custom.image=custom-keycloak:${{ steps.vars.outputs.version }} \
|
-Dtest.operator.custom.image=custom-keycloak:${{ steps.vars.outputs.version }} \
|
||||||
|
@ -121,12 +121,12 @@ 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 && ./scripts/build-testing-docker-images.sh ${{ steps.vars.outputs.version }} keycloak custom-keycloak)
|
(cd operator/app && ./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: |
|
||||||
eval $(minikube -p minikube docker-env)
|
eval $(minikube -p minikube docker-env)
|
||||||
mvn -Poperator -pl operator -am clean verify \
|
mvn clean verify -Poperator -pl :keycloak-operator -am \
|
||||||
-Dquarkus.container-image.build=true \
|
-Dquarkus.container-image.build=true \
|
||||||
-Dquarkus.kubernetes.deployment-target=kubernetes \
|
-Dquarkus.kubernetes.deployment-target=kubernetes \
|
||||||
-Doperator.keycloak.image=keycloak:${{ steps.vars.outputs.version }} \
|
-Doperator.keycloak.image=keycloak:${{ steps.vars.outputs.version }} \
|
||||||
|
@ -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
|
working-directory: operator/app
|
||||||
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
|
working-directory: operator/app
|
||||||
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
|
working-directory: operator/app
|
||||||
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
|
||||||
|
|
41
config-api/pom.xml
Executable file
41
config-api/pom.xml
Executable file
|
@ -0,0 +1,41 @@
|
||||||
|
<?xml version="1.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-parent</artifactId>
|
||||||
|
<groupId>org.keycloak</groupId>
|
||||||
|
<version>999-SNAPSHOT</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>keycloak-config-api</artifactId>
|
||||||
|
<name>Keycloak Configuration API</name>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<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>
|
||||||
|
|
||||||
|
</project>
|
13
config-api/src/main/java/org/keycloak/config/AllOptions.java
Normal file
13
config-api/src/main/java/org/keycloak/config/AllOptions.java
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
package org.keycloak.config;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class AllOptions {
|
||||||
|
|
||||||
|
public final static List<Option<?>> ALL_OPTIONS = new ArrayList<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
ALL_OPTIONS.addAll(HttpOptions.ALL_OPTIONS);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package org.keycloak.config;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class HttpOptions {
|
||||||
|
|
||||||
|
public final static Option httpPort = new OptionBuilder<Integer>("http-port", Integer.class)
|
||||||
|
.description("The used HTTP port.")
|
||||||
|
.category(OptionCategory.HTTP)
|
||||||
|
.defaultValue(8080)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
public final static List<Option<?>> ALL_OPTIONS = new ArrayList<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
ALL_OPTIONS.add(httpPort);
|
||||||
|
}
|
||||||
|
}
|
65
config-api/src/main/java/org/keycloak/config/Option.java
Normal file
65
config-api/src/main/java/org/keycloak/config/Option.java
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
package org.keycloak.config;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class Option<T> {
|
||||||
|
|
||||||
|
public enum Runtime {
|
||||||
|
QUARKUS,
|
||||||
|
DOCS,
|
||||||
|
OPERATOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Class<T> type;
|
||||||
|
private final String key;
|
||||||
|
private final OptionCategory category;
|
||||||
|
private final Set<Runtime> supportedRuntimes;
|
||||||
|
private final boolean buildTime;
|
||||||
|
private final String description;
|
||||||
|
private final Optional<T> defaultValue;
|
||||||
|
private final List<T> expectedValues;
|
||||||
|
|
||||||
|
public Option(Class<T> type, String key, OptionCategory category, Set<Runtime> supportedRuntimes, boolean buildTime, String description, Optional<T> defaultValue, List<T> expectedValues) {
|
||||||
|
this.type = type;
|
||||||
|
this.key = key;
|
||||||
|
this.category = category;
|
||||||
|
this.supportedRuntimes = supportedRuntimes;
|
||||||
|
this.buildTime = buildTime;
|
||||||
|
this.description = description;
|
||||||
|
this.defaultValue = defaultValue;
|
||||||
|
this.expectedValues = expectedValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Class<T> getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Runtime> getSupportedRuntimes() {
|
||||||
|
return supportedRuntimes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isBuildTime() {
|
||||||
|
return buildTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OptionCategory getCategory() {
|
||||||
|
return category;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() { return description; }
|
||||||
|
|
||||||
|
public Optional<T> getDefaultValue() {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<T> getExpectedValues() {
|
||||||
|
return expectedValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,85 @@
|
||||||
|
package org.keycloak.config;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class OptionBuilder<T> {
|
||||||
|
private Class<T> type;
|
||||||
|
private String key;
|
||||||
|
private OptionCategory category;
|
||||||
|
private Set<Option.Runtime> supportedRuntimes;
|
||||||
|
private boolean build;
|
||||||
|
private String description;
|
||||||
|
private Optional<T> defaultValue;
|
||||||
|
private List<T> expectedValues;
|
||||||
|
|
||||||
|
public OptionBuilder(String key, Class<T> type) {
|
||||||
|
this.type = type;
|
||||||
|
this.key = key;
|
||||||
|
category = OptionCategory.GENERAL;
|
||||||
|
supportedRuntimes = Arrays.stream(Option.Runtime.values()).collect(Collectors.toSet());
|
||||||
|
build = false;
|
||||||
|
description = "";
|
||||||
|
defaultValue = Optional.empty();
|
||||||
|
expectedValues = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public OptionBuilder<T> category(OptionCategory category) {
|
||||||
|
this.category = category;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OptionBuilder<T> runtimes(Option.Runtime ... runtimes) {
|
||||||
|
this.supportedRuntimes.clear();
|
||||||
|
this.supportedRuntimes.addAll(Arrays.asList(runtimes));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OptionBuilder<T> runtimes(Set<Option.Runtime> runtimes) {
|
||||||
|
this.supportedRuntimes.clear();
|
||||||
|
this.supportedRuntimes.addAll(runtimes);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OptionBuilder<T> buildTime(boolean build) {
|
||||||
|
this.build = build;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OptionBuilder<T> description(String description) {
|
||||||
|
this.description = description;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OptionBuilder<T> defaultValue(Optional<T> defaultV) {
|
||||||
|
this.defaultValue = defaultV;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OptionBuilder<T> defaultValue(T defaultV) {
|
||||||
|
this.defaultValue = Optional.ofNullable(defaultV);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OptionBuilder<T> expectedValues(List<T> expected) {
|
||||||
|
this.expectedValues.clear();
|
||||||
|
this.expectedValues.addAll(expected);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OptionBuilder<T> expectedValues(T ... expected) {
|
||||||
|
this.expectedValues.clear();
|
||||||
|
this.expectedValues.addAll(Arrays.asList(expected));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Option<T> build() {
|
||||||
|
return new Option<T>(type, key, category, supportedRuntimes, build, description, defaultValue, expectedValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
package org.keycloak.quarkus.runtime.configuration.mappers;
|
package org.keycloak.config;
|
||||||
|
|
||||||
public enum ConfigCategory {
|
public enum OptionCategory {
|
||||||
// ordered by name asc
|
// ordered by name asc
|
||||||
CLUSTERING("Cluster", 10),
|
CLUSTERING("Cluster", 10),
|
||||||
DATABASE("Database", 20),
|
DATABASE("Database", 20),
|
||||||
|
@ -20,7 +20,7 @@ public enum ConfigCategory {
|
||||||
//Categories with a lower number are shown before groups with a higher number
|
//Categories with a lower number are shown before groups with a higher number
|
||||||
private final int order;
|
private final int order;
|
||||||
|
|
||||||
ConfigCategory(String heading, int order) {
|
OptionCategory(String heading, int order) {
|
||||||
this.heading = heading; this.order = order;
|
this.heading = heading; this.order = order;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,25 +5,22 @@ import static org.keycloak.quarkus.runtime.configuration.Configuration.toDashCas
|
||||||
import static org.keycloak.quarkus.runtime.configuration.MicroProfileConfigProvider.NS_KEYCLOAK_PREFIX;
|
import static org.keycloak.quarkus.runtime.configuration.MicroProfileConfigProvider.NS_KEYCLOAK_PREFIX;
|
||||||
|
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
import org.keycloak.config.OptionCategory;
|
||||||
import org.keycloak.provider.ProviderConfigProperty;
|
import org.keycloak.provider.ProviderConfigProperty;
|
||||||
import org.keycloak.provider.ProviderFactory;
|
import org.keycloak.provider.ProviderFactory;
|
||||||
import org.keycloak.provider.ProviderManager;
|
import org.keycloak.provider.ProviderManager;
|
||||||
import org.keycloak.provider.Spi;
|
import org.keycloak.provider.Spi;
|
||||||
import org.keycloak.quarkus.runtime.Providers;
|
import org.keycloak.quarkus.runtime.Providers;
|
||||||
import org.keycloak.quarkus.runtime.configuration.Configuration;
|
import org.keycloak.quarkus.runtime.configuration.Configuration;
|
||||||
import org.keycloak.quarkus.runtime.configuration.mappers.ConfigCategory;
|
|
||||||
import org.keycloak.quarkus.runtime.configuration.mappers.PropertyMapper;
|
|
||||||
import org.keycloak.quarkus.runtime.configuration.mappers.PropertyMappers;
|
import org.keycloak.quarkus.runtime.configuration.mappers.PropertyMappers;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.function.Predicate;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.StreamSupport;
|
import java.util.stream.StreamSupport;
|
||||||
|
|
||||||
|
@ -36,7 +33,7 @@ public class Options {
|
||||||
options = PropertyMappers.getMappers().stream()
|
options = PropertyMappers.getMappers().stream()
|
||||||
.filter(m -> !m.isHidden())
|
.filter(m -> !m.isHidden())
|
||||||
.filter(propertyMapper -> Objects.nonNull(propertyMapper.getDescription()))
|
.filter(propertyMapper -> Objects.nonNull(propertyMapper.getDescription()))
|
||||||
.map(m -> new Option(m.getFrom(), m.getCategory(), m.isBuildTime(), m.getDescription(), m.getDefaultValue(), m.getExpectedValues()))
|
.map(m -> new Option(m.getFrom(), m.getCategory(), m.isBuildTime(), m.getDescription(), (String) m.getDefaultValue().map(d -> d.toString()).orElse(null), m.getExpectedValues()))
|
||||||
.sorted(Comparator.comparing(Option::getKey))
|
.sorted(Comparator.comparing(Option::getKey))
|
||||||
.collect(Collectors.toMap(Option::getKey, o -> o, (o1, o2) -> o1, LinkedHashMap::new)); // Need to ignore duplicate keys??
|
.collect(Collectors.toMap(Option::getKey, o -> o, (o1, o2) -> o1, LinkedHashMap::new)); // Need to ignore duplicate keys??
|
||||||
ProviderManager providerManager = Providers.getProviderManager(Thread.currentThread().getContextClassLoader());
|
ProviderManager providerManager = Providers.getProviderManager(Thread.currentThread().getContextClassLoader());
|
||||||
|
@ -51,7 +48,7 @@ public class Options {
|
||||||
|
|
||||||
String optionPrefix = NS_KEYCLOAK_PREFIX + String.join(OPTION_PART_SEPARATOR, ArrayUtils.insert(0, new String[] {loadSpi.getName(), providerFactory.getId()}, "spi"));
|
String optionPrefix = NS_KEYCLOAK_PREFIX + String.join(OPTION_PART_SEPARATOR, ArrayUtils.insert(0, new String[] {loadSpi.getName(), providerFactory.getId()}, "spi"));
|
||||||
List<Option> options = configMetadata.stream()
|
List<Option> options = configMetadata.stream()
|
||||||
.map(m -> new Option(Configuration.toDashCase(optionPrefix.concat("-") + m.getName()), ConfigCategory.GENERAL, false,
|
.map(m -> new Option(Configuration.toDashCase(optionPrefix.concat("-") + m.getName()), OptionCategory.GENERAL, false,
|
||||||
m.getHelpText(),
|
m.getHelpText(),
|
||||||
m.getDefaultValue() == null ? "none" : m.getDefaultValue().toString(),
|
m.getDefaultValue() == null ? "none" : m.getDefaultValue().toString(),
|
||||||
m.getOptions() == null ? (m.getType() == null ? Collections.emptyList() : Collections.singletonList(m.getType())) : m.getOptions()))
|
m.getOptions() == null ? (m.getType() == null ? Collections.emptyList() : Collections.singletonList(m.getType())) : m.getOptions()))
|
||||||
|
@ -64,15 +61,15 @@ public class Options {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigCategory[] getCategories() {
|
public OptionCategory[] getCategories() {
|
||||||
return ConfigCategory.values();
|
return OptionCategory.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<Option> getValues() {
|
public Collection<Option> getValues() {
|
||||||
return options.values();
|
return options.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<Option> getValues(ConfigCategory category) {
|
public Collection<Option> getValues(OptionCategory category) {
|
||||||
return options.values().stream().filter(o -> o.category.equals(category)).collect(Collectors.toList());
|
return options.values().stream().filter(o -> o.category.equals(category)).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,13 +89,13 @@ public class Options {
|
||||||
public class Option {
|
public class Option {
|
||||||
|
|
||||||
private String key;
|
private String key;
|
||||||
private ConfigCategory category;
|
private OptionCategory category;
|
||||||
private boolean build;
|
private boolean build;
|
||||||
private String description;
|
private String description;
|
||||||
private String defaultValue;
|
private String defaultValue;
|
||||||
private List<String> expectedValues;
|
private List<String> expectedValues;
|
||||||
|
|
||||||
public Option(String key, ConfigCategory category, boolean build, String description, String defaultValue, Iterable<String> expectedValues) {
|
public Option(String key, OptionCategory category, boolean build, String description, String defaultValue, Iterable<String> expectedValues) {
|
||||||
this.key = key;
|
this.key = key;
|
||||||
this.category = category;
|
this.category = category;
|
||||||
this.build = build;
|
this.build = build;
|
||||||
|
|
289
operator/app/pom.xml
Normal file
289
operator/app/pom.xml
Normal file
|
@ -0,0 +1,289 @@
|
||||||
|
<?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.2</jackson.version>
|
||||||
|
<jackson.databind.version>2.13.2.2</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.7</quarkus.operator.sdk.version>
|
||||||
|
<quarkus.version>2.7.5.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>
|
||||||
|
<maven-failsafe-plugin.version>2.22.0</maven-failsafe-plugin.version>
|
||||||
|
</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>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-failsafe-plugin</artifactId>
|
||||||
|
<version>${maven-failsafe-plugin.version}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>integration-test</goal>
|
||||||
|
<goal>verify</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>native</id>
|
||||||
|
<properties>
|
||||||
|
<quarkus.package.type>native</quarkus.package.type>
|
||||||
|
</properties>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
</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,8 +18,8 @@ VERSION="86400000.0.0"
|
||||||
|
|
||||||
# Build the operator Docker image
|
# Build the operator Docker image
|
||||||
(
|
(
|
||||||
cd $SCRIPT_DIR/../
|
cd $SCRIPT_DIR/../../
|
||||||
mvn clean package \
|
mvn clean package -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}" \
|
||||||
-Doperator.keycloak.image="ttl.sh/${UUID}keycloak:${VERSION}" \
|
-Doperator.keycloak.image="ttl.sh/${UUID}keycloak:${VERSION}" \
|
|
@ -20,6 +20,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
|
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
|
||||||
|
|
||||||
import org.keycloak.operator.Constants;
|
import org.keycloak.operator.Constants;
|
||||||
|
import org.keycloak.operator.codegen.configuration.ServerConfig;
|
||||||
import org.keycloak.operator.v2alpha1.crds.keycloakspec.Unsupported;
|
import org.keycloak.operator.v2alpha1.crds.keycloakspec.Unsupported;
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
@ -35,6 +36,9 @@ public class KeycloakSpec {
|
||||||
"expressed as a keys (reference: https://www.keycloak.org/server/all-config) and values that can be either direct values or references to secrets.")
|
"expressed as a keys (reference: https://www.keycloak.org/server/all-config) and values that can be either direct values or references to secrets.")
|
||||||
private List<ValueOrSecret> serverConfiguration; // can't use Set due to a bug in Sundrio https://github.com/sundrio/sundrio/issues/316
|
private List<ValueOrSecret> serverConfiguration; // can't use Set due to a bug in Sundrio https://github.com/sundrio/sundrio/issues/316
|
||||||
|
|
||||||
|
// TODO: switch to this serverConfig when all the options are ported
|
||||||
|
// private ServerConfig serverConfig;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@JsonPropertyDescription("Hostname for the Keycloak server.\n" +
|
@JsonPropertyDescription("Hostname for the Keycloak server.\n" +
|
||||||
"The special value `" + Constants.INSECURE_DISABLE + "` disables the hostname strict resolution.")
|
"The special value `" + Constants.INSECURE_DISABLE + "` disables the hostname strict resolution.")
|
66
operator/maven-plugin/pom.xml
Normal file
66
operator/maven-plugin/pom.xml
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
|
||||||
|
<!--
|
||||||
|
~ 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>
|
|
@ -0,0 +1,32 @@
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,83 @@
|
||||||
|
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()));
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
292
operator/pom.xml
Normal file → Executable file
292
operator/pom.xml
Normal file → Executable file
|
@ -1,272 +1,36 @@
|
||||||
<?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"
|
~ Copyright 2016 Red Hat, Inc. and/or its affiliates
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
~ and other contributors as indicated by the @author tags.
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
~
|
||||||
<modelVersion>4.0.0</modelVersion>
|
~ 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>
|
<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>
|
||||||
</parent>
|
</parent>
|
||||||
|
<name>Keycloak Operator Parent</name>
|
||||||
<name>Keycloak Operator</name>
|
<description/>
|
||||||
<artifactId>keycloak-operator</artifactId>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<properties>
|
<artifactId>keycloak-operator-parent</artifactId>
|
||||||
<!--
|
<packaging>pom</packaging>
|
||||||
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.2</jackson.version>
|
|
||||||
<jackson.databind.version>2.13.2.2</jackson.databind.version>
|
|
||||||
<kubernetes-client.version>5.12.2</kubernetes-client.version>
|
|
||||||
|
|
||||||
<compiler-plugin.version>3.8.1</compiler-plugin.version>
|
<modules>
|
||||||
<maven.compiler.parameters>true</maven.compiler.parameters>
|
<module>maven-plugin</module>
|
||||||
<maven.compiler.release>11</maven.compiler.release>
|
<module>app</module>
|
||||||
<maven.compiler.source>11</maven.compiler.source>
|
</modules>
|
||||||
<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.7</quarkus.operator.sdk.version>
|
|
||||||
<quarkus.version>2.7.5.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>
|
|
||||||
<maven-failsafe-plugin.version>2.22.0</maven-failsafe-plugin.version>
|
|
||||||
</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>
|
|
||||||
</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-failsafe-plugin</artifactId>
|
|
||||||
<version>${maven-failsafe-plugin.version}</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<goals>
|
|
||||||
<goal>integration-test</goal>
|
|
||||||
<goal>verify</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>
|
||||||
|
|
21
pom.xml
21
pom.xml
|
@ -133,6 +133,7 @@
|
||||||
<apacheds.codec.version>2.0.0</apacheds.codec.version>
|
<apacheds.codec.version>2.0.0</apacheds.codec.version>
|
||||||
<google.zxing.version>3.4.0</google.zxing.version>
|
<google.zxing.version>3.4.0</google.zxing.version>
|
||||||
<freemarker.version>2.3.31</freemarker.version>
|
<freemarker.version>2.3.31</freemarker.version>
|
||||||
|
<javaparser.version>3.24.2</javaparser.version>
|
||||||
|
|
||||||
<jetty9.version>${jetty94.version}</jetty9.version>
|
<jetty9.version>${jetty94.version}</jetty9.version>
|
||||||
<liquibase.version>4.8.0</liquibase.version>
|
<liquibase.version>4.8.0</liquibase.version>
|
||||||
|
@ -1028,6 +1029,11 @@
|
||||||
<artifactId>keycloak-core</artifactId>
|
<artifactId>keycloak-core</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.keycloak</groupId>
|
||||||
|
<artifactId>keycloak-config-api</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.keycloak</groupId>
|
<groupId>org.keycloak</groupId>
|
||||||
<artifactId>keycloak-client-api</artifactId>
|
<artifactId>keycloak-client-api</artifactId>
|
||||||
|
@ -1596,6 +1602,11 @@
|
||||||
<artifactId>commons-io</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
<version>${commons-io.version}</version>
|
<version>${commons-io.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.javaparser</groupId>
|
||||||
|
<artifactId>javaparser-core</artifactId>
|
||||||
|
<version>${javaparser.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.microprofile.metrics</groupId>
|
<groupId>org.eclipse.microprofile.metrics</groupId>
|
||||||
|
@ -1871,6 +1882,16 @@
|
||||||
</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>
|
||||||
|
|
|
@ -251,6 +251,16 @@
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.keycloak</groupId>
|
||||||
|
<artifactId>keycloak-config-api</artifactId>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>*</groupId>
|
||||||
|
<artifactId>*</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- Keycloak Dependencies-->
|
<!-- Keycloak Dependencies-->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -47,6 +47,7 @@ import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.eclipse.microprofile.config.spi.ConfigSource;
|
import org.eclipse.microprofile.config.spi.ConfigSource;
|
||||||
|
import org.keycloak.config.OptionCategory;
|
||||||
import org.keycloak.quarkus.runtime.cli.command.Build;
|
import org.keycloak.quarkus.runtime.cli.command.Build;
|
||||||
import org.keycloak.quarkus.runtime.cli.command.ImportRealmMixin;
|
import org.keycloak.quarkus.runtime.cli.command.ImportRealmMixin;
|
||||||
import org.keycloak.quarkus.runtime.cli.command.Main;
|
import org.keycloak.quarkus.runtime.cli.command.Main;
|
||||||
|
@ -55,7 +56,6 @@ import org.keycloak.quarkus.runtime.cli.command.StartDev;
|
||||||
import org.keycloak.quarkus.runtime.configuration.ConfigArgsConfigSource;
|
import org.keycloak.quarkus.runtime.configuration.ConfigArgsConfigSource;
|
||||||
import org.keycloak.quarkus.runtime.configuration.PersistedConfigSource;
|
import org.keycloak.quarkus.runtime.configuration.PersistedConfigSource;
|
||||||
import org.keycloak.quarkus.runtime.configuration.QuarkusPropertiesConfigSource;
|
import org.keycloak.quarkus.runtime.configuration.QuarkusPropertiesConfigSource;
|
||||||
import org.keycloak.quarkus.runtime.configuration.mappers.ConfigCategory;
|
|
||||||
import org.keycloak.quarkus.runtime.configuration.mappers.PropertyMappers;
|
import org.keycloak.quarkus.runtime.configuration.mappers.PropertyMappers;
|
||||||
import org.keycloak.quarkus.runtime.configuration.mappers.PropertyMapper;
|
import org.keycloak.quarkus.runtime.configuration.mappers.PropertyMapper;
|
||||||
import org.keycloak.quarkus.runtime.Environment;
|
import org.keycloak.quarkus.runtime.Environment;
|
||||||
|
@ -259,7 +259,7 @@ public final class Picocli {
|
||||||
if (runtimeValue == null && isNotBlank(persistedValue)) {
|
if (runtimeValue == null && isNotBlank(persistedValue)) {
|
||||||
PropertyMapper mapper = PropertyMappers.getMapper(propertyName);
|
PropertyMapper mapper = PropertyMappers.getMapper(propertyName);
|
||||||
|
|
||||||
if (mapper != null && persistedValue.equals(mapper.getDefaultValue())) {
|
if (mapper != null && persistedValue.equals(mapper.getDefaultValue().orElse(null))) {
|
||||||
// same as default
|
// same as default
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -381,7 +381,7 @@ public final class Picocli {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addMappedOptionsToArgGroups(CommandSpec cSpec, List<PropertyMapper> propertyMappers) {
|
private static void addMappedOptionsToArgGroups(CommandSpec cSpec, List<PropertyMapper> propertyMappers) {
|
||||||
for(ConfigCategory category : ConfigCategory.values()) {
|
for(OptionCategory category : OptionCategory.values()) {
|
||||||
List<PropertyMapper> mappersInCategory = propertyMappers.stream()
|
List<PropertyMapper> mappersInCategory = propertyMappers.stream()
|
||||||
.filter(m -> category.equals(m.getCategory()))
|
.filter(m -> category.equals(m.getCategory()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
@ -405,18 +405,26 @@ public final class Picocli {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
String defaultValue = mapper.getDefaultValue();
|
|
||||||
Iterable<String> expectedValues = mapper.getExpectedValues();
|
Iterable<String> expectedValues = mapper.getExpectedValues();
|
||||||
|
|
||||||
argGroupBuilder.addArg(OptionSpec.builder(name)
|
OptionSpec.Builder optBuilder = OptionSpec.builder(name)
|
||||||
.defaultValue(defaultValue)
|
|
||||||
.description(description)
|
.description(description)
|
||||||
.paramLabel(mapper.getParamLabel())
|
.paramLabel(mapper.getParamLabel())
|
||||||
.completionCandidates(expectedValues)
|
.completionCandidates(expectedValues)
|
||||||
.parameterConsumer(PropertyMapperParameterConsumer.INSTANCE)
|
.parameterConsumer(PropertyMapperParameterConsumer.INSTANCE)
|
||||||
.type(String.class)
|
.hidden(mapper.isHidden());
|
||||||
.hidden(mapper.isHidden())
|
|
||||||
.build());
|
if (mapper.getDefaultValue().isPresent()) {
|
||||||
|
optBuilder.defaultValue(mapper.getDefaultValue().get().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mapper.getType() != null) {
|
||||||
|
optBuilder.type(mapper.getType());
|
||||||
|
} else {
|
||||||
|
optBuilder.type(String.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
argGroupBuilder.addArg(optBuilder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
cSpec.addArgGroup(argGroupBuilder.build());
|
cSpec.addArgGroup(argGroupBuilder.build());
|
||||||
|
|
|
@ -3,6 +3,7 @@ package org.keycloak.quarkus.runtime.configuration.mappers;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
|
import org.keycloak.config.OptionCategory;
|
||||||
import org.keycloak.quarkus.runtime.Environment;
|
import org.keycloak.quarkus.runtime.Environment;
|
||||||
|
|
||||||
import io.smallrye.config.ConfigSourceInterceptorContext;
|
import io.smallrye.config.ConfigSourceInterceptorContext;
|
||||||
|
@ -64,6 +65,6 @@ final class ClusteringPropertyMappers {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PropertyMapper.Builder builder() {
|
private static PropertyMapper.Builder builder() {
|
||||||
return PropertyMapper.builder(ConfigCategory.CLUSTERING);
|
return PropertyMapper.builder(OptionCategory.CLUSTERING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package org.keycloak.quarkus.runtime.configuration.mappers;
|
||||||
import io.quarkus.datasource.common.runtime.DatabaseKind;
|
import io.quarkus.datasource.common.runtime.DatabaseKind;
|
||||||
import io.smallrye.config.ConfigSourceInterceptorContext;
|
import io.smallrye.config.ConfigSourceInterceptorContext;
|
||||||
import io.smallrye.config.ConfigValue;
|
import io.smallrye.config.ConfigValue;
|
||||||
|
import org.keycloak.config.OptionCategory;
|
||||||
import org.keycloak.quarkus.runtime.storage.database.Database;
|
import org.keycloak.quarkus.runtime.storage.database.Database;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
@ -129,8 +130,8 @@ final class DatabasePropertyMappers {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PropertyMapper.Builder builder() {
|
private static <T> PropertyMapper.Builder<T> builder() {
|
||||||
return PropertyMapper.builder(ConfigCategory.DATABASE);
|
return PropertyMapper.builder(OptionCategory.DATABASE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String resolveUsername(String value, ConfigSourceInterceptorContext context) {
|
private static String resolveUsername(String value, ConfigSourceInterceptorContext context) {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package org.keycloak.quarkus.runtime.configuration.mappers;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.keycloak.common.Profile;
|
import org.keycloak.common.Profile;
|
||||||
|
import org.keycloak.config.OptionCategory;
|
||||||
|
|
||||||
final class FeaturePropertyMappers {
|
final class FeaturePropertyMappers {
|
||||||
|
|
||||||
|
@ -39,6 +40,6 @@ final class FeaturePropertyMappers {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PropertyMapper.Builder builder() {
|
private static PropertyMapper.Builder builder() {
|
||||||
return PropertyMapper.builder(ConfigCategory.FEATURE).isBuildTimeProperty(true);
|
return PropertyMapper.builder(OptionCategory.FEATURE).isBuildTimeProperty(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package org.keycloak.quarkus.runtime.configuration.mappers;
|
package org.keycloak.quarkus.runtime.configuration.mappers;
|
||||||
|
|
||||||
|
import org.keycloak.config.OptionCategory;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,6 +23,6 @@ final class HealthPropertyMappers {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PropertyMapper.Builder builder() {
|
private static PropertyMapper.Builder builder() {
|
||||||
return PropertyMapper.builder(ConfigCategory.HEALTH);
|
return PropertyMapper.builder(OptionCategory.HEALTH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package org.keycloak.quarkus.runtime.configuration.mappers;
|
package org.keycloak.quarkus.runtime.configuration.mappers;
|
||||||
|
|
||||||
|
|
||||||
|
import org.keycloak.config.OptionCategory;
|
||||||
|
|
||||||
final class HostnamePropertyMappers {
|
final class HostnamePropertyMappers {
|
||||||
|
|
||||||
private HostnamePropertyMappers(){}
|
private HostnamePropertyMappers(){}
|
||||||
|
@ -45,6 +47,6 @@ final class HostnamePropertyMappers {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PropertyMapper.Builder builder() {
|
private static PropertyMapper.Builder builder() {
|
||||||
return PropertyMapper.builder(ConfigCategory.HOSTNAME);
|
return PropertyMapper.builder(OptionCategory.HOSTNAME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,9 @@ package org.keycloak.quarkus.runtime.configuration.mappers;
|
||||||
|
|
||||||
import io.smallrye.config.ConfigSourceInterceptorContext;
|
import io.smallrye.config.ConfigSourceInterceptorContext;
|
||||||
import io.smallrye.config.ConfigValue;
|
import io.smallrye.config.ConfigValue;
|
||||||
|
import org.keycloak.config.HttpOptions;
|
||||||
|
import org.keycloak.config.Option;
|
||||||
|
import org.keycloak.config.OptionCategory;
|
||||||
import org.keycloak.quarkus.runtime.Environment;
|
import org.keycloak.quarkus.runtime.Environment;
|
||||||
import org.keycloak.quarkus.runtime.Messages;
|
import org.keycloak.quarkus.runtime.Messages;
|
||||||
import org.keycloak.quarkus.runtime.configuration.MicroProfileConfigProvider;
|
import org.keycloak.quarkus.runtime.configuration.MicroProfileConfigProvider;
|
||||||
|
@ -10,6 +13,7 @@ import java.io.File;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import static org.keycloak.quarkus.runtime.configuration.mappers.PropertyMapper.fromOption;
|
||||||
import static org.keycloak.quarkus.runtime.configuration.mappers.PropertyMappers.getMapper;
|
import static org.keycloak.quarkus.runtime.configuration.mappers.PropertyMappers.getMapper;
|
||||||
import static org.keycloak.quarkus.runtime.integration.QuarkusPlatform.addInitializationException;
|
import static org.keycloak.quarkus.runtime.integration.QuarkusPlatform.addInitializationException;
|
||||||
|
|
||||||
|
@ -40,10 +44,8 @@ final class HttpPropertyMappers {
|
||||||
.paramLabel("path")
|
.paramLabel("path")
|
||||||
.isBuildTimeProperty(true)
|
.isBuildTimeProperty(true)
|
||||||
.build(),
|
.build(),
|
||||||
builder().from("http-port")
|
fromOption(HttpOptions.httpPort)
|
||||||
.to("quarkus.http.port")
|
.to("quarkus.http.port")
|
||||||
.defaultValue(String.valueOf(8080))
|
|
||||||
.description("The used HTTP port.")
|
|
||||||
.paramLabel("port")
|
.paramLabel("port")
|
||||||
.build(),
|
.build(),
|
||||||
builder().from("https-port")
|
builder().from("https-port")
|
||||||
|
@ -159,8 +161,6 @@ final class HttpPropertyMappers {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PropertyMapper.Builder builder() {
|
private static <T> PropertyMapper.Builder<T> builder() { return PropertyMapper.<T> builder(OptionCategory.HTTP); }
|
||||||
return PropertyMapper.builder(ConfigCategory.HTTP);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import java.util.function.BiFunction;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.jboss.logmanager.LogContext;
|
import org.jboss.logmanager.LogContext;
|
||||||
|
import org.keycloak.config.OptionCategory;
|
||||||
import org.keycloak.quarkus.runtime.Messages;
|
import org.keycloak.quarkus.runtime.Messages;
|
||||||
|
|
||||||
import io.smallrye.config.ConfigSourceInterceptorContext;
|
import io.smallrye.config.ConfigSourceInterceptorContext;
|
||||||
|
@ -175,7 +176,7 @@ public final class LoggingPropertyMappers {
|
||||||
LogContext.getLogContext().getLogger(category).setLevel(toLevel(level));
|
LogContext.getLogContext().getLogger(category).setLevel(toLevel(level));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PropertyMapper.Builder builder() {
|
private static <T> PropertyMapper.Builder<T> builder() {
|
||||||
return PropertyMapper.builder(ConfigCategory.LOGGING);
|
return PropertyMapper.builder(OptionCategory.LOGGING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package org.keycloak.quarkus.runtime.configuration.mappers;
|
package org.keycloak.quarkus.runtime.configuration.mappers;
|
||||||
|
|
||||||
|
import org.keycloak.config.OptionCategory;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,6 +23,6 @@ final class MetricsPropertyMappers {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PropertyMapper.Builder builder() {
|
private static PropertyMapper.Builder builder() {
|
||||||
return PropertyMapper.builder(ConfigCategory.METRICS);
|
return PropertyMapper.builder(OptionCategory.METRICS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue