From d12aef0b433a71f5a542486d708e8831886a2bab Mon Sep 17 00:00:00 2001 From: Andre Nascimento RH <90404766+andre-nascimento-rh@users.noreply.github.com> Date: Fri, 21 Oct 2022 14:41:02 +0200 Subject: [PATCH] Rename free-form field from 'serverConfiguration' to 'additionalOptions' in Keycloak CR. --- .../src/main/operator/advanced-configuration.adoc | 6 +++--- .../guides/src/main/operator/basic-deployment.adoc | 2 +- .../src/main/operator/customizing-keycloak.adoc | 2 +- .../operator/controllers/KeycloakDeployment.java | 10 +++++----- .../controllers/KeycloakDistConfigurator.java | 2 +- .../crds/v2alpha1/deployment/KeycloakSpec.java | 14 +++++++------- .../integration/KeycloakDeploymentTest.java | 10 +++++----- .../testsuite/integration/RealmImportTest.java | 2 +- .../testsuite/integration/WatchedSecretsTest.java | 8 ++++---- .../testsuite/unit/CRSerializationTest.java | 2 +- .../unit/KeycloakDistConfiguratorTest.java | 2 +- .../resources/correct-podtemplate-keycloak.yml | 2 +- .../test/resources/empty-podtemplate-keycloak.yml | 2 +- .../resources/test-serialization-keycloak-cr.yml | 2 +- 14 files changed, 33 insertions(+), 33 deletions(-) diff --git a/docs/guides/src/main/operator/advanced-configuration.adoc b/docs/guides/src/main/operator/advanced-configuration.adoc index 5a8773052e..10e3131196 100644 --- a/docs/guides/src/main/operator/advanced-configuration.adoc +++ b/docs/guides/src/main/operator/advanced-configuration.adoc @@ -12,7 +12,7 @@ In this guide, you'll learn how to configure your Keycloak deployment using adva === 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"/>. The values can be expressed as plain text strings or Kubernetes Secret references. @@ -26,7 +26,7 @@ metadata: name: example-kc spec: ... - serverConfiguration: + additionalOptions: - name: db value: postgres # plain text value - name: db-url-host @@ -43,7 +43,7 @@ spec: === 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. Along with the Keycloak Server Deployment, the operator adds special labels to the referenced Secrets in order to watch for changes. diff --git a/docs/guides/src/main/operator/basic-deployment.adoc b/docs/guides/src/main/operator/basic-deployment.adoc index f5bfd018a3..4716b7f046 100644 --- a/docs/guides/src/main/operator/basic-deployment.adoc +++ b/docs/guides/src/main/operator/basic-deployment.adoc @@ -120,7 +120,7 @@ metadata: name: example-kc spec: instances: 1 - serverConfiguration: + additionalOptions: - name: db value: postgres - name: db-url-host diff --git a/docs/guides/src/main/operator/customizing-keycloak.adoc b/docs/guides/src/main/operator/customizing-keycloak.adoc index d1a88fc4fd..97f704d177 100644 --- a/docs/guides/src/main/operator/customizing-keycloak.adoc +++ b/docs/guides/src/main/operator/customizing-keycloak.adoc @@ -44,6 +44,6 @@ spec: .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. diff --git a/operator/src/main/java/org/keycloak/operator/controllers/KeycloakDeployment.java b/operator/src/main/java/org/keycloak/operator/controllers/KeycloakDeployment.java index b610ace59e..8b5757201d 100644 --- a/operator/src/main/java/org/keycloak/operator/controllers/KeycloakDeployment.java +++ b/operator/src/main/java/org/keycloak/operator/controllers/KeycloakDeployment.java @@ -436,9 +436,9 @@ public class KeycloakDeployment extends OperatorManagedResource implements Statu .collect(Collectors.toList()); // merge with the CR; the values in CR take precedence - if (keycloakCR.getSpec().getServerConfiguration() != null) { - serverConfig.removeAll(keycloakCR.getSpec().getServerConfiguration()); - serverConfig.addAll(keycloakCR.getSpec().getServerConfiguration()); + if (keycloakCR.getSpec().getAdditionalOptions() != null) { + serverConfig.removeAll(keycloakCR.getSpec().getAdditionalOptions()); + serverConfig.addAll(keycloakCR.getSpec().getAdditionalOptions()); } // set env vars @@ -564,12 +564,12 @@ public class KeycloakDeployment extends OperatorManagedResource implements Statu protected String readConfigurationValue(String key) { if (keycloakCR != null && keycloakCR.getSpec() != null && - keycloakCR.getSpec().getServerConfiguration() != null + keycloakCR.getSpec().getAdditionalOptions() != null ) { var serverConfigValue = keycloakCR .getSpec() - .getServerConfiguration() + .getAdditionalOptions() .stream() .filter(sc -> sc.getName().equals(key)) .findFirst(); diff --git a/operator/src/main/java/org/keycloak/operator/controllers/KeycloakDistConfigurator.java b/operator/src/main/java/org/keycloak/operator/controllers/KeycloakDistConfigurator.java index b309182146..27e2ae6696 100644 --- a/operator/src/main/java/org/keycloak/operator/controllers/KeycloakDistConfigurator.java +++ b/operator/src/main/java/org/keycloak/operator/controllers/KeycloakDistConfigurator.java @@ -178,7 +178,7 @@ public class KeycloakDistConfigurator { protected void assumeFirstClassCitizens(KeycloakStatusBuilder status) { final var serverConfigNames = keycloakCR .getSpec() - .getServerConfiguration() + .getAdditionalOptions() .stream() .map(ValueOrSecret::getName) .collect(Collectors.toSet()); diff --git a/operator/src/main/java/org/keycloak/operator/crds/v2alpha1/deployment/KeycloakSpec.java b/operator/src/main/java/org/keycloak/operator/crds/v2alpha1/deployment/KeycloakSpec.java index 3c1e85009e..a78f44ca43 100644 --- a/operator/src/main/java/org/keycloak/operator/crds/v2alpha1/deployment/KeycloakSpec.java +++ b/operator/src/main/java/org/keycloak/operator/crds/v2alpha1/deployment/KeycloakSpec.java @@ -44,7 +44,7 @@ public class KeycloakSpec { @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.") - private List serverConfiguration; // can't use Set due to a bug in Sundrio https://github.com/sundrio/sundrio/issues/316 + private List additionalOptions; // can't use Set due to a bug in Sundrio https://github.com/sundrio/sundrio/issues/316 @JsonProperty("http") @JsonPropertyDescription("In this section you can configure Keycloak features related to HTTP and HTTPS") @@ -156,14 +156,14 @@ public class KeycloakSpec { this.imagePullSecrets = imagePullSecrets; } - public List getServerConfiguration() { - if (serverConfiguration == null) { - serverConfiguration = new ArrayList<>(); + public List getAdditionalOptions() { + if (this.additionalOptions == null) { + this.additionalOptions = new ArrayList<>(); } - return serverConfiguration; + return additionalOptions; } - public void setServerConfiguration(List serverConfiguration) { - this.serverConfiguration = serverConfiguration; + public void setAdditionalOptions(List additionalOptions) { + this.additionalOptions = additionalOptions; } } \ No newline at end of file diff --git a/operator/src/test/java/org/keycloak/operator/testsuite/integration/KeycloakDeploymentTest.java b/operator/src/test/java/org/keycloak/operator/testsuite/integration/KeycloakDeploymentTest.java index 0221d08139..903bc8b94c 100644 --- a/operator/src/test/java/org/keycloak/operator/testsuite/integration/KeycloakDeploymentTest.java +++ b/operator/src/test/java/org/keycloak/operator/testsuite/integration/KeycloakDeploymentTest.java @@ -100,8 +100,8 @@ public class KeycloakDeploymentTest extends BaseOperatorTest { final var dbConf = new ValueOrSecret("db-password", "Ay Caramba!"); kc.getSpec().setImage("quay.io/keycloak/non-existing-keycloak"); - kc.getSpec().getServerConfiguration().remove(dbConf); - kc.getSpec().getServerConfiguration().add(dbConf); + kc.getSpec().getAdditionalOptions().remove(dbConf); + kc.getSpec().getAdditionalOptions().add(dbConf); deployKeycloak(k8sclient, kc, false); Awaitility.await() @@ -131,7 +131,7 @@ public class KeycloakDeploymentTest extends BaseOperatorTest { .withName(KeycloakDistConfigurator.getKeycloakOptionEnvVarName(health.getName())) .withValue(health.getValue()) .build(); - kc.getSpec().getServerConfiguration().add(health); + kc.getSpec().getAdditionalOptions().add(health); deployKeycloak(k8sclient, kc, false); 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() { try { 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); var pods = k8sclient @@ -515,7 +515,7 @@ public class KeycloakDeploymentTest extends BaseOperatorTest { .build(); 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() .withName(secretName) .withKey(keyName) diff --git a/operator/src/test/java/org/keycloak/operator/testsuite/integration/RealmImportTest.java b/operator/src/test/java/org/keycloak/operator/testsuite/integration/RealmImportTest.java index 2efb04df37..0773b06dac 100644 --- a/operator/src/test/java/org/keycloak/operator/testsuite/integration/RealmImportTest.java +++ b/operator/src/test/java/org/keycloak/operator/testsuite/integration/RealmImportTest.java @@ -146,7 +146,7 @@ public class RealmImportTest extends BaseOperatorTest { keycloak.getSpec().setImage(customImage); // 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 - // keycloak.getSpec().getServerConfiguration().removeIf(sc -> sc.getName().equals("db")); + // keycloak.getSpec().getAdditionalOptions().removeIf(sc -> sc.getName().equals("db")); deployKeycloak(k8sclient, keycloak, false); // Act diff --git a/operator/src/test/java/org/keycloak/operator/testsuite/integration/WatchedSecretsTest.java b/operator/src/test/java/org/keycloak/operator/testsuite/integration/WatchedSecretsTest.java index 8e9ec2196d..20740eecb2 100644 --- a/operator/src/test/java/org/keycloak/operator/testsuite/integration/WatchedSecretsTest.java +++ b/operator/src/test/java/org/keycloak/operator/testsuite/integration/WatchedSecretsTest.java @@ -278,10 +278,10 @@ public class WatchedSecretsTest extends BaseOperatorTest { var username = new ValueOrSecret("db-username", "postgres"); var password = new ValueOrSecret("db-password", "testpassword"); - kc.getSpec().getServerConfiguration().remove(username); - kc.getSpec().getServerConfiguration().add(username); - kc.getSpec().getServerConfiguration().remove(password); - kc.getSpec().getServerConfiguration().add(password); + kc.getSpec().getAdditionalOptions().remove(username); + kc.getSpec().getAdditionalOptions().add(username); + kc.getSpec().getAdditionalOptions().remove(password); + kc.getSpec().getAdditionalOptions().add(password); } @AfterEach diff --git a/operator/src/test/java/org/keycloak/operator/testsuite/unit/CRSerializationTest.java b/operator/src/test/java/org/keycloak/operator/testsuite/unit/CRSerializationTest.java index 8e1905bcec..dc6ee091f6 100644 --- a/operator/src/test/java/org/keycloak/operator/testsuite/unit/CRSerializationTest.java +++ b/operator/src/test/java/org/keycloak/operator/testsuite/unit/CRSerializationTest.java @@ -55,7 +55,7 @@ public class CRSerializationTest { assertThat(transactionsSpec.isXaEnabled(), notNullValue()); assertThat(transactionsSpec.isXaEnabled(), CoreMatchers.is(false)); - List serverConfiguration = keycloak.getSpec().getServerConfiguration(); + List serverConfiguration = keycloak.getSpec().getAdditionalOptions(); assertNotNull(serverConfiguration); assertFalse(serverConfiguration.isEmpty()); diff --git a/operator/src/test/java/org/keycloak/operator/testsuite/unit/KeycloakDistConfiguratorTest.java b/operator/src/test/java/org/keycloak/operator/testsuite/unit/KeycloakDistConfiguratorTest.java index cc9e7a3192..ee809cf09a 100644 --- a/operator/src/test/java/org/keycloak/operator/testsuite/unit/KeycloakDistConfiguratorTest.java +++ b/operator/src/test/java/org/keycloak/operator/testsuite/unit/KeycloakDistConfiguratorTest.java @@ -158,7 +158,7 @@ public class KeycloakDistConfiguratorTest { .map(f -> new ValueOrSecret(f, "foo")) .collect(Collectors.toUnmodifiableList()); - keycloak.getSpec().setServerConfiguration(serverConfig); + keycloak.getSpec().setAdditionalOptions(serverConfig); final var expectedFields = expectedValues.keySet(); diff --git a/operator/src/test/resources/correct-podtemplate-keycloak.yml b/operator/src/test/resources/correct-podtemplate-keycloak.yml index 4117b4dbb4..97a0eb6497 100644 --- a/operator/src/test/resources/correct-podtemplate-keycloak.yml +++ b/operator/src/test/resources/correct-podtemplate-keycloak.yml @@ -4,7 +4,7 @@ metadata: name: example-podtemplate-kc spec: instances: 1 - serverConfiguration: + additionalOptions: - name: db value: postgres - name: db-url-host diff --git a/operator/src/test/resources/empty-podtemplate-keycloak.yml b/operator/src/test/resources/empty-podtemplate-keycloak.yml index 4a89e90d01..02571ad8ed 100644 --- a/operator/src/test/resources/empty-podtemplate-keycloak.yml +++ b/operator/src/test/resources/empty-podtemplate-keycloak.yml @@ -4,7 +4,7 @@ metadata: name: example-podtemplate spec: instances: 1 - serverConfiguration: + additionalOptions: - name: db value: postgres - name: db-url-host diff --git a/operator/src/test/resources/test-serialization-keycloak-cr.yml b/operator/src/test/resources/test-serialization-keycloak-cr.yml index 5c472f771f..a5470f42d1 100644 --- a/operator/src/test/resources/test-serialization-keycloak-cr.yml +++ b/operator/src/test/resources/test-serialization-keycloak-cr.yml @@ -5,7 +5,7 @@ metadata: spec: instances: 3 image: my-image - serverConfiguration: + additionalOptions: - name: key1 value: value1 - name: features