Repository navigation
Operator CRD with generated ServerConfiguration from refactored config #11929
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 changes: 13 additions & 0 deletions
13
config-api/src/main/java/org/keycloak/config/AllOptions.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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); | ||
| } | ||
| } |
20 changes: 20 additions & 0 deletions
20
config-api/src/main/java/org/keycloak/config/HttpOptions.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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; | ||
| } | ||
|
|
||
| } |
85 changes: 85 additions & 0 deletions
85
config-api/src/main/java/org/keycloak/config/OptionBuilder.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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; | ||
|
|
||
| 10BC8 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); | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we replace this class and
Optionnow we have similar types in from the new module?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can replace some of this, unfortunately, looks like
SPIs configuration is still not covered:keycloak/docs/maven-plugin/src/main/java/org/keycloak/guides/maven/Options.java
Lines 44 to 64 in 3ff3aeb
In this PR I took out the docs bit to be able to perform the change incrementally (i.e. with subsequent non-breaking PRs)
E.g. the
docssub-module will rely on the new configuration only after we move all the configuration keys to the new encoding.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although we don't have yet a proper support for exposing SPI configuration options, the new module should be able to provide them similarly to what you did to
HttpOptions.The difference here is that these options are dynamic as they come from whatever provider is installed on the server. In the future, and that is related to the extension story, it should also resolve options from custom providers.
If you want, I can look at this closer and try to come up with something to support this.