Rename free-form field from 'serverConfiguration' to 'additionalOptions' in Keycloak CR.

This commit is contained in:
Andre Nascimento RH 2022-10-21 14:41:02 +02:00 committed by GitHub
parent 24acc4c7d1
commit d12aef0b43
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 33 additions and 33 deletions

View file

@ -12,7 +12,7 @@ In this guide, you'll learn how to configure your Keycloak deployment using adva
=== Server Configuration details === Server Configuration details
The `serverConfiguration` field of the Keycloak CR allows to pass to Keycloak any available configuration in the form of key-value pairs. The `additionalOptions` field of the Keycloak CR allows to pass to Keycloak any available configuration in the form of key-value pairs.
For all the available configuration options, refer to <@links.server id="all-config"/>. For all the available configuration options, refer to <@links.server id="all-config"/>.
The values can be expressed as plain text strings or Kubernetes Secret references. The values can be expressed as plain text strings or Kubernetes Secret references.
@ -26,7 +26,7 @@ metadata:
name: example-kc name: example-kc
spec: spec:
... ...
serverConfiguration: additionalOptions:
- name: db - name: db
value: postgres # plain text value value: postgres # plain text value
- name: db-url-host - name: db-url-host
@ -43,7 +43,7 @@ spec:
=== Secret References === Secret References
A Secret Reference can be either a value in `serverConfiguration` or the `tlsSecret`. A Secret Reference can be either a value in `additionalOptions` or the `tlsSecret`.
When specifying a Secret Reference, you have to make sure that a Secret containing the referenced keys is present in the same namespace as the CR referencing it. When specifying a Secret Reference, you have to make sure that a Secret containing the referenced keys is present in the same namespace as the CR referencing it.
Along with the Keycloak Server Deployment, the operator adds special labels to the referenced Secrets in order to watch for changes. Along with the Keycloak Server Deployment, the operator adds special labels to the referenced Secrets in order to watch for changes.

View file

@ -120,7 +120,7 @@ metadata:
name: example-kc name: example-kc
spec: spec:
instances: 1 instances: 1
serverConfiguration: additionalOptions:
- name: db - name: db
value: postgres value: postgres
- name: db-url-host - name: db-url-host

View file

@ -44,6 +44,6 @@ spec:
.Note: .Note:
[NOTE] [NOTE]
Using custom images, every build time configuration passed through the `serverConfiguration` key will be ignored. Using custom images, every build time configuration passed through the `additionalOptions` key will be ignored.
</@tmpl.guide> </@tmpl.guide>

View file

@ -436,9 +436,9 @@ public class KeycloakDeployment extends OperatorManagedResource implements Statu
.collect(Collectors.toList()); .collect(Collectors.toList());
// merge with the CR; the values in CR take precedence // merge with the CR; the values in CR take precedence
if (keycloakCR.getSpec().getServerConfiguration() != null) { if (keycloakCR.getSpec().getAdditionalOptions() != null) {
serverConfig.removeAll(keycloakCR.getSpec().getServerConfiguration()); serverConfig.removeAll(keycloakCR.getSpec().getAdditionalOptions());
serverConfig.addAll(keycloakCR.getSpec().getServerConfiguration()); serverConfig.addAll(keycloakCR.getSpec().getAdditionalOptions());
} }
// set env vars // set env vars
@ -564,12 +564,12 @@ public class KeycloakDeployment extends OperatorManagedResource implements Statu
protected String readConfigurationValue(String key) { protected String readConfigurationValue(String key) {
if (keycloakCR != null && if (keycloakCR != null &&
keycloakCR.getSpec() != null && keycloakCR.getSpec() != null &&
keycloakCR.getSpec().getServerConfiguration() != null keycloakCR.getSpec().getAdditionalOptions() != null
) { ) {
var serverConfigValue = keycloakCR var serverConfigValue = keycloakCR
.getSpec() .getSpec()
.getServerConfiguration() .getAdditionalOptions()
.stream() .stream()
.filter(sc -> sc.getName().equals(key)) .filter(sc -> sc.getName().equals(key))
.findFirst(); .findFirst();

View file

@ -178,7 +178,7 @@ public class KeycloakDistConfigurator {
protected void assumeFirstClassCitizens(KeycloakStatusBuilder status) { protected void assumeFirstClassCitizens(KeycloakStatusBuilder status) {
final var serverConfigNames = keycloakCR final var serverConfigNames = keycloakCR
.getSpec() .getSpec()
.getServerConfiguration() .getAdditionalOptions()
.stream() .stream()
.map(ValueOrSecret::getName) .map(ValueOrSecret::getName)
.collect(Collectors.toSet()); .collect(Collectors.toSet());

View file

@ -44,7 +44,7 @@ public class KeycloakSpec {
@JsonPropertyDescription("Configuration of the Keycloak server.\n" + @JsonPropertyDescription("Configuration of the Keycloak server.\n" +
"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> additionalOptions; // can't use Set due to a bug in Sundrio https://github.com/sundrio/sundrio/issues/316
@JsonProperty("http") @JsonProperty("http")
@JsonPropertyDescription("In this section you can configure Keycloak features related to HTTP and HTTPS") @JsonPropertyDescription("In this section you can configure Keycloak features related to HTTP and HTTPS")
@ -156,14 +156,14 @@ public class KeycloakSpec {
this.imagePullSecrets = imagePullSecrets; this.imagePullSecrets = imagePullSecrets;
} }
public List<ValueOrSecret> getServerConfiguration() { public List<ValueOrSecret> getAdditionalOptions() {
if (serverConfiguration == null) { if (this.additionalOptions == null) {
serverConfiguration = new ArrayList<>(); this.additionalOptions = new ArrayList<>();
} }
return serverConfiguration; return additionalOptions;
} }
public void setServerConfiguration(List<ValueOrSecret> serverConfiguration) { public void setAdditionalOptions(List<ValueOrSecret> additionalOptions) {
this.serverConfiguration = serverConfiguration; this.additionalOptions = additionalOptions;
} }
} }

View file

@ -100,8 +100,8 @@ public class KeycloakDeploymentTest extends BaseOperatorTest {
final var dbConf = new ValueOrSecret("db-password", "Ay Caramba!"); final var dbConf = new ValueOrSecret("db-password", "Ay Caramba!");
kc.getSpec().setImage("quay.io/keycloak/non-existing-keycloak"); kc.getSpec().setImage("quay.io/keycloak/non-existing-keycloak");
kc.getSpec().getServerConfiguration().remove(dbConf); kc.getSpec().getAdditionalOptions().remove(dbConf);
kc.getSpec().getServerConfiguration().add(dbConf); kc.getSpec().getAdditionalOptions().add(dbConf);
deployKeycloak(k8sclient, kc, false); deployKeycloak(k8sclient, kc, false);
Awaitility.await() Awaitility.await()
@ -131,7 +131,7 @@ public class KeycloakDeploymentTest extends BaseOperatorTest {
.withName(KeycloakDistConfigurator.getKeycloakOptionEnvVarName(health.getName())) .withName(KeycloakDistConfigurator.getKeycloakOptionEnvVarName(health.getName()))
.withValue(health.getValue()) .withValue(health.getValue())
.build(); .build();
kc.getSpec().getServerConfiguration().add(health); kc.getSpec().getAdditionalOptions().add(health);
deployKeycloak(k8sclient, kc, false); deployKeycloak(k8sclient, kc, false);
assertThat(Constants.DEFAULT_DIST_CONFIG.get(health.getName())).isEqualTo("true"); // just a sanity check default values did not change assertThat(Constants.DEFAULT_DIST_CONFIG.get(health.getName())).isEqualTo("true"); // just a sanity check default values did not change
@ -483,7 +483,7 @@ public class KeycloakDeploymentTest extends BaseOperatorTest {
public void testHttpRelativePathWithPlainValue() { public void testHttpRelativePathWithPlainValue() {
try { try {
var kc = getDefaultKeycloakDeployment(); var kc = getDefaultKeycloakDeployment();
kc.getSpec().getServerConfiguration().add(new ValueOrSecret(Constants.KEYCLOAK_HTTP_RELATIVE_PATH_KEY, "/foobar")); kc.getSpec().getAdditionalOptions().add(new ValueOrSecret(Constants.KEYCLOAK_HTTP_RELATIVE_PATH_KEY, "/foobar"));
deployKeycloak(k8sclient, kc, true); deployKeycloak(k8sclient, kc, true);
var pods = k8sclient var pods = k8sclient
@ -515,7 +515,7 @@ public class KeycloakDeploymentTest extends BaseOperatorTest {
.build(); .build();
k8sclient.secrets().inNamespace(namespace).createOrReplace(httpRelativePathSecret); k8sclient.secrets().inNamespace(namespace).createOrReplace(httpRelativePathSecret);
kc.getSpec().getServerConfiguration().add(new ValueOrSecret(Constants.KEYCLOAK_HTTP_RELATIVE_PATH_KEY, kc.getSpec().getAdditionalOptions().add(new ValueOrSecret(Constants.KEYCLOAK_HTTP_RELATIVE_PATH_KEY,
new SecretKeySelectorBuilder() new SecretKeySelectorBuilder()
.withName(secretName) .withName(secretName)
.withKey(keyName) .withKey(keyName)

View file

@ -146,7 +146,7 @@ public class RealmImportTest extends BaseOperatorTest {
keycloak.getSpec().setImage(customImage); keycloak.getSpec().setImage(customImage);
// Removing the Database so that a subsequent build will by default act on h2 // Removing the Database so that a subsequent build will by default act on h2
// TODO: uncomment the following line after resolution of: https://github.com/keycloak/keycloak/issues/11767 // TODO: uncomment the following line after resolution of: https://github.com/keycloak/keycloak/issues/11767
// keycloak.getSpec().getServerConfiguration().removeIf(sc -> sc.getName().equals("db")); // keycloak.getSpec().getAdditionalOptions().removeIf(sc -> sc.getName().equals("db"));
deployKeycloak(k8sclient, keycloak, false); deployKeycloak(k8sclient, keycloak, false);
// Act // Act

View file

@ -278,10 +278,10 @@ public class WatchedSecretsTest extends BaseOperatorTest {
var username = new ValueOrSecret("db-username", "postgres"); var username = new ValueOrSecret("db-username", "postgres");
var password = new ValueOrSecret("db-password", "testpassword"); var password = new ValueOrSecret("db-password", "testpassword");
kc.getSpec().getServerConfiguration().remove(username); kc.getSpec().getAdditionalOptions().remove(username);
kc.getSpec().getServerConfiguration().add(username); kc.getSpec().getAdditionalOptions().add(username);
kc.getSpec().getServerConfiguration().remove(password); kc.getSpec().getAdditionalOptions().remove(password);
kc.getSpec().getServerConfiguration().add(password); kc.getSpec().getAdditionalOptions().add(password);
} }
@AfterEach @AfterEach

View file

@ -55,7 +55,7 @@ public class CRSerializationTest {
assertThat(transactionsSpec.isXaEnabled(), notNullValue()); assertThat(transactionsSpec.isXaEnabled(), notNullValue());
assertThat(transactionsSpec.isXaEnabled(), CoreMatchers.is(false)); assertThat(transactionsSpec.isXaEnabled(), CoreMatchers.is(false));
List<ValueOrSecret> serverConfiguration = keycloak.getSpec().getServerConfiguration(); List<ValueOrSecret> serverConfiguration = keycloak.getSpec().getAdditionalOptions();
assertNotNull(serverConfiguration); assertNotNull(serverConfiguration);
assertFalse(serverConfiguration.isEmpty()); assertFalse(serverConfiguration.isEmpty());

View file

@ -158,7 +158,7 @@ public class KeycloakDistConfiguratorTest {
.map(f -> new ValueOrSecret(f, "foo")) .map(f -> new ValueOrSecret(f, "foo"))
.collect(Collectors.toUnmodifiableList()); .collect(Collectors.toUnmodifiableList());
keycloak.getSpec().setServerConfiguration(serverConfig); keycloak.getSpec().setAdditionalOptions(serverConfig);
final var expectedFields = expectedValues.keySet(); final var expectedFields = expectedValues.keySet();

View file

@ -4,7 +4,7 @@ metadata:
name: example-podtemplate-kc name: example-podtemplate-kc
spec: spec:
instances: 1 instances: 1
serverConfiguration: additionalOptions:
- name: db - name: db
value: postgres value: postgres
- name: db-url-host - name: db-url-host

View file

@ -4,7 +4,7 @@ metadata:
name: example-podtemplate name: example-podtemplate
spec: spec:
instances: 1 instances: 1
serverConfiguration: additionalOptions:
- name: db - name: db
value: postgres value: postgres
- name: db-url-host - name: db-url-host

View file

@ -5,7 +5,7 @@ metadata:
spec: spec:
instances: 3 instances: 3
image: my-image image: my-image
serverConfiguration: additionalOptions:
- name: key1 - name: key1
value: value1 value: value1
- name: features - name: features