diff --git a/.ci/openshift-ci/build-root/e2e-test-prod.sh b/.ci/openshift-ci/build-root/e2e-test-prod.sh
index 8f789b802..8b53decb9 100644
--- a/.ci/openshift-ci/build-root/e2e-test-prod.sh
+++ b/.ci/openshift-ci/build-root/e2e-test-prod.sh
@@ -113,9 +113,9 @@ mvn test -Dmaven.repo.local=./local-repo-prod -pl testsuite/ -Pts.prod \
-Dintersmash.activemq.operators.package_manifest=amq-broker-rhel8 \
-Dintersmash.activemq.operators.channel=7.11.x \
-Dintersmash.activemq.operators.index_image='' \
- -Dintersmash.keycloak.image=registry.redhat.io/rh-sso-7/sso76-openshift-rhel8:latest \
- -Dintersmash.keycloak.operators.catalog_source=redhat-operators \
- -Dintersmash.keycloak.operators.package_manifest=rhsso-operator \
+ -Dintersmash.rhsso.image=registry.redhat.io/rh-sso-7/sso76-openshift-rhel8:latest \
+ -Dintersmash.rhsso.operators.catalog_source=redhat-operators \
+ -Dintersmash.rhsso.operators.package_manifest=rhsso-operator \
-Dintersmash.infinispan.image=registry.redhat.io/jboss-datagrid-7/datagrid73-openshift:latest \
-Dintersmash.infinispan.operators.catalog_source=redhat-operators \
-Dintersmash.infinispan.operators.package_manifest=datagrid \
diff --git a/README.md b/README.md
index dffdb8e88..5efd882c8 100644
--- a/README.md
+++ b/README.md
@@ -245,23 +245,22 @@ public class PostgresqlProvisionTest {
Mapping of implemented provisioners:
-| Product | Application | Provisioner | Notes |
-|:-----------|:---------------------------------------|:---------------------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| ActiveMQ | ActiveMQOperatorApplication* | ActiveMQOperatorProvisioner | |
-| Kafka | KafkaOperatorApplication | KafkaOperatorProvisioner | |
-| Wildfly | WildflyImageOpenShiftApplication | WildflyImageOpenShiftProvisioner | Available both for Git sources and binary based s2i v2 build (either a pre-built deployment or a filesystem resource like a Maven project folder) |
-| Wildfly | WildflyHelmChartOpenShiftApplication | WildflyHelmChartOpenShiftProvisioner | The `wildfly-2.3.2` tag of https://github.com/wildfly/wildfly-charts is used and the model is generated based on the https://raw.githubusercontent.com/wildfly/wildfly-charts/main/charts/wildfly/values.schema.json value schema file | |
-| Infinispan | InfinispanOperatorApplication | InfinispanOperatorProvisioner | |
-| Keycloak | KeycloakOperatorApplication | KeycloakOperatorProvisioner | |
-| Keycloak | KeycloakRealmImportOperatorApplication | KeycloakRealmImportOperatorProvisioner | The latest Quarkus based Keycloak Operator, doesn't provide stable CRDs yet (see https://www.keycloak.org/2022/09/operator-crs); this operator offers a temporary solution which supports the `Keycloak` and `KeycloakRealmImport` Custom Resources: these are the only supported CR at the time of writing |
-
-Additional services provisioners:
-
-| Service | Application | Provisioner |
-|:-----------|:---------------------------------------|:---------------------------------------|
-| MySQL | MysqlImageOpenShiftApplication | MysqlImageOpenShiftProvisioner |
-| PostgreSQL | PostgreSQLImageOpenShiftApplication | PostgreSQLImageOpenShiftProvisioner |
-| PostgreSQL | PostgreSQLTemplateOpenShiftApplication | PostgreSQLTemplateOpenShiftProvisioner |
+| Service | Supports community project | Supports product | Application | Provisioner | Notes |
+|:--------------------------------------|:---------------------------|:-------------------|:-------------------------------------|:--------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| ActiveMQ Artemis & Red Hat AMQ Broker | :heavy_check_mark: | :heavy_check_mark: | ActiveMQOperatorApplication | ActiveMQOperatorProvisioner | Operator based provisioner, see details [below](#operator-based-provisioning) |
+| HyperFoil | :heavy_check_mark: | :x: | HyperfoilOperatorApplication | HyperfoilOperatorProvisioner | Operator based provisioner, see details [below](#operator-based-provisioning) |
+| Infinispan & Red Hat DataGrid | :heavy_check_mark: | :heavy_check_mark: | InfinispanOperatorApplication | InfinispanOperatorProvisioner | Operator based provisioner, see details [below](#operator-based-provisioning) |
+| Kafka & Red Hat AMQ Streams | :heavy_check_mark: | :heavy_check_mark: | KafkaOperatorApplication | KafkaOperatorProvisioner | Operator based provisioner, see details [below](#operator-based-provisioning) |
+| Keycloak | :heavy_check_mark: | :x: | KeycloakOperatorApplication | KeycloakOperatorProvisioner | Based on the latest Quarkus based Keycloak Operator, doesn't provide stable CRDs yet (see https://www.keycloak.org/2022/09/operator-crs); this operator offers a solution which supports the `Keycloak` and `KeycloakRealmImport` Custom Resources: these are the only supported CRs at the time of writing. See details [below](#operator-based-provisioning) |
+| MySQL | :heavy_check_mark: | :x: | MysqlImageOpenShiftApplication | MysqlImageOpenShiftProvisioner | Deploys a MySQL image and sets environment variables to configure the service (ports, credentials etc.) |
+| PostgreSQL | :heavy_check_mark: | :x: | PostgreSQLImageOpenShiftApplication | PostgreSQLImageOpenShiftProvisioner | Deploys a PostgreSQL image and sets environment variables to configure the service (ports, credentials etc.) |
+| Wildfly & Red Hat JBoss EAP XP | :heavy_check_mark: | :heavy_check_mark: | BootableJarOpenShiftApplication | WildflyBootableJarImageOpenShiftProvisioner | Deploys a WildFly Bootable JAR, i.e. a runnable WildFly application |
+| Wildfly & Red Hat JBoss EAP 8 | :heavy_check_mark: | :heavy_check_mark: | WildflyImageOpenShiftApplication | WildflyImageOpenShiftProvisioner | Available both for Git sources and binary based s2i v2 build (either a pre-built deployment or a filesystem resource like a Maven project folder) |
+| Wildfly & Red Hat JBoss EAP 8 | :heavy_check_mark: | :heavy_check_mark: | WildflyHelmChartOpenShiftApplication | WildflyHelmChartOpenShiftProvisioner | The `wildfly-2.3.2` tag of https://github.com/wildfly/wildfly-charts is used and the model is generated based on the https://raw.githubusercontent.com/wildfly/wildfly-charts/main/charts/wildfly/values.schema.json value schema file |
+| Wildfly & Red Hat JBoss EAP 7/8 | :heavy_check_mark: | :heavy_check_mark: | WildflyOperatorApplication | WildflyOperatorProvisioner | Operator based provisioner, see details [below](#operator-based-provisioning) |
+| Red Hat JBoss EAP 7 | :x: | :heavy_check_mark: | Eap7ImageOpenShiftApplication | Eap7ImageOpenShiftProvisioner | Available both for Git sources and binary based EAP 7 s2i (legacy) build, i.e. based on a pre-built deployment (i.e. a _WAR archive_) |
+| Red Hat SSO 7 | :x: | :heavy_check_mark: | RhSsoOperatorApplication | RhSsoOperatorProvisioner | Based on the archived Keycloak operator project, which contains the latest Red Hat SSO 7.z CRDs definitions, see details [below](#operator-based-provisioning) |
+
The only thing users have to take care of is to implement the correct `Application` (see the table above) interface and
pass the class via `@Service` annotation, it's a task for the framework to choose a suitable Provisioner implementation
@@ -277,18 +276,19 @@ a given service on cloud environments via APIs that leverage the
Intersmash makes this feature available for currently supported products (see the table below), but that can be
extended easily, since Intersmash _provisioners_ are pluggable components.
-| Product | Supported Operator version | Channel name | Supported product version | Repository | Notes |
+| Service | Supported Operator version | Channel name | Supported product version | Repository | Notes |
|:--------------------------|:---------------------------|:-------------|:--------------------------|:----------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| ActiveMQ Artemis | 1.0.11 | upstream | 1.0.15 | https://github.com/artemiscloud/activemq-artemis-operator | We are using a custom index image, i.e. quay.io/jbossqe-eap/intersmash-activemq-operator-catalog:v1.0.11, built as described in https://github.com/Intersmash/intersmash/issues/32 |
+| Red HatAMQ Broker | 7.11.2-opr-1 | 7.11.x | 7.11.z | https://github.com/rh-messaging/activemq-artemis-operator | As available on the OpenShift OperatorHub |
| Hyperfoil | 0.24.2 | alpha | 0.24.2 | https://github.com/Hyperfoil/hyperfoil-operator | We force the CRs version for the used Hyperfoil runtime to be 0.24.2, see https://github.com/Hyperfoil/hyperfoil-operator/issues/18 |
| Infinispan | 2.3.4 | 2.3.x | 14.0.17.Final | https://github.com/infinispan/infinispan-operator | As available on the OpenShift OperatorHub (community-operators) |
| Red Hat DataGrid | 8.4.8 | 8.4.x | 8.4.4.GA | https://github.com/infinispan/infinispan-operator | As available on the OpenShift OperatorHub |
-| WildFly | 0.5.6 | alpha | 29.0.1.Final | https://github.com/wildfly/wildfly-operator | As available on https://operatorhub.io/operator/wildfly |
-| Red Hat JBoss EAP | 2.4.2 | stable | EAP 8.0 Beta, EAP 7.4.z | https://github.com/wildfly/wildfly-operator | As available on the OpenShift OperatorHub |
| Kafka provided by Strimzi | 0.37.0-SNAPSHOT | stable | 3.5.1 | https://github.com/strimzi/strimzi-kafka-operator | A snapshot version of Strimzi API is used in order to be compatible with Fabric8 Kubernetes client artifacts |
-| Red HatAMQ Streams | 2.5.0-0 | stable | 3.5.0 | https://github.com/strimzi/strimzi-kafka-operator | As available on the OpenShift OperatorHub. A snapshot version of Strimzi API is used in order to be compatible with Fabric8 Kubernetes client artifacts |
-| ActiveMQ Artemis | 1.0.11 | upstream | 1.0.15 | https://github.com/artemiscloud/activemq-artemis-operator | We are using a custom index image, i.e. quay.io/jbossqe-eap/intersmash-activemq-operator-catalog:v1.0.11, built as described in https://github.com/Intersmash/intersmash/issues/32 |
-| Red HatAMQ Broker | 7.11.2-opr-1 | 7.11.x | 7.11.z | https://github.com/rh-messaging/activemq-artemis-operator | As available on the OpenShift OperatorHub |
+| Red Hat AMQ Streams | 2.5.0-0 | stable | 3.5.0 | https://github.com/strimzi/strimzi-kafka-operator | As available on the OpenShift OperatorHub. A snapshot version of Strimzi API is used in order to be compatible with Fabric8 Kubernetes client artifacts |
| Keycloak | 22.0.4 | upstream | 22.0.4 | https://github.com/keycloak/keycloak/tree/main/operator | Latest Keycloak, based on Quarkus. Supports a limited number of CR (Keycloak and KeycloakRealmImport): more to come in upcoming versions |
+| Red Hat SSO | 7.6.5-opr-003 | stable | 7.4.6 | https://github.com/keycloak/keycloak-operator | Latest Red Hat SSO Operator, based on legacy Keycloak |
+| WildFly | 0.5.6 | alpha | 29.0.1.Final | https://github.com/wildfly/wildfly-operator | As available on https://operatorhub.io/operator/wildfly |
+| Red Hat JBoss EAP | 2.4.2 | stable | EAP 8.0 Beta, EAP 7.4.z | https://github.com/wildfly/wildfly-operator | As available on the OpenShift OperatorHub |
Intersmash operator-based provisioners implement a common contract and high level behavior which is defined by the
[OperatorProvisioner](./intersmash-tools/intersmash-tools-core/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/OperatorProvisioner.java)
diff --git a/global-test.properties b/global-test.properties
index e92c3a36a..87ed7023d 100644
--- a/global-test.properties
+++ b/global-test.properties
@@ -31,9 +31,9 @@ intersmash.activemq.operators.index_image=quay.io/jbossqe-eap/intersmash-activem
intersmash.activemq.operators.package_manifest=activemq-artemis-operator
intersmash.activemq.operators.channel=upstream
-intersmash.keycloak.realm_import.image=quay.io/keycloak/keycloak:latest
-intersmash.keycloak.realm_import.operators.catalog_source=community-operators
-intersmash.keycloak.realm_import.operators.channel=fast
+intersmash.keycloak.image=quay.io/keycloak/keycloak:latest
+intersmash.keycloak.operators.catalog_source=community-operators
+intersmash.keycloak.operators.channel=fast
intersmash.kafka.operators.channel=stable
diff --git a/pom.xml b/pom.xml
index 87dc8c407..9a1e7aa67 100644
--- a/pom.xml
+++ b/pom.xml
@@ -97,6 +97,7 @@
2.0.1
2.35.0
3.3.1
+ 0.101.0
+
+ io.sundr
+ builder-annotations
+ provided
+
+
+ org.projectlombok
+ lombok
+ provided
+
@@ -194,6 +208,10 @@
as in https://github.com/infinispan/infinispan-operator/blob/2.3.4.Final/config/crd/bases/infinispan.org_infinispans.yaml#L1473-L1477
-->
false
+
+ true
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/application/openshift/Eap7ImageOpenShiftApplication.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/application/openshift/Eap7ImageOpenShiftApplication.java
index c92416f7e..b8d8fc168 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/application/openshift/Eap7ImageOpenShiftApplication.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/application/openshift/Eap7ImageOpenShiftApplication.java
@@ -4,9 +4,9 @@
import java.util.List;
import org.jboss.intersmash.tools.application.openshift.input.BuildInput;
+import org.jboss.intersmash.tools.provision.openshift.Eap7ImageOpenShiftProvisioner;
import io.fabric8.kubernetes.api.model.EnvVar;
-import org.jboss.intersmash.tools.provision.openshift.Eap7ImageOpenShiftProvisioner;
/**
* End user Application descriptor interface which presents a AP 7.z (i.e. Jakarta EE 8 based WildFly) application on
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/application/openshift/KeycloakOperatorApplication.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/application/openshift/KeycloakOperatorApplication.java
index 728f2fd22..a5c1b9a23 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/application/openshift/KeycloakOperatorApplication.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/application/openshift/KeycloakOperatorApplication.java
@@ -19,11 +19,8 @@
import java.util.List;
import org.jboss.intersmash.tools.provision.openshift.KeycloakOperatorProvisioner;
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.backup.KeycloakBackup;
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.client.KeycloakClient;
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.keycloak.Keycloak;
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.realm.KeycloakRealm;
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.user.KeycloakUser;
+import org.keycloak.k8s.v2alpha1.Keycloak;
+import org.keycloak.k8s.v2alpha1.KeycloakRealmImport;
/**
* End user Application interface which presents Keycloak operator application on OpenShift Container Platform.
@@ -37,19 +34,7 @@ public interface KeycloakOperatorApplication extends OperatorApplication {
Keycloak getKeycloak();
- default List getKeycloakBackups() {
- return Collections.emptyList();
- }
-
- default List getKeycloakClients() {
- return Collections.emptyList();
- }
-
- default List getKeycloakRealms() {
- return Collections.emptyList();
- }
-
- default List getKeycloakUsers() {
+ default List getKeycloakRealmImports() {
return Collections.emptyList();
}
}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/application/openshift/KeycloakRealmImportOperatorApplication.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/application/openshift/RhSsoOperatorApplication.java
similarity index 56%
rename from tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/application/openshift/KeycloakRealmImportOperatorApplication.java
rename to tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/application/openshift/RhSsoOperatorApplication.java
index 2af2c7efd..22614bb91 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/application/openshift/KeycloakRealmImportOperatorApplication.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/application/openshift/RhSsoOperatorApplication.java
@@ -18,23 +18,38 @@
import java.util.Collections;
import java.util.List;
-import org.jboss.intersmash.tools.provision.openshift.KeycloakRealmImportOperatorProvisioner;
-import org.keycloak.k8s.v2alpha1.Keycloak;
-import org.keycloak.k8s.v2alpha1.KeycloakRealmImport;
+import org.jboss.intersmash.tools.provision.openshift.RhSsoOperatorProvisioner;
+import org.keycloak.v1alpha1.Keycloak;
+import org.keycloak.v1alpha1.KeycloakBackup;
+import org.keycloak.v1alpha1.KeycloakClient;
+import org.keycloak.v1alpha1.KeycloakRealm;
+import org.keycloak.v1alpha1.KeycloakUser;
/**
* End user Application interface which presents Keycloak operator application on OpenShift Container Platform.
*
* The application will be deployed by:
*
- * - {@link KeycloakRealmImportOperatorProvisioner}
+ * - {@link RhSsoOperatorProvisioner}
*
*/
-public interface KeycloakRealmImportOperatorApplication extends OperatorApplication {
+public interface RhSsoOperatorApplication extends OperatorApplication {
Keycloak getKeycloak();
- default List getKeycloakRealmImports() {
+ default List getKeycloakBackups() {
+ return Collections.emptyList();
+ }
+
+ default List getKeycloakClients() {
+ return Collections.emptyList();
+ }
+
+ default List getKeycloakRealms() {
+ return Collections.emptyList();
+ }
+
+ default List getKeycloakUsers() {
return Collections.emptyList();
}
}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/KeycloakOperatorProvisioner.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/KeycloakOperatorProvisioner.java
index 1b9838bd1..f7e1fb8ab 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/KeycloakOperatorProvisioner.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/KeycloakOperatorProvisioner.java
@@ -17,6 +17,7 @@
import java.net.MalformedURLException;
import java.net.URL;
+import java.text.MessageFormat;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -27,24 +28,20 @@
import org.jboss.intersmash.tools.IntersmashConfig;
import org.jboss.intersmash.tools.application.openshift.KeycloakOperatorApplication;
import org.jboss.intersmash.tools.provision.openshift.operator.OperatorProvisioner;
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.backup.KeycloakBackup;
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.backup.KeycloakBackupList;
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.client.KeycloakClient;
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.client.KeycloakClientList;
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.keycloak.Keycloak;
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.keycloak.KeycloakList;
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.realm.KeycloakRealm;
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.realm.KeycloakRealmList;
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.user.KeycloakUser;
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.user.KeycloakUserList;
+import org.jboss.intersmash.tools.util.tls.CertificatesUtils;
+import org.keycloak.k8s.v2alpha1.Keycloak;
+import org.keycloak.k8s.v2alpha1.KeycloakOperatorKeycloakList;
+import org.keycloak.k8s.v2alpha1.KeycloakOperatorRealmImportList;
+import org.keycloak.k8s.v2alpha1.KeycloakRealmImport;
+import org.keycloak.k8s.v2alpha1.keycloakspec.Http;
import org.slf4j.event.Level;
import cz.xtf.core.config.OpenShiftConfig;
import cz.xtf.core.event.helpers.EventHelper;
import cz.xtf.core.openshift.OpenShiftWaiters;
import cz.xtf.core.openshift.OpenShifts;
-import cz.xtf.core.openshift.helpers.ResourceParsers;
import cz.xtf.core.waiting.SimpleWaiter;
+import cz.xtf.core.waiting.failfast.FailFastCheck;
import io.fabric8.kubernetes.api.model.DeletionPropagation;
import io.fabric8.kubernetes.api.model.Pod;
import io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition;
@@ -59,27 +56,49 @@
* Keycloak operator provisioner
*/
public class KeycloakOperatorProvisioner extends OperatorProvisioner {
- private static final String KEYCLOAK_RESOURCE = "keycloaks.keycloak.org";
- private static NonNamespaceOperation> KEYCLOAKS_CLIENT;
+ private static final String KEYCLOAK_RESOURCE = "keycloaks.k8s.keycloak.org";
+ private static final String KEYCLOAK_REALM_IMPORT_RESOURCE = "keycloakrealmimports.k8s.keycloak.org";
+ private static NonNamespaceOperation> KEYCLOAK_CUSTOM_RESOURCE_CLIENT;
+ private static NonNamespaceOperation> KEYCLOAK_REALM_IMPORT_CUSTOM_RESOURCE_CLIENT;
- private static final String KEYCLOAK_REALM_RESOURCE = "keycloakrealms.keycloak.org";
- private static NonNamespaceOperation> KEYCLOAK_REALMS_CLIENT;
-
- private static final String KEYCLOAK_BACKUP_RESOURCE = "keycloakbackups.keycloak.org";
- private static NonNamespaceOperation> KEYCLOAK_BACKUPS_CLIENT;
-
- private static final String KEYCLOAK_CLIENT_RESOURCE = "keycloakclients.keycloak.org";
- private static NonNamespaceOperation> KEYCLOAK_CLIENTS_CLIENT;
+ public NonNamespaceOperation> keycloakClient() {
+ if (KEYCLOAK_CUSTOM_RESOURCE_CLIENT == null) {
+ CustomResourceDefinition crd = OpenShifts.admin().apiextensions().v1().customResourceDefinitions()
+ .withName(KEYCLOAK_RESOURCE).get();
+ CustomResourceDefinitionContext crdc = CustomResourceDefinitionContext.fromCrd(crd);
+ if (!getCustomResourceDefinitions().contains(KEYCLOAK_RESOURCE)) {
+ throw new RuntimeException(String.format("[%s] custom resource is not provided by [%s] operator.",
+ KEYCLOAK_RESOURCE, OPERATOR_ID));
+ }
+ MixedOperation> crClient = OpenShifts
+ .master().newHasMetadataOperation(crdc, Keycloak.class, KeycloakOperatorKeycloakList.class);
+ KEYCLOAK_CUSTOM_RESOURCE_CLIENT = crClient.inNamespace(OpenShiftConfig.namespace());
+ }
+ return KEYCLOAK_CUSTOM_RESOURCE_CLIENT;
+ }
- private static final String KEYCLOAK_USER_RESOURCE = "keycloakusers.keycloak.org";
- private static NonNamespaceOperation> KEYCLOAK_USERS_CLIENT;
+ public NonNamespaceOperation> keycloakRealmImportClient() {
+ if (KEYCLOAK_REALM_IMPORT_CUSTOM_RESOURCE_CLIENT == null) {
+ CustomResourceDefinition crd = OpenShifts.admin().apiextensions().v1().customResourceDefinitions()
+ .withName(KEYCLOAK_REALM_IMPORT_RESOURCE).get();
+ CustomResourceDefinitionContext crdc = CustomResourceDefinitionContext.fromCrd(crd);
+ if (!getCustomResourceDefinitions().contains(KEYCLOAK_REALM_IMPORT_RESOURCE)) {
+ throw new RuntimeException(String.format("[%s] custom resource is not provided by [%s] operator.",
+ KEYCLOAK_REALM_IMPORT_RESOURCE, OPERATOR_ID));
+ }
+ MixedOperation> crClient = OpenShifts
+ .master()
+ .newHasMetadataOperation(crdc, KeycloakRealmImport.class, KeycloakOperatorRealmImportList.class);
+ KEYCLOAK_REALM_IMPORT_CUSTOM_RESOURCE_CLIENT = crClient.inNamespace(OpenShiftConfig.namespace());
+ }
+ return KEYCLOAK_REALM_IMPORT_CUSTOM_RESOURCE_CLIENT;
+ }
- // oc get packagemanifest rhsso-operator -n openshift-marketplace
private static final String OPERATOR_ID = IntersmashConfig.keycloakOperatorPackageManifest();
- private static final String STATEFUL_SET_NAME = "keycloak";
+ protected FailFastCheck ffCheck = () -> false;
- public KeycloakOperatorProvisioner(@NonNull KeycloakOperatorApplication keycloakOperatorApplication) {
- super(keycloakOperatorApplication, OPERATOR_ID);
+ public KeycloakOperatorProvisioner(@NonNull KeycloakOperatorApplication application) {
+ super(application, OPERATOR_ID);
}
public static String getOperatorId() {
@@ -106,12 +125,13 @@ public void subscribe() {
if (Strings.isNullOrEmpty(IntersmashConfig.keycloakImageURL())) {
super.subscribe();
} else {
- // RELATED_IMAGE_RHSSO_OPENJ9 and RELATED_IMAGE_RHSSO_OPENJDK, determine the final value for RELATED_IMAGE_RHSSO
subscribe(
INSTALLPLAN_APPROVAL_MANUAL,
Map.of(
- "RELATED_IMAGE_RHSSO", IntersmashConfig.keycloakImageURL(),
- "PROFILE", "RHSSO"));
+ // Custom Keycloak image to be used: overrides the Keycloak image at the operator level: all
+ // Keycloak instances will be spun out of this image
+ // e.g. OPERATOR_KEYCLOAK_IMAGE=quay.io/keycloak/keycloak:21.1.1 --> operator.keycloak.image
+ "OPERATOR_KEYCLOAK_IMAGE", IntersmashConfig.keycloakImageURL()));
}
}
@@ -123,19 +143,46 @@ public void deploy() {
// deploy using environment variables in Keycloak Operator Subscription
subscribe();
- // create custom resources
- keycloaksClient().createOrReplace(getApplication().getKeycloak());
- if (getApplication().getKeycloakRealms().size() > 0) {
- getApplication().getKeycloakRealms().stream().forEach((i) -> keycloakRealmsClient().resource(i).create());
+ // Custom Keycloak image to be used: overrides the Keycloak image at the Keycloak level: just this Keycloak
+ // instance will be spun out of this image
+ if (!Strings.isNullOrEmpty(IntersmashConfig.keycloakImageURL())) {
+ getApplication().getKeycloak().getSpec().setImage(IntersmashConfig.keycloakImageURL());
}
- if (getApplication().getKeycloakClients().size() > 0) {
- getApplication().getKeycloakClients().stream().forEach((i) -> keycloakClientsClient().resource(i).create());
+
+ // create keys/certificates and add them to the Keycloak resource:
+ // TODO: https://www.keycloak.org/operator/basic-deployment or ~/projects/keycloak/docs/guides/operator/basic-deployment.adoc
+ if (getApplication().getKeycloak().getSpec().getHttp() == null
+ || getApplication().getKeycloak().getSpec().getHttp().getTlsSecret() == null) {
+ // create key, certificate and tls secret
+ String tlsSecretName = getApplication().getKeycloak().getMetadata().getName() + "-tls-secret";
+ CertificatesUtils.CertificateAndKey certificateAndKey = CertificatesUtils
+ .generateSelfSignedCertificateAndKey(
+ getApplication().getKeycloak().getSpec().getHostname().getHostname().replaceFirst("[.].*$", ""),
+ tlsSecretName);
+ // add config to keycloak
+ if (getApplication().getKeycloak().getSpec().getHttp() == null) {
+ Http http = new Http();
+ http.setTlsSecret(certificateAndKey.tlsSecret.getMetadata().getName());
+ getApplication().getKeycloak().getSpec().setHttp(http);
+ } else {
+ getApplication().getKeycloak().getSpec().getHttp()
+ .setTlsSecret(certificateAndKey.tlsSecret.getMetadata().getName());
+ }
}
- if (getApplication().getKeycloakUsers().size() > 0) {
- getApplication().getKeycloakUsers().stream().forEach((i) -> keycloakUsersClient().resource(i).create());
+
+ // 1. check externalDatabase exists
+ if (getApplication().getKeycloak().getSpec().getDb() != null) {
+ // 2. Service "spec.db.host" must be installed beforehand
+ new SimpleWaiter(() -> OpenShiftProvisioner.openShift
+ .getService(getApplication().getKeycloak().getSpec().getDb().getHost()) != null)
+ .level(Level.DEBUG).waitFor();
}
- if (getApplication().getKeycloakBackups().size() > 0) {
- getApplication().getKeycloakBackups().stream().forEach((i) -> keycloakBackupsClient().resource(i).create());
+
+ // create custom resources
+ keycloakClient().createOrReplace(getApplication().getKeycloak());
+ if (getApplication().getKeycloakRealmImports().size() > 0) {
+ getApplication().getKeycloakRealmImports().stream()
+ .forEach((i) -> keycloakRealmImportClient().resource(i).create());
}
// Wait for Keycloak (and PostgreSQL) to be ready
@@ -151,77 +198,104 @@ public void deploy() {
}
}
- /**
- * Wait for Keycloak and PostgreSQL (in case no external database is used) to be ready
- *
- * @param keycloak Concrete {@link Keycloak} instance which the method should be wait for
- */
public void waitFor(Keycloak keycloak) {
- int replicas = keycloak.getSpec().getInstances();
+ Long replicas = keycloak.getSpec().getInstances();
if (replicas > 0) {
- // 1. check externalDatabase
- if (keycloak.getSpec().getExternalDatabase() == null || !keycloak.getSpec().getExternalDatabase().isEnabled()) {
- // 2. wait for PostgreSQL to be ready (Service "keycloak-postgresql" is guaranteed to exist by documentation)
- new SimpleWaiter(() -> OpenShiftProvisioner.openShift.getPods()
- .stream()
- .filter(
- pod -> OpenShiftProvisioner.openShift.getService("keycloak-postgresql") != null
- && pod.getMetadata().getLabels().entrySet().containsAll(
- OpenShiftProvisioner.openShift.getService("keycloak-postgresql").getSpec()
- .getSelector().entrySet())
- && ResourceParsers.isPodReady(pod))
- .count() > 0).level(Level.DEBUG).waitFor();
- }
- // 4. wait for >= 1 pods with label controller-revision-hash=keycloak-d86bb6ddc
+ // wait for >= 1 pods with label controller-revision-hash=keycloak-d86bb6ddc
String controllerRevisionHash = getStatefulSet().getStatus().getUpdateRevision();
OpenShiftWaiters.get(OpenShiftProvisioner.openShift, ffCheck)
- .areExactlyNPodsReady(replicas, "controller-revision-hash",
+ .areExactlyNPodsReady(replicas.intValue(), "controller-revision-hash",
controllerRevisionHash)
.waitFor();
}
}
+ public void waitFor(KeycloakRealmImport realmImport) {
+ new SimpleWaiter(() -> {
+ Resource res = keycloakRealmImportClient().withName(realmImport.getMetadata().getName());
+ if (Objects.nonNull(res)
+ && Objects.nonNull(res.get())
+ && Objects.nonNull(res.get().getStatus())) {
+ KeycloakRealmImport imp = res.get();
+ return imp.getStatus().getConditions().stream().filter(
+ cond -> cond.getStatus() != null
+ && "Done".equalsIgnoreCase(cond.getType())
+ && com.google.common.base.Strings.isNullOrEmpty(cond.getMessage()))
+ .count() == 1
+ &&
+ imp.getStatus().getConditions().stream().filter(
+ cond -> cond.getStatus() == null
+ && "HasErrors".equalsIgnoreCase(cond.getType())
+ && com.google.common.base.Strings.isNullOrEmpty(cond.getMessage()))
+ .count() == 1;
+ }
+ return false;
+ }).reason("Wait for KeycloakRealmImport resource to be imported").level(Level.DEBUG).waitFor();
+ }
+
private void waitForKeycloakResourceReadiness() {
- new SimpleWaiter(() -> keycloak().get().getStatus().isReady())
- .reason("Wait for keycloak resource to be ready").level(Level.DEBUG).waitFor();
- if (getApplication().getKeycloakRealms().size() > 0)
- new SimpleWaiter(() -> keycloakRealms().stream().map(realm -> realm.get().getStatus().isReady())
- .reduce(Boolean::logicalAnd).get())
- .reason("Wait for keycloakrealms to be ready.").level(Level.DEBUG).waitFor();
- if (getApplication().getKeycloakClients().size() > 0)
- new SimpleWaiter(() -> keycloakClients().stream().map(realm -> realm.get().getStatus().isReady())
- .reduce(Boolean::logicalAnd).get())
- .reason("Wait for keycloakclients to be ready.").level(Level.DEBUG).waitFor();
- if (getApplication().getKeycloakUsers().size() > 0)
- new SimpleWaiter(() -> keycloakUsersClient().list().getItems().size() == getApplication().getKeycloakUsers().size())
- .reason("Wait for keycloakusers to be ready.").level(Level.DEBUG).waitFor(); // no isReady() for users
- if (getApplication().getKeycloakBackups().size() > 0)
- new SimpleWaiter(() -> keycloakBackups().stream().map(realm -> realm.get().getStatus().isReady())
- .reduce(Boolean::logicalAnd).get())
- .reason("Wait for keycloakbackups to be ready.").level(Level.DEBUG).waitFor();
+ new SimpleWaiter(
+ () -> keycloak().get().getStatus().getConditions().stream().anyMatch(
+ condition -> "Ready".equalsIgnoreCase(condition.getType())
+ && condition.getStatus() != null))
+ .reason("Wait for Keycloak resource to be ready").level(Level.DEBUG).waitFor();
+ if (getApplication().getKeycloakRealmImports().size() > 0)
+ new SimpleWaiter(() -> keycloakRealmImports().stream().allMatch(
+ realmImport -> realmImport.getStatus().getConditions().stream().anyMatch(
+ condition -> "Done".equalsIgnoreCase(condition.getType())
+ && condition.getStatus() != null)))
+ .reason("Wait for KeycloakRealmImports to be done.").level(Level.DEBUG).waitFor();
+ }
+
+ /**
+ * Get a reference to keycloak object. Use get() to get the actual object, or null in case it does not
+ * exist on tested cluster.
+ * @return A concrete {@link Resource} instance representing the {@link org.jboss.intersmash.tools.provision.openshift.operator.keycloak.keycloak.Keycloak} resource definition
+ */
+ public Resource keycloak() {
+ return keycloakClient()
+ .withName(getApplication().getKeycloak().getMetadata().getName());
+ }
+
+ public List keycloakRealmImports() {
+ return keycloakRealmImportClient().list().getItems()
+ .stream().filter(
+ realm -> getApplication().getKeycloakRealmImports().stream().map(
+ ri -> ri.getMetadata().getName())
+ .anyMatch(riName -> riName.equalsIgnoreCase(realm.getMetadata().getName())))
+ .collect(Collectors.toList());
+ }
+
+ /**
+ * @return the underlying StatefulSet which provisions the cluster
+ */
+ private StatefulSet getStatefulSet() {
+ final String STATEFUL_SET_NAME = getApplication().getKeycloak().getMetadata().getName();
+ new SimpleWaiter(
+ () -> Objects.nonNull(OpenShiftProvisioner.openShift.getStatefulSet(STATEFUL_SET_NAME)))
+ .reason(
+ MessageFormat.format(
+ "Waiting for StatefulSet \"{0}\" to be created for Keycloak \"{1}\".",
+ STATEFUL_SET_NAME,
+ getApplication().getKeycloak().getMetadata().getName()))
+ .level(Level.DEBUG).timeout(60000L).waitFor();
+ return OpenShiftProvisioner.openShift.getStatefulSet(STATEFUL_SET_NAME);
}
@Override
public void undeploy() {
- // delete custom resources
- keycloakBackups()
- .forEach(keycloakBackup -> keycloakBackup.withPropagationPolicy(DeletionPropagation.FOREGROUND).delete());
- new SimpleWaiter(() -> keycloakBackupsClient().list().getItems().size() == 0)
- .reason("Wait for all keycloakbackups instances to be deleted.").level(Level.DEBUG).waitFor();
- keycloakUsers().forEach(keycloakUser -> keycloakUser.withPropagationPolicy(DeletionPropagation.FOREGROUND).delete());
- new SimpleWaiter(() -> keycloakUsersClient().list().getItems().size() == 0)
- .reason("Wait for all keycloakusers instances to be deleted.").level(Level.DEBUG).waitFor();
- keycloakClients()
- .forEach(keycloakClient -> keycloakClient.withPropagationPolicy(DeletionPropagation.FOREGROUND).delete());
- keycloakUsers().forEach(keycloakUser -> keycloakUser.withPropagationPolicy(DeletionPropagation.FOREGROUND).delete());
- new SimpleWaiter(() -> keycloakClientsClient().list().getItems().size() == 0)
- .reason("Wait for all keycloakclients instances to be deleted.").level(Level.DEBUG).waitFor();
- keycloakRealms().forEach(keycloakRealm -> keycloakRealm.withPropagationPolicy(DeletionPropagation.FOREGROUND).delete());
- new SimpleWaiter(() -> keycloakRealmsClient().list().getItems().size() == 0)
- .reason("Wait for all keycloakrealms instances to be deleted.").level(Level.DEBUG).waitFor();
+ keycloakRealmImports()
+ .forEach(
+ keycloakRealm -> keycloakRealmImportClient()
+ .withName(keycloakRealm.getMetadata().getName())
+ .withPropagationPolicy(DeletionPropagation.FOREGROUND)
+ .delete());
+ new SimpleWaiter(
+ () -> keycloakRealmImportClient().list().getItems().size() == 0)
+ .reason("Wait for all keycloakRealmImports instances to be deleted.").level(Level.DEBUG).waitFor();
keycloak().withPropagationPolicy(DeletionPropagation.FOREGROUND).delete();
- new SimpleWaiter(() -> keycloaksClient().list().getItems().size() == 0)
- .reason("Wait for all keycloakrealms instances to be deleted.").level(Level.DEBUG).waitFor();
+ new SimpleWaiter(() -> keycloakClient().list().getItems().size() == 0)
+ .reason("Wait for Keycloak instances to be deleted.").level(Level.DEBUG).waitFor();
// wait for 0 pods
OpenShiftWaiters.get(OpenShiftProvisioner.openShift, () -> false)
@@ -234,8 +308,8 @@ public void undeploy() {
public void scale(int replicas, boolean wait) {
String controllerRevisionHash = getStatefulSet().getStatus().getUpdateRevision();
Keycloak tmpKeycloak = keycloak().get();
- int originalReplicas = tmpKeycloak.getSpec().getInstances();
- tmpKeycloak.getSpec().setInstances(replicas);
+ Long originalReplicas = tmpKeycloak.getSpec().getInstances();
+ tmpKeycloak.getSpec().setInstances(Integer.toUnsignedLong(replicas));
keycloak().replace(tmpKeycloak);
if (wait) {
OpenShiftWaiters.get(OpenShiftProvisioner.openShift, ffCheck)
@@ -243,8 +317,11 @@ public void scale(int replicas, boolean wait) {
.level(Level.DEBUG)
.waitFor();
}
- new SimpleWaiter(() -> keycloak().get().getStatus().isReady())
- .reason("Wait for keycloak resource to be ready").level(Level.DEBUG).waitFor();
+ new SimpleWaiter(
+ () -> keycloak().get().getStatus().getConditions().stream().anyMatch(
+ condition -> "Ready".equalsIgnoreCase(condition.getType())
+ && condition.getStatus() != null))
+ .reason("Wait for Keycloak resource to be ready").level(Level.DEBUG).waitFor();
// check that route is up
if (originalReplicas == 0 && replicas > 0) {
WaitersUtil.routeIsUp(getURL().toExternalForm())
@@ -255,6 +332,7 @@ public void scale(int replicas, boolean wait) {
@Override
public List getPods() {
+ String STATEFUL_SET_NAME = getApplication().getKeycloak().getMetadata().getName();
StatefulSet statefulSet = OpenShiftProvisioner.openShift.getStatefulSet(STATEFUL_SET_NAME);
return Objects.nonNull(statefulSet)
? OpenShiftProvisioner.openShift.getLabeledPods("controller-revision-hash",
@@ -264,258 +342,27 @@ public List getPods() {
@Override
public URL getURL() {
- // https://github.com/keycloak/keycloak-operator/blob/15.0.2/pkg/apis/keycloak/v1alpha1/keycloak_types.go#L232
- String externalUrl = keycloak().get().getStatus().getExternalURL();
+ String host = OpenShiftProvisioner.openShift.routes().list().getItems()
+ .stream().filter(
+ route -> route.getMetadata().getName().startsWith(
+ keycloak().get().getMetadata().getName())
+ &&
+ route.getMetadata().getLabels().entrySet()
+ .stream().filter(
+ label -> label.getKey().equalsIgnoreCase("app")
+ &&
+ label.getValue().equalsIgnoreCase(
+ keycloak().get().getMetadata().getLabels().get("app")))
+ .count() == 1
+
+ ).findFirst()
+ .orElseThrow(() -> new RuntimeException(
+ String.format("No route for Keycloak %s!", keycloak().get().getMetadata().getName())))
+ .getSpec().getHost();
try {
- return Strings.isNullOrEmpty(externalUrl) ? null : new URL(externalUrl);
+ return Strings.isNullOrEmpty(host) ? null : new URL(String.format("https://%s", host));
} catch (MalformedURLException e) {
- throw new RuntimeException(String.format("Keycloak operator External URL \"%s\" is malformed.", externalUrl), e);
- }
- }
-
- // keycloaks.keycloak.org
-
- /**
- * Get a client capable of working with {@link #KEYCLOAK_RESOURCE} custom resource.
- *
- * @return client for operations with {@link #KEYCLOAK_RESOURCE} custom resource
- */
- public NonNamespaceOperation> keycloaksClient() {
- if (KEYCLOAKS_CLIENT == null) {
- CustomResourceDefinition crd = OpenShifts.admin().apiextensions().v1().customResourceDefinitions()
- .withName(KEYCLOAK_RESOURCE).get();
- CustomResourceDefinitionContext crdc = CustomResourceDefinitionContext.fromCrd(crd);
- if (!getCustomResourceDefinitions().contains(KEYCLOAK_RESOURCE)) {
- throw new RuntimeException(String.format("[%s] custom resource is not provided by [%s] operator.",
- KEYCLOAK_RESOURCE, OPERATOR_ID));
- }
- MixedOperation> keycloaksClient = OpenShifts
- .master()
- .newHasMetadataOperation(crdc, Keycloak.class, KeycloakList.class);
- KEYCLOAKS_CLIENT = keycloaksClient.inNamespace(OpenShiftConfig.namespace());
- }
- return KEYCLOAKS_CLIENT;
- }
-
- /**
- * Get a reference to keycloak object. Use get() to get the actual object, or null in case it does not
- * exist on tested cluster.
- * @return A concrete {@link Resource} instance representing the {@link Keycloak} resource definition
- */
- public Resource keycloak() {
- return keycloaksClient().withName(getApplication().getKeycloak().getMetadata().getName());
- }
-
- // keycloakrealms.keycloak.org
-
- /**
- * Get a client capable of working with {@link #KEYCLOAK_REALM_RESOURCE} custom resource.
- *
- * @return client for operations with {@link #KEYCLOAK_REALM_RESOURCE} custom resource
- */
- public NonNamespaceOperation> keycloakRealmsClient() {
- if (KEYCLOAK_REALMS_CLIENT == null) {
- CustomResourceDefinition crd = OpenShifts.admin().apiextensions().v1().customResourceDefinitions()
- .withName(KEYCLOAK_REALM_RESOURCE).get();
- CustomResourceDefinitionContext crdc = CustomResourceDefinitionContext.fromCrd(crd);
- if (!getCustomResourceDefinitions().contains(KEYCLOAK_REALM_RESOURCE)) {
- throw new RuntimeException(String.format("[%s] custom resource is not provided by [%s] operator.",
- KEYCLOAK_REALM_RESOURCE, OPERATOR_ID));
- }
- MixedOperation> keycloakRealmsClient = OpenShifts
- .master()
- .newHasMetadataOperation(crdc, KeycloakRealm.class, KeycloakRealmList.class);
- KEYCLOAK_REALMS_CLIENT = keycloakRealmsClient.inNamespace(OpenShiftConfig.namespace());
- }
- return KEYCLOAK_REALMS_CLIENT;
- }
-
- /**
- * Get a reference to keycloakrealms object. Use get() to get the actual object, or null in case it does not
- * exist on tested cluster.
- *
- * @param name name of the keycloakrealm custom resource
- * @return A concrete {@link Resource} instance representing the {@link KeycloakRealm} resource definition
- */
- public Resource keycloakRealm(String name) {
- return keycloakRealmsClient().withName(name);
- }
-
- /**
- * Get all keycloakrealms maintained by the current operator instance.
- *
- * Be aware that this method return just a references to the addresses, they might not actually exist on the cluster.
- * Use get() to get the actual object, or null in case it does not exist on tested cluster.
- * @return A list of {@link Resource} instances representing the {@link KeycloakRealm} resource definitions
- */
- public List> keycloakRealms() {
- KeycloakOperatorApplication keycloakOperatorApplication = getApplication();
- return keycloakOperatorApplication.getKeycloakRealms().stream()
- .map(keycloakRealm -> keycloakRealm.getMetadata().getName())
- .map(this::keycloakRealm)
- .collect(Collectors.toList());
- }
-
- // keycloakbackups.keycloak.org
-
- /**
- * Get a client capable of working with {@link #KEYCLOAK_BACKUP_RESOURCE} custom resource.
- *
- * @return client for operations with {@link #KEYCLOAK_BACKUP_RESOURCE} custom resource
- */
- public NonNamespaceOperation> keycloakBackupsClient() {
- if (KEYCLOAK_BACKUPS_CLIENT == null) {
- CustomResourceDefinition crd = OpenShifts.admin().apiextensions().v1().customResourceDefinitions()
- .withName(KEYCLOAK_BACKUP_RESOURCE).get();
- CustomResourceDefinitionContext crdc = CustomResourceDefinitionContext.fromCrd(crd);
- if (!getCustomResourceDefinitions().contains(KEYCLOAK_BACKUP_RESOURCE)) {
- throw new RuntimeException(String.format("[%s] custom resource is not provided by [%s] operator.",
- KEYCLOAK_BACKUP_RESOURCE, OPERATOR_ID));
- }
- MixedOperation> keycloakBackupsClient = OpenShifts
- .master()
- .newHasMetadataOperation(crdc, KeycloakBackup.class, KeycloakBackupList.class);
- KEYCLOAK_BACKUPS_CLIENT = keycloakBackupsClient.inNamespace(OpenShiftConfig.namespace());
- }
- return KEYCLOAK_BACKUPS_CLIENT;
- }
-
- /**
- * Get a reference to keycloakbackup object. Use get() to get the actual object, or null in case it does not
- * exist on tested cluster.
- *
- * @param name name of the {@link KeycloakBackup} custom resource
- * @return A concrete {@link Resource} instance representing the {@link KeycloakBackup} resource definition
- */
- public Resource keycloakBackup(String name) {
- return keycloakBackupsClient().withName(name);
- }
-
- /**
- * Get all keycloakbackups maintained by the current operator instance.
- *
- * Be aware that this method return just a references to the addresses, they might not actually exist on the cluster.
- * Use get() to get the actual object, or null in case it does not exist on tested cluster.
- * @return A list of {@link Resource} instances representing the {@link KeycloakBackup} resource definitions
- */
- public List> keycloakBackups() {
- KeycloakOperatorApplication keycloakOperatorApplication = getApplication();
- return keycloakOperatorApplication.getKeycloakBackups().stream()
- .map(keycloakBackup -> keycloakBackup.getMetadata().getName())
- .map(this::keycloakBackup)
- .collect(Collectors.toList());
- }
-
- // keycloakclients.keycloak.org
-
- /**
- * Get a client capable of working with {@link #KEYCLOAK_CLIENT_RESOURCE} custom resource.
- *
- * @return client for operations with {@link #KEYCLOAK_CLIENT_RESOURCE} custom resource
- */
- public NonNamespaceOperation> keycloakClientsClient() {
- if (KEYCLOAK_CLIENTS_CLIENT == null) {
- CustomResourceDefinition crd = OpenShifts.admin().apiextensions().v1().customResourceDefinitions()
- .withName(KEYCLOAK_CLIENT_RESOURCE).get();
- CustomResourceDefinitionContext crdc = CustomResourceDefinitionContext.fromCrd(crd);
- if (!getCustomResourceDefinitions().contains(KEYCLOAK_CLIENT_RESOURCE)) {
- throw new RuntimeException(String.format("[%s] custom resource is not provided by [%s] operator.",
- KEYCLOAK_CLIENT_RESOURCE, OPERATOR_ID));
- }
- MixedOperation> keycloakClientsClient = OpenShifts
- .master()
- .newHasMetadataOperation(crdc, KeycloakClient.class, KeycloakClientList.class);
- KEYCLOAK_CLIENTS_CLIENT = keycloakClientsClient.inNamespace(OpenShiftConfig.namespace());
- }
- return KEYCLOAK_CLIENTS_CLIENT;
- }
-
- /**
- * Get a reference to keycloakclient object. Use get() to get the actual object, or null in case it does not
- * exist on tested cluster.
- *
- * @param name name of the {@link KeycloakClient} custom resource
- * @return A concrete {@link Resource} instance representing the {@link KeycloakClient} resource definition
- */
- public Resource keycloakClient(String name) {
- return keycloakClientsClient().withName(name);
- }
-
- /**
- * Get all keycloakclients maintained by the current operator instance.
- *
- * Be aware that this method return just a references to the addresses, they might not actually exist on the cluster.
- * Use get() to get the actual object, or null in case it does not exist on tested cluster.
- * @return A list of {@link Resource} instances representing the {@link KeycloakClient} resource definitions
- */
- public List> keycloakClients() {
- KeycloakOperatorApplication keycloakOperatorApplication = getApplication();
- return keycloakOperatorApplication.getKeycloakClients().stream()
- .map(keycloakClient -> keycloakClient.getMetadata().getName())
- .map(this::keycloakClient)
- .collect(Collectors.toList());
- }
-
- // keycloakusers.keycloak.org
-
- /**
- * Get a client capable of working with {@link #KEYCLOAK_USER_RESOURCE} custom resource.
- *
- * @return client for operations with {@link #KEYCLOAK_USER_RESOURCE} custom resource
- */
- public NonNamespaceOperation> keycloakUsersClient() {
- if (KEYCLOAK_USERS_CLIENT == null) {
- CustomResourceDefinition crd = OpenShifts.admin().apiextensions().v1().customResourceDefinitions()
- .withName(KEYCLOAK_USER_RESOURCE).get();
- CustomResourceDefinitionContext crdc = CustomResourceDefinitionContext.fromCrd(crd);
- if (!getCustomResourceDefinitions().contains(KEYCLOAK_USER_RESOURCE)) {
- throw new RuntimeException(String.format("[%s] custom resource is not provided by [%s] operator.",
- KEYCLOAK_USER_RESOURCE, OPERATOR_ID));
- }
- MixedOperation> keycloakUsersClient = OpenShifts
- .master()
- .newHasMetadataOperation(crdc, KeycloakUser.class, KeycloakUserList.class);
- KEYCLOAK_USERS_CLIENT = keycloakUsersClient.inNamespace(OpenShiftConfig.namespace());
- }
- return KEYCLOAK_USERS_CLIENT;
- }
-
- /**
- * Get a reference to keycloakuser object. Use get() to get the actual object, or null in case it does not
- * exist on tested cluster.
- *
- * @param name name of the keycloakuser custom resource
- * @return A concrete {@link Resource} instance representing the {@link KeycloakUser} resource definition
- */
- public Resource keycloakUser(String name) {
- return keycloakUsersClient().withName(name);
- }
-
- /**
- * Get all keycloakusers maintained by the current operator instance.
- *
- * Be aware that this method return just a references to the addresses, they might not actually exist on the cluster.
- * Use get() to get the actual object, or null in case it does not exist on tested cluster.
- * @return A list of {@link Resource} instances representing the {@link KeycloakUser} resource definitions
- */
- public List> keycloakUsers() {
- KeycloakOperatorApplication keycloakOperatorApplication = getApplication();
- return keycloakOperatorApplication.getKeycloakUsers().stream()
- .map(keycloakUser -> keycloakUser.getMetadata().getName())
- .map(this::keycloakUser)
- .collect(Collectors.toList());
- }
-
- /**
- * @return the underlying StatefulSet which provisions the cluster
- */
- private StatefulSet getStatefulSet() {
- StatefulSet statefulSet = OpenShiftProvisioner.openShift.getStatefulSet(STATEFUL_SET_NAME);
- if (Objects.isNull(statefulSet)) {
- throw new IllegalStateException(String.format(
- "Impossible to find StatefulSet with name=\"%s\"!",
- STATEFUL_SET_NAME));
+ throw new RuntimeException(String.format("Keycloak operator External URL \"%s\" is malformed.", host), e);
}
- return statefulSet;
}
}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/KeycloakOperatorProvisionerFactory.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/KeycloakOperatorProvisionerFactory.java
index ae7982fa7..74942e5f9 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/KeycloakOperatorProvisionerFactory.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/KeycloakOperatorProvisionerFactory.java
@@ -22,7 +22,8 @@
import lombok.extern.slf4j.Slf4j;
@Slf4j
-public class KeycloakOperatorProvisionerFactory implements ProvisionerFactory {
+public class KeycloakOperatorProvisionerFactory
+ implements ProvisionerFactory {
@Override
public KeycloakOperatorProvisioner getProvisioner(Application application) {
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/KeycloakRealmImportOperatorProvisioner.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/KeycloakRealmImportOperatorProvisioner.java
deleted file mode 100644
index 6af11f3fe..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/KeycloakRealmImportOperatorProvisioner.java
+++ /dev/null
@@ -1,368 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.text.MessageFormat;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.stream.Collectors;
-
-import org.assertj.core.util.Lists;
-import org.assertj.core.util.Strings;
-import org.jboss.intersmash.tools.IntersmashConfig;
-import org.jboss.intersmash.tools.application.openshift.KeycloakRealmImportOperatorApplication;
-import org.jboss.intersmash.tools.provision.openshift.operator.OperatorProvisioner;
-import org.jboss.intersmash.tools.util.tls.CertificatesUtils;
-import org.keycloak.k8s.v2alpha1.Keycloak;
-import org.keycloak.k8s.v2alpha1.KeycloakRealmImport;
-import org.keycloak.k8s.v2alpha1.KeycloakRealmImportOperatorKeycloakList;
-import org.keycloak.k8s.v2alpha1.KeycloakRealmImportOperatorRealmImportList;
-import org.keycloak.k8s.v2alpha1.keycloakspec.Http;
-import org.slf4j.event.Level;
-
-import cz.xtf.core.config.OpenShiftConfig;
-import cz.xtf.core.event.helpers.EventHelper;
-import cz.xtf.core.openshift.OpenShiftWaiters;
-import cz.xtf.core.openshift.OpenShifts;
-import cz.xtf.core.waiting.SimpleWaiter;
-import cz.xtf.core.waiting.failfast.FailFastCheck;
-import io.fabric8.kubernetes.api.model.DeletionPropagation;
-import io.fabric8.kubernetes.api.model.Pod;
-import io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition;
-import io.fabric8.kubernetes.api.model.apps.StatefulSet;
-import io.fabric8.kubernetes.client.dsl.MixedOperation;
-import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation;
-import io.fabric8.kubernetes.client.dsl.Resource;
-import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext;
-import lombok.NonNull;
-
-/**
- * Keycloak operator provisioner
- */
-public class KeycloakRealmImportOperatorProvisioner extends OperatorProvisioner {
- private static final String KEYCLOAK_RESOURCE = "keycloaks.k8s.keycloak.org";
- private static final String KEYCLOAK_REALM_IMPORT_RESOURCE = "keycloakrealmimports.k8s.keycloak.org";
- private static NonNamespaceOperation> KEYCLOAK_CUSTOM_RESOURCE_CLIENT;
- private static NonNamespaceOperation> KEYCLOAK_REALM_IMPORT_CUSTOM_RESOURCE_CLIENT;
-
- public NonNamespaceOperation> keycloakClient() {
- if (KEYCLOAK_CUSTOM_RESOURCE_CLIENT == null) {
- CustomResourceDefinition crd = OpenShifts.admin().apiextensions().v1().customResourceDefinitions()
- .withName(KEYCLOAK_RESOURCE).get();
- CustomResourceDefinitionContext crdc = CustomResourceDefinitionContext.fromCrd(crd);
- if (!getCustomResourceDefinitions().contains(KEYCLOAK_RESOURCE)) {
- throw new RuntimeException(String.format("[%s] custom resource is not provided by [%s] operator.",
- KEYCLOAK_RESOURCE, OPERATOR_ID));
- }
- MixedOperation> crClient = OpenShifts
- .master().newHasMetadataOperation(crdc, Keycloak.class, KeycloakRealmImportOperatorKeycloakList.class);
- KEYCLOAK_CUSTOM_RESOURCE_CLIENT = crClient.inNamespace(OpenShiftConfig.namespace());
- }
- return KEYCLOAK_CUSTOM_RESOURCE_CLIENT;
- }
-
- public NonNamespaceOperation> keycloakRealmImportClient() {
- if (KEYCLOAK_REALM_IMPORT_CUSTOM_RESOURCE_CLIENT == null) {
- CustomResourceDefinition crd = OpenShifts.admin().apiextensions().v1().customResourceDefinitions()
- .withName(KEYCLOAK_REALM_IMPORT_RESOURCE).get();
- CustomResourceDefinitionContext crdc = CustomResourceDefinitionContext.fromCrd(crd);
- if (!getCustomResourceDefinitions().contains(KEYCLOAK_REALM_IMPORT_RESOURCE)) {
- throw new RuntimeException(String.format("[%s] custom resource is not provided by [%s] operator.",
- KEYCLOAK_REALM_IMPORT_RESOURCE, OPERATOR_ID));
- }
- MixedOperation> crClient = OpenShifts
- .master()
- .newHasMetadataOperation(crdc, KeycloakRealmImport.class, KeycloakRealmImportOperatorRealmImportList.class);
- KEYCLOAK_REALM_IMPORT_CUSTOM_RESOURCE_CLIENT = crClient.inNamespace(OpenShiftConfig.namespace());
- }
- return KEYCLOAK_REALM_IMPORT_CUSTOM_RESOURCE_CLIENT;
- }
-
- private static final String OPERATOR_ID = IntersmashConfig.keycloakRealmImportOperatorPackageManifest();
- protected FailFastCheck ffCheck = () -> false;
-
- public KeycloakRealmImportOperatorProvisioner(@NonNull KeycloakRealmImportOperatorApplication application) {
- super(application, OPERATOR_ID);
- }
-
- public static String getOperatorId() {
- return OPERATOR_ID;
- }
-
- @Override
- protected String getOperatorCatalogSource() {
- return IntersmashConfig.keycloakRealmImportOperatorCatalogSource();
- }
-
- @Override
- protected String getOperatorIndexImage() {
- return IntersmashConfig.keycloakRealmImportOperatorIndexImage();
- }
-
- @Override
- protected String getOperatorChannel() {
- return IntersmashConfig.keycloakRealmImportOperatorChannel();
- }
-
- @Override
- public void subscribe() {
- if (Strings.isNullOrEmpty(IntersmashConfig.keycloakRealmImportImageURL())) {
- super.subscribe();
- } else {
- subscribe(
- INSTALLPLAN_APPROVAL_MANUAL,
- Map.of(
- // Custom Keycloak image to be used: overrides the Keycloak image at the operator level: all
- // Keycloak instances will be spun out of this image
- // e.g. OPERATOR_KEYCLOAK_IMAGE=quay.io/keycloak/keycloak:21.1.1 --> operator.keycloak.image
- "OPERATOR_KEYCLOAK_IMAGE", IntersmashConfig.keycloakRealmImportImageURL()));
- }
- }
-
- @Override
- public void deploy() {
- ffCheck = FailFastUtils.getFailFastCheck(EventHelper.timeOfLastEventBMOrTestNamespaceOrEpoch(),
- getApplication().getName());
- // Keycloak Operator codebase contains the name of the Keycloak image to deploy: user can override Keycloak image to
- // deploy using environment variables in Keycloak Operator Subscription
- subscribe();
-
- // Custom Keycloak image to be used: overrides the Keycloak image at the Keycloak level: just this Keycloak
- // instance will be spun out of this image
- if (!Strings.isNullOrEmpty(IntersmashConfig.keycloakRealmImportImageURL())) {
- getApplication().getKeycloak().getSpec().setImage(IntersmashConfig.keycloakRealmImportImageURL());
- }
-
- // create keys/certificates and add them to the Keycloak resource:
- // TODO: https://www.keycloak.org/operator/basic-deployment or ~/projects/keycloak/docs/guides/operator/basic-deployment.adoc
- if (getApplication().getKeycloak().getSpec().getHttp() == null
- || getApplication().getKeycloak().getSpec().getHttp().getTlsSecret() == null) {
- // create key, certificate and tls secret
- String tlsSecretName = getApplication().getKeycloak().getMetadata().getName() + "-tls-secret";
- CertificatesUtils.CertificateAndKey certificateAndKey = CertificatesUtils
- .generateSelfSignedCertificateAndKey(
- getApplication().getKeycloak().getSpec().getHostname().getHostname().replaceFirst("[.].*$", ""),
- tlsSecretName);
- // add config to keycloak
- if (getApplication().getKeycloak().getSpec().getHttp() == null) {
- Http http = new Http();
- http.setTlsSecret(certificateAndKey.tlsSecret.getMetadata().getName());
- getApplication().getKeycloak().getSpec().setHttp(http);
- } else {
- getApplication().getKeycloak().getSpec().getHttp()
- .setTlsSecret(certificateAndKey.tlsSecret.getMetadata().getName());
- }
- }
-
- // 1. check externalDatabase exists
- if (getApplication().getKeycloak().getSpec().getDb() != null) {
- // 2. Service "spec.db.host" must be installed beforehand
- new SimpleWaiter(() -> OpenShiftProvisioner.openShift
- .getService(getApplication().getKeycloak().getSpec().getDb().getHost()) != null)
- .level(Level.DEBUG).waitFor();
- }
-
- // create custom resources
- keycloakClient().createOrReplace(getApplication().getKeycloak());
- if (getApplication().getKeycloakRealmImports().size() > 0) {
- getApplication().getKeycloakRealmImports().stream()
- .forEach((i) -> keycloakRealmImportClient().resource(i).create());
- }
-
- // Wait for Keycloak (and PostgreSQL) to be ready
- waitFor(getApplication().getKeycloak());
- // wait for all resources to be ready
- waitForKeycloakResourceReadiness();
- // check that route is up, only if there's a valid external URL available
- URL externalUrl = getURL();
- if ((getApplication().getKeycloak().getSpec().getInstances() > 0) && (externalUrl != null)) {
- WaitersUtil.routeIsUp(externalUrl.toExternalForm())
- .level(Level.DEBUG)
- .waitFor();
- }
- }
-
- public void waitFor(Keycloak keycloak) {
- Long replicas = keycloak.getSpec().getInstances();
- if (replicas > 0) {
- // wait for >= 1 pods with label controller-revision-hash=keycloak-d86bb6ddc
- String controllerRevisionHash = getStatefulSet().getStatus().getUpdateRevision();
- OpenShiftWaiters.get(OpenShiftProvisioner.openShift, ffCheck)
- .areExactlyNPodsReady(replicas.intValue(), "controller-revision-hash",
- controllerRevisionHash)
- .waitFor();
- }
- }
-
- public void waitFor(KeycloakRealmImport realmImport) {
- new SimpleWaiter(() -> {
- Resource res = keycloakRealmImportClient().withName(realmImport.getMetadata().getName());
- if (Objects.nonNull(res)
- && Objects.nonNull(res.get())
- && Objects.nonNull(res.get().getStatus())) {
- KeycloakRealmImport imp = res.get();
- return imp.getStatus().getConditions().stream().filter(
- cond -> cond.getStatus() != null
- && "Done".equalsIgnoreCase(cond.getType())
- && com.google.common.base.Strings.isNullOrEmpty(cond.getMessage()))
- .count() == 1
- &&
- imp.getStatus().getConditions().stream().filter(
- cond -> cond.getStatus() == null
- && "HasErrors".equalsIgnoreCase(cond.getType())
- && com.google.common.base.Strings.isNullOrEmpty(cond.getMessage()))
- .count() == 1;
- }
- return false;
- }).reason("Wait for KeycloakRealmImport resource to be imported").level(Level.DEBUG).waitFor();
- }
-
- private void waitForKeycloakResourceReadiness() {
- new SimpleWaiter(
- () -> keycloak().get().getStatus().getConditions().stream().anyMatch(
- condition -> "Ready".equalsIgnoreCase(condition.getType())
- && condition.getStatus() != null))
- .reason("Wait for Keycloak resource to be ready").level(Level.DEBUG).waitFor();
- if (getApplication().getKeycloakRealmImports().size() > 0)
- new SimpleWaiter(() -> keycloakRealmImports().stream().allMatch(
- realmImport -> realmImport.getStatus().getConditions().stream().anyMatch(
- condition -> "Done".equalsIgnoreCase(condition.getType())
- && condition.getStatus() != null)))
- .reason("Wait for KeycloakRealmImports to be done.").level(Level.DEBUG).waitFor();
- }
-
- /**
- * Get a reference to keycloak object. Use get() to get the actual object, or null in case it does not
- * exist on tested cluster.
- * @return A concrete {@link Resource} instance representing the {@link org.jboss.intersmash.tools.provision.openshift.operator.keycloak.keycloak.Keycloak} resource definition
- */
- public Resource keycloak() {
- return keycloakClient()
- .withName(getApplication().getKeycloak().getMetadata().getName());
- }
-
- public List keycloakRealmImports() {
- return keycloakRealmImportClient().list().getItems()
- .stream().filter(
- realm -> getApplication().getKeycloakRealmImports().stream().map(
- ri -> ri.getMetadata().getName())
- .anyMatch(riName -> riName.equalsIgnoreCase(realm.getMetadata().getName())))
- .collect(Collectors.toList());
- }
-
- /**
- * @return the underlying StatefulSet which provisions the cluster
- */
- private StatefulSet getStatefulSet() {
- final String STATEFUL_SET_NAME = getApplication().getKeycloak().getMetadata().getName();
- new SimpleWaiter(
- () -> Objects.nonNull(OpenShiftProvisioner.openShift.getStatefulSet(STATEFUL_SET_NAME)))
- .reason(
- MessageFormat.format(
- "Waiting for StatefulSet \"{0}\" to be created for Keycloak \"{1}\".",
- STATEFUL_SET_NAME,
- getApplication().getKeycloak().getMetadata().getName()))
- .level(Level.DEBUG).timeout(60000L).waitFor();
- return OpenShiftProvisioner.openShift.getStatefulSet(STATEFUL_SET_NAME);
- }
-
- @Override
- public void undeploy() {
- keycloakRealmImports()
- .forEach(
- keycloakRealm -> keycloakRealmImportClient()
- .withName(keycloakRealm.getMetadata().getName())
- .withPropagationPolicy(DeletionPropagation.FOREGROUND)
- .delete());
- new SimpleWaiter(
- () -> keycloakRealmImportClient().list().getItems().size() == 0)
- .reason("Wait for all keycloakRealmImports instances to be deleted.").level(Level.DEBUG).waitFor();
- keycloak().withPropagationPolicy(DeletionPropagation.FOREGROUND).delete();
- new SimpleWaiter(() -> keycloakClient().list().getItems().size() == 0)
- .reason("Wait for Keycloak instances to be deleted.").level(Level.DEBUG).waitFor();
-
- // wait for 0 pods
- OpenShiftWaiters.get(OpenShiftProvisioner.openShift, () -> false)
- .areExactlyNPodsReady(0, "app", getApplication().getKeycloak().getKind().toLowerCase()).level(Level.DEBUG)
- .waitFor();
- unsubscribe();
- }
-
- @Override
- public void scale(int replicas, boolean wait) {
- String controllerRevisionHash = getStatefulSet().getStatus().getUpdateRevision();
- Keycloak tmpKeycloak = keycloak().get();
- Long originalReplicas = tmpKeycloak.getSpec().getInstances();
- tmpKeycloak.getSpec().setInstances(Integer.toUnsignedLong(replicas));
- keycloak().replace(tmpKeycloak);
- if (wait) {
- OpenShiftWaiters.get(OpenShiftProvisioner.openShift, ffCheck)
- .areExactlyNPodsReady(replicas, "controller-revision-hash", controllerRevisionHash)
- .level(Level.DEBUG)
- .waitFor();
- }
- new SimpleWaiter(
- () -> keycloak().get().getStatus().getConditions().stream().anyMatch(
- condition -> "Ready".equalsIgnoreCase(condition.getType())
- && condition.getStatus() != null))
- .reason("Wait for Keycloak resource to be ready").level(Level.DEBUG).waitFor();
- // check that route is up
- if (originalReplicas == 0 && replicas > 0) {
- WaitersUtil.routeIsUp(getURL().toExternalForm())
- .level(Level.DEBUG)
- .waitFor();
- }
- }
-
- @Override
- public List getPods() {
- String STATEFUL_SET_NAME = getApplication().getKeycloak().getMetadata().getName();
- StatefulSet statefulSet = OpenShiftProvisioner.openShift.getStatefulSet(STATEFUL_SET_NAME);
- return Objects.nonNull(statefulSet)
- ? OpenShiftProvisioner.openShift.getLabeledPods("controller-revision-hash",
- statefulSet.getStatus().getUpdateRevision())
- : Lists.emptyList();
- }
-
- @Override
- public URL getURL() {
- String host = OpenShiftProvisioner.openShift.routes().list().getItems()
- .stream().filter(
- route -> route.getMetadata().getName().startsWith(
- keycloak().get().getMetadata().getName())
- &&
- route.getMetadata().getLabels().entrySet()
- .stream().filter(
- label -> label.getKey().equalsIgnoreCase("app")
- &&
- label.getValue().equalsIgnoreCase(
- keycloak().get().getMetadata().getLabels().get("app")))
- .count() == 1
-
- ).findFirst()
- .orElseThrow(() -> new RuntimeException(
- String.format("No route for Keycloak %s!", keycloak().get().getMetadata().getName())))
- .getSpec().getHost();
- try {
- return Strings.isNullOrEmpty(host) ? null : new URL(String.format("https://%s", host));
- } catch (MalformedURLException e) {
- throw new RuntimeException(String.format("Keycloak operator External URL \"%s\" is malformed.", host), e);
- }
- }
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/RhSsoOperatorProvisioner.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/RhSsoOperatorProvisioner.java
new file mode 100644
index 000000000..a8ab7b82c
--- /dev/null
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/RhSsoOperatorProvisioner.java
@@ -0,0 +1,521 @@
+/**
+ * Copyright (C) 2023 Red Hat, Inc.
+ *
+ * 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.
+ */
+package org.jboss.intersmash.tools.provision.openshift;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+import org.assertj.core.util.Lists;
+import org.assertj.core.util.Strings;
+import org.jboss.intersmash.tools.IntersmashConfig;
+import org.jboss.intersmash.tools.application.openshift.RhSsoOperatorApplication;
+import org.jboss.intersmash.tools.provision.openshift.operator.OperatorProvisioner;
+import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.backup.KeycloakBackupList;
+import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.client.KeycloakClientList;
+import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.keycloak.KeycloakList;
+import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.realm.KeycloakRealmList;
+import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.user.KeycloakUserList;
+import org.keycloak.v1alpha1.Keycloak;
+import org.keycloak.v1alpha1.KeycloakBackup;
+import org.keycloak.v1alpha1.KeycloakClient;
+import org.keycloak.v1alpha1.KeycloakRealm;
+import org.keycloak.v1alpha1.KeycloakUser;
+import org.slf4j.event.Level;
+
+import cz.xtf.core.config.OpenShiftConfig;
+import cz.xtf.core.event.helpers.EventHelper;
+import cz.xtf.core.openshift.OpenShiftWaiters;
+import cz.xtf.core.openshift.OpenShifts;
+import cz.xtf.core.openshift.helpers.ResourceParsers;
+import cz.xtf.core.waiting.SimpleWaiter;
+import io.fabric8.kubernetes.api.model.DeletionPropagation;
+import io.fabric8.kubernetes.api.model.Pod;
+import io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition;
+import io.fabric8.kubernetes.api.model.apps.StatefulSet;
+import io.fabric8.kubernetes.client.dsl.MixedOperation;
+import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation;
+import io.fabric8.kubernetes.client.dsl.Resource;
+import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext;
+import lombok.NonNull;
+
+/**
+ * Keycloak operator provisioner
+ */
+public class RhSsoOperatorProvisioner extends OperatorProvisioner {
+ private static final String KEYCLOAK_RESOURCE = "keycloaks.keycloak.org";
+ private static NonNamespaceOperation> KEYCLOAKS_CLIENT;
+
+ private static final String KEYCLOAK_REALM_RESOURCE = "keycloakrealms.keycloak.org";
+ private static NonNamespaceOperation> KEYCLOAK_REALMS_CLIENT;
+
+ private static final String KEYCLOAK_BACKUP_RESOURCE = "keycloakbackups.keycloak.org";
+ private static NonNamespaceOperation> KEYCLOAK_BACKUPS_CLIENT;
+
+ private static final String KEYCLOAK_CLIENT_RESOURCE = "keycloakclients.keycloak.org";
+ private static NonNamespaceOperation> KEYCLOAK_CLIENTS_CLIENT;
+
+ private static final String KEYCLOAK_USER_RESOURCE = "keycloakusers.keycloak.org";
+ private static NonNamespaceOperation> KEYCLOAK_USERS_CLIENT;
+
+ // oc get packagemanifest rhsso-operator -n openshift-marketplace
+ private static final String OPERATOR_ID = IntersmashConfig.rhSsoOperatorPackageManifest();
+ private static final String STATEFUL_SET_NAME = "keycloak";
+
+ public RhSsoOperatorProvisioner(@NonNull RhSsoOperatorApplication rhSsoOperatorApplication) {
+ super(rhSsoOperatorApplication, OPERATOR_ID);
+ }
+
+ public static String getOperatorId() {
+ return OPERATOR_ID;
+ }
+
+ @Override
+ protected String getOperatorCatalogSource() {
+ return IntersmashConfig.rhSsoOperatorCatalogSource();
+ }
+
+ @Override
+ protected String getOperatorIndexImage() {
+ return IntersmashConfig.rhSsoOperatorIndexImage();
+ }
+
+ @Override
+ protected String getOperatorChannel() {
+ return IntersmashConfig.rhSsoOperatorChannel();
+ }
+
+ @Override
+ public void subscribe() {
+ if (Strings.isNullOrEmpty(IntersmashConfig.rhSsoImageURL())) {
+ super.subscribe();
+ } else {
+ // RELATED_IMAGE_RHSSO_OPENJ9 and RELATED_IMAGE_RHSSO_OPENJDK, determine the final value for RELATED_IMAGE_RHSSO
+ subscribe(
+ INSTALLPLAN_APPROVAL_MANUAL,
+ Map.of(
+ "RELATED_IMAGE_RHSSO", IntersmashConfig.rhSsoImageURL(),
+ "PROFILE", "RHSSO"));
+ }
+ }
+
+ @Override
+ public void deploy() {
+ ffCheck = FailFastUtils.getFailFastCheck(EventHelper.timeOfLastEventBMOrTestNamespaceOrEpoch(),
+ getApplication().getName());
+ // Keycloak Operator codebase contains the name of the Keycloak image to deploy: user can override Keycloak image to
+ // deploy using environment variables in Keycloak Operator Subscription
+ subscribe();
+
+ // create custom resources
+ keycloaksClient().createOrReplace(getApplication().getKeycloak());
+ if (getApplication().getKeycloakRealms().size() > 0) {
+ getApplication().getKeycloakRealms().stream().forEach((i) -> keycloakRealmsClient().resource(i).create());
+ }
+ if (getApplication().getKeycloakClients().size() > 0) {
+ getApplication().getKeycloakClients().stream().forEach((i) -> keycloakClientsClient().resource(i).create());
+ }
+ if (getApplication().getKeycloakUsers().size() > 0) {
+ getApplication().getKeycloakUsers().stream().forEach((i) -> keycloakUsersClient().resource(i).create());
+ }
+ if (getApplication().getKeycloakBackups().size() > 0) {
+ getApplication().getKeycloakBackups().stream().forEach((i) -> keycloakBackupsClient().resource(i).create());
+ }
+
+ // Wait for Keycloak (and PostgreSQL) to be ready
+ waitFor(getApplication().getKeycloak());
+ // wait for all resources to be ready
+ waitForKeycloakResourceReadiness();
+ // check that route is up, only if there's a valid external URL available
+ URL externalUrl = getURL();
+ if ((getApplication().getKeycloak().getSpec().getInstances() > 0) && (externalUrl != null)) {
+ WaitersUtil.routeIsUp(externalUrl.toExternalForm())
+ .level(Level.DEBUG)
+ .waitFor();
+ }
+ }
+
+ /**
+ * Wait for Keycloak and PostgreSQL (in case no external database is used) to be ready
+ *
+ * @param keycloak Concrete {@link Keycloak} instance which the method should be wait for
+ */
+ public void waitFor(Keycloak keycloak) {
+ int replicas = keycloak.getSpec().getInstances().intValue();
+ if (replicas > 0) {
+ // 1. check externalDatabase
+ if (keycloak.getSpec().getExternalDatabase() == null || !keycloak.getSpec().getExternalDatabase().getEnabled()) {
+ // 2. wait for PostgreSQL to be ready (Service "keycloak-postgresql" is guaranteed to exist by documentation)
+ new SimpleWaiter(() -> OpenShiftProvisioner.openShift.getPods()
+ .stream()
+ .filter(
+ pod -> OpenShiftProvisioner.openShift.getService("keycloak-postgresql") != null
+ && pod.getMetadata().getLabels().entrySet().containsAll(
+ OpenShiftProvisioner.openShift.getService("keycloak-postgresql").getSpec()
+ .getSelector().entrySet())
+ && ResourceParsers.isPodReady(pod))
+ .count() > 0).level(Level.DEBUG).waitFor();
+ }
+ // 4. wait for >= 1 pods with label controller-revision-hash=keycloak-d86bb6ddc
+ String controllerRevisionHash = getStatefulSet().getStatus().getUpdateRevision();
+ OpenShiftWaiters.get(OpenShiftProvisioner.openShift, ffCheck)
+ .areExactlyNPodsReady(replicas, "controller-revision-hash",
+ controllerRevisionHash)
+ .waitFor();
+ }
+ }
+
+ private void waitForKeycloakResourceReadiness() {
+ new SimpleWaiter(() -> keycloak().get().getStatus().getReady())
+ .reason("Wait for keycloak resource to be ready").level(Level.DEBUG).waitFor();
+ if (getApplication().getKeycloakRealms().size() > 0)
+ new SimpleWaiter(() -> keycloakRealms().stream().map(realm -> realm.get().getStatus().getReady())
+ .reduce(Boolean::logicalAnd).get())
+ .reason("Wait for keycloakrealms to be ready.").level(Level.DEBUG).waitFor();
+ if (getApplication().getKeycloakClients().size() > 0)
+ new SimpleWaiter(() -> keycloakClients().stream().map(realm -> realm.get().getStatus().getReady())
+ .reduce(Boolean::logicalAnd).get())
+ .reason("Wait for keycloakclients to be ready.").level(Level.DEBUG).waitFor();
+ if (getApplication().getKeycloakUsers().size() > 0)
+ new SimpleWaiter(() -> keycloakUsersClient().list().getItems().size() == getApplication().getKeycloakUsers().size())
+ .reason("Wait for keycloakusers to be ready.").level(Level.DEBUG).waitFor(); // no isReady() for users
+ if (getApplication().getKeycloakBackups().size() > 0)
+ new SimpleWaiter(() -> keycloakBackups().stream().map(realm -> realm.get().getStatus().getReady())
+ .reduce(Boolean::logicalAnd).get())
+ .reason("Wait for keycloakbackups to be ready.").level(Level.DEBUG).waitFor();
+ }
+
+ @Override
+ public void undeploy() {
+ // delete custom resources
+ keycloakBackups()
+ .forEach(keycloakBackup -> keycloakBackup.withPropagationPolicy(DeletionPropagation.FOREGROUND).delete());
+ new SimpleWaiter(() -> keycloakBackupsClient().list().getItems().size() == 0)
+ .reason("Wait for all keycloakbackups instances to be deleted.").level(Level.DEBUG).waitFor();
+ keycloakUsers().forEach(keycloakUser -> keycloakUser.withPropagationPolicy(DeletionPropagation.FOREGROUND).delete());
+ new SimpleWaiter(() -> keycloakUsersClient().list().getItems().size() == 0)
+ .reason("Wait for all keycloakusers instances to be deleted.").level(Level.DEBUG).waitFor();
+ keycloakClients()
+ .forEach(keycloakClient -> keycloakClient.withPropagationPolicy(DeletionPropagation.FOREGROUND).delete());
+ keycloakUsers().forEach(keycloakUser -> keycloakUser.withPropagationPolicy(DeletionPropagation.FOREGROUND).delete());
+ new SimpleWaiter(() -> keycloakClientsClient().list().getItems().size() == 0)
+ .reason("Wait for all keycloakclients instances to be deleted.").level(Level.DEBUG).waitFor();
+ keycloakRealms().forEach(keycloakRealm -> keycloakRealm.withPropagationPolicy(DeletionPropagation.FOREGROUND).delete());
+ new SimpleWaiter(() -> keycloakRealmsClient().list().getItems().size() == 0)
+ .reason("Wait for all keycloakrealms instances to be deleted.").level(Level.DEBUG).waitFor();
+ keycloak().withPropagationPolicy(DeletionPropagation.FOREGROUND).delete();
+ new SimpleWaiter(() -> keycloaksClient().list().getItems().size() == 0)
+ .reason("Wait for all keycloakrealms instances to be deleted.").level(Level.DEBUG).waitFor();
+
+ // wait for 0 pods
+ OpenShiftWaiters.get(OpenShiftProvisioner.openShift, () -> false)
+ .areExactlyNPodsReady(0, "app", getApplication().getKeycloak().getKind().toLowerCase()).level(Level.DEBUG)
+ .waitFor();
+ unsubscribe();
+ }
+
+ @Override
+ public void scale(int replicas, boolean wait) {
+ String controllerRevisionHash = getStatefulSet().getStatus().getUpdateRevision();
+ Keycloak tmpKeycloak = keycloak().get();
+ int originalReplicas = tmpKeycloak.getSpec().getInstances().intValue();
+ tmpKeycloak.getSpec().setInstances(Long.valueOf(replicas));
+ keycloak().replace(tmpKeycloak);
+ if (wait) {
+ OpenShiftWaiters.get(OpenShiftProvisioner.openShift, ffCheck)
+ .areExactlyNPodsReady(replicas, "controller-revision-hash", controllerRevisionHash)
+ .level(Level.DEBUG)
+ .waitFor();
+ }
+ new SimpleWaiter(() -> keycloak().get().getStatus().getReady())
+ .reason("Wait for keycloak resource to be ready").level(Level.DEBUG).waitFor();
+ // check that route is up
+ if (originalReplicas == 0 && replicas > 0) {
+ WaitersUtil.routeIsUp(getURL().toExternalForm())
+ .level(Level.DEBUG)
+ .waitFor();
+ }
+ }
+
+ @Override
+ public List getPods() {
+ StatefulSet statefulSet = OpenShiftProvisioner.openShift.getStatefulSet(STATEFUL_SET_NAME);
+ return Objects.nonNull(statefulSet)
+ ? OpenShiftProvisioner.openShift.getLabeledPods("controller-revision-hash",
+ statefulSet.getStatus().getUpdateRevision())
+ : Lists.emptyList();
+ }
+
+ @Override
+ public URL getURL() {
+ // https://github.com/keycloak/keycloak-operator/blob/15.0.2/pkg/apis/keycloak/v1alpha1/keycloak_types.go#L232
+ String externalUrl = keycloak().get().getStatus().getExternalURL();
+ try {
+ return Strings.isNullOrEmpty(externalUrl) ? null : new URL(externalUrl);
+ } catch (MalformedURLException e) {
+ throw new RuntimeException(String.format("Keycloak operator External URL \"%s\" is malformed.", externalUrl), e);
+ }
+ }
+
+ // keycloaks.keycloak.org
+
+ /**
+ * Get a client capable of working with {@link #KEYCLOAK_RESOURCE} custom resource.
+ *
+ * @return client for operations with {@link #KEYCLOAK_RESOURCE} custom resource
+ */
+ public NonNamespaceOperation> keycloaksClient() {
+ if (KEYCLOAKS_CLIENT == null) {
+ CustomResourceDefinition crd = OpenShifts.admin().apiextensions().v1().customResourceDefinitions()
+ .withName(KEYCLOAK_RESOURCE).get();
+ CustomResourceDefinitionContext crdc = CustomResourceDefinitionContext.fromCrd(crd);
+ if (!getCustomResourceDefinitions().contains(KEYCLOAK_RESOURCE)) {
+ throw new RuntimeException(String.format("[%s] custom resource is not provided by [%s] operator.",
+ KEYCLOAK_RESOURCE, OPERATOR_ID));
+ }
+ MixedOperation> keycloaksClient = OpenShifts
+ .master()
+ .newHasMetadataOperation(crdc, Keycloak.class, KeycloakList.class);
+ KEYCLOAKS_CLIENT = keycloaksClient.inNamespace(OpenShiftConfig.namespace());
+ }
+ return KEYCLOAKS_CLIENT;
+ }
+
+ /**
+ * Get a reference to keycloak object. Use get() to get the actual object, or null in case it does not
+ * exist on tested cluster.
+ * @return A concrete {@link Resource} instance representing the {@link Keycloak} resource definition
+ */
+ public Resource keycloak() {
+ return keycloaksClient().withName(getApplication().getKeycloak().getMetadata().getName());
+ }
+
+ // keycloakrealms.keycloak.org
+
+ /**
+ * Get a client capable of working with {@link #KEYCLOAK_REALM_RESOURCE} custom resource.
+ *
+ * @return client for operations with {@link #KEYCLOAK_REALM_RESOURCE} custom resource
+ */
+ public NonNamespaceOperation> keycloakRealmsClient() {
+ if (KEYCLOAK_REALMS_CLIENT == null) {
+ CustomResourceDefinition crd = OpenShifts.admin().apiextensions().v1().customResourceDefinitions()
+ .withName(KEYCLOAK_REALM_RESOURCE).get();
+ CustomResourceDefinitionContext crdc = CustomResourceDefinitionContext.fromCrd(crd);
+ if (!getCustomResourceDefinitions().contains(KEYCLOAK_REALM_RESOURCE)) {
+ throw new RuntimeException(String.format("[%s] custom resource is not provided by [%s] operator.",
+ KEYCLOAK_REALM_RESOURCE, OPERATOR_ID));
+ }
+ MixedOperation> keycloakRealmsClient = OpenShifts
+ .master()
+ .newHasMetadataOperation(crdc, KeycloakRealm.class, KeycloakRealmList.class);
+ KEYCLOAK_REALMS_CLIENT = keycloakRealmsClient.inNamespace(OpenShiftConfig.namespace());
+ }
+ return KEYCLOAK_REALMS_CLIENT;
+ }
+
+ /**
+ * Get a reference to keycloakrealms object. Use get() to get the actual object, or null in case it does not
+ * exist on tested cluster.
+ *
+ * @param name name of the keycloakrealm custom resource
+ * @return A concrete {@link Resource} instance representing the {@link KeycloakRealm} resource definition
+ */
+ public Resource keycloakRealm(String name) {
+ return keycloakRealmsClient().withName(name);
+ }
+
+ /**
+ * Get all keycloakrealms maintained by the current operator instance.
+ *
+ * Be aware that this method return just a references to the addresses, they might not actually exist on the cluster.
+ * Use get() to get the actual object, or null in case it does not exist on tested cluster.
+ * @return A list of {@link Resource} instances representing the {@link KeycloakRealm} resource definitions
+ */
+ public List> keycloakRealms() {
+ RhSsoOperatorApplication rhSsoOperatorApplication = getApplication();
+ return rhSsoOperatorApplication.getKeycloakRealms().stream()
+ .map(keycloakRealm -> keycloakRealm.getMetadata().getName())
+ .map(this::keycloakRealm)
+ .collect(Collectors.toList());
+ }
+
+ // keycloakbackups.keycloak.org
+
+ /**
+ * Get a client capable of working with {@link #KEYCLOAK_BACKUP_RESOURCE} custom resource.
+ *
+ * @return client for operations with {@link #KEYCLOAK_BACKUP_RESOURCE} custom resource
+ */
+ public NonNamespaceOperation> keycloakBackupsClient() {
+ if (KEYCLOAK_BACKUPS_CLIENT == null) {
+ CustomResourceDefinition crd = OpenShifts.admin().apiextensions().v1().customResourceDefinitions()
+ .withName(KEYCLOAK_BACKUP_RESOURCE).get();
+ CustomResourceDefinitionContext crdc = CustomResourceDefinitionContext.fromCrd(crd);
+ if (!getCustomResourceDefinitions().contains(KEYCLOAK_BACKUP_RESOURCE)) {
+ throw new RuntimeException(String.format("[%s] custom resource is not provided by [%s] operator.",
+ KEYCLOAK_BACKUP_RESOURCE, OPERATOR_ID));
+ }
+ MixedOperation> keycloakBackupsClient = OpenShifts
+ .master()
+ .newHasMetadataOperation(crdc, KeycloakBackup.class, KeycloakBackupList.class);
+ KEYCLOAK_BACKUPS_CLIENT = keycloakBackupsClient.inNamespace(OpenShiftConfig.namespace());
+ }
+ return KEYCLOAK_BACKUPS_CLIENT;
+ }
+
+ /**
+ * Get a reference to keycloakbackup object. Use get() to get the actual object, or null in case it does not
+ * exist on tested cluster.
+ *
+ * @param name name of the {@link KeycloakBackup} custom resource
+ * @return A concrete {@link Resource} instance representing the {@link KeycloakBackup} resource definition
+ */
+ public Resource keycloakBackup(String name) {
+ return keycloakBackupsClient().withName(name);
+ }
+
+ /**
+ * Get all keycloakbackups maintained by the current operator instance.
+ *
+ * Be aware that this method return just a references to the addresses, they might not actually exist on the cluster.
+ * Use get() to get the actual object, or null in case it does not exist on tested cluster.
+ * @return A list of {@link Resource} instances representing the {@link KeycloakBackup} resource definitions
+ */
+ public List> keycloakBackups() {
+ RhSsoOperatorApplication rhSsoOperatorApplication = getApplication();
+ return rhSsoOperatorApplication.getKeycloakBackups().stream()
+ .map(keycloakBackup -> keycloakBackup.getMetadata().getName())
+ .map(this::keycloakBackup)
+ .collect(Collectors.toList());
+ }
+
+ // keycloakclients.keycloak.org
+
+ /**
+ * Get a client capable of working with {@link #KEYCLOAK_CLIENT_RESOURCE} custom resource.
+ *
+ * @return client for operations with {@link #KEYCLOAK_CLIENT_RESOURCE} custom resource
+ */
+ public NonNamespaceOperation> keycloakClientsClient() {
+ if (KEYCLOAK_CLIENTS_CLIENT == null) {
+ CustomResourceDefinition crd = OpenShifts.admin().apiextensions().v1().customResourceDefinitions()
+ .withName(KEYCLOAK_CLIENT_RESOURCE).get();
+ CustomResourceDefinitionContext crdc = CustomResourceDefinitionContext.fromCrd(crd);
+ if (!getCustomResourceDefinitions().contains(KEYCLOAK_CLIENT_RESOURCE)) {
+ throw new RuntimeException(String.format("[%s] custom resource is not provided by [%s] operator.",
+ KEYCLOAK_CLIENT_RESOURCE, OPERATOR_ID));
+ }
+ MixedOperation> keycloakClientsClient = OpenShifts
+ .master()
+ .newHasMetadataOperation(crdc, KeycloakClient.class, KeycloakClientList.class);
+ KEYCLOAK_CLIENTS_CLIENT = keycloakClientsClient.inNamespace(OpenShiftConfig.namespace());
+ }
+ return KEYCLOAK_CLIENTS_CLIENT;
+ }
+
+ /**
+ * Get a reference to keycloakclient object. Use get() to get the actual object, or null in case it does not
+ * exist on tested cluster.
+ *
+ * @param name name of the {@link KeycloakClient} custom resource
+ * @return A concrete {@link Resource} instance representing the {@link KeycloakClient} resource definition
+ */
+ public Resource keycloakClient(String name) {
+ return keycloakClientsClient().withName(name);
+ }
+
+ /**
+ * Get all keycloakclients maintained by the current operator instance.
+ *
+ * Be aware that this method return just a references to the addresses, they might not actually exist on the cluster.
+ * Use get() to get the actual object, or null in case it does not exist on tested cluster.
+ * @return A list of {@link Resource} instances representing the {@link KeycloakClient} resource definitions
+ */
+ public List> keycloakClients() {
+ RhSsoOperatorApplication rhSsoOperatorApplication = getApplication();
+ return rhSsoOperatorApplication.getKeycloakClients().stream()
+ .map(keycloakClient -> keycloakClient.getMetadata().getName())
+ .map(this::keycloakClient)
+ .collect(Collectors.toList());
+ }
+
+ // keycloakusers.keycloak.org
+
+ /**
+ * Get a client capable of working with {@link #KEYCLOAK_USER_RESOURCE} custom resource.
+ *
+ * @return client for operations with {@link #KEYCLOAK_USER_RESOURCE} custom resource
+ */
+ public NonNamespaceOperation> keycloakUsersClient() {
+ if (KEYCLOAK_USERS_CLIENT == null) {
+ CustomResourceDefinition crd = OpenShifts.admin().apiextensions().v1().customResourceDefinitions()
+ .withName(KEYCLOAK_USER_RESOURCE).get();
+ CustomResourceDefinitionContext crdc = CustomResourceDefinitionContext.fromCrd(crd);
+ if (!getCustomResourceDefinitions().contains(KEYCLOAK_USER_RESOURCE)) {
+ throw new RuntimeException(String.format("[%s] custom resource is not provided by [%s] operator.",
+ KEYCLOAK_USER_RESOURCE, OPERATOR_ID));
+ }
+ MixedOperation> keycloakUsersClient = OpenShifts
+ .master()
+ .newHasMetadataOperation(crdc, KeycloakUser.class, KeycloakUserList.class);
+ KEYCLOAK_USERS_CLIENT = keycloakUsersClient.inNamespace(OpenShiftConfig.namespace());
+ }
+ return KEYCLOAK_USERS_CLIENT;
+ }
+
+ /**
+ * Get a reference to keycloakuser object. Use get() to get the actual object, or null in case it does not
+ * exist on tested cluster.
+ *
+ * @param name name of the keycloakuser custom resource
+ * @return A concrete {@link Resource} instance representing the {@link KeycloakUser} resource definition
+ */
+ public Resource keycloakUser(String name) {
+ return keycloakUsersClient().withName(name);
+ }
+
+ /**
+ * Get all keycloakusers maintained by the current operator instance.
+ *
+ * Be aware that this method return just a references to the addresses, they might not actually exist on the cluster.
+ * Use get() to get the actual object, or null in case it does not exist on tested cluster.
+ * @return A list of {@link Resource} instances representing the {@link KeycloakUser} resource definitions
+ */
+ public List> keycloakUsers() {
+ RhSsoOperatorApplication rhSsoOperatorApplication = getApplication();
+ return rhSsoOperatorApplication.getKeycloakUsers().stream()
+ .map(keycloakUser -> keycloakUser.getMetadata().getName())
+ .map(this::keycloakUser)
+ .collect(Collectors.toList());
+ }
+
+ /**
+ * @return the underlying StatefulSet which provisions the cluster
+ */
+ private StatefulSet getStatefulSet() {
+ StatefulSet statefulSet = OpenShiftProvisioner.openShift.getStatefulSet(STATEFUL_SET_NAME);
+ if (Objects.isNull(statefulSet)) {
+ throw new IllegalStateException(String.format(
+ "Impossible to find StatefulSet with name=\"%s\"!",
+ STATEFUL_SET_NAME));
+ }
+ return statefulSet;
+ }
+}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/KeycloakRealmImportOperatorProvisionerFactory.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/RhSsoOperatorProvisionerFactory.java
similarity index 62%
rename from tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/KeycloakRealmImportOperatorProvisionerFactory.java
rename to tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/RhSsoOperatorProvisionerFactory.java
index 21906bc2c..e7c86d69f 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/KeycloakRealmImportOperatorProvisionerFactory.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/RhSsoOperatorProvisionerFactory.java
@@ -16,19 +16,18 @@
package org.jboss.intersmash.tools.provision.openshift;
import org.jboss.intersmash.tools.application.Application;
-import org.jboss.intersmash.tools.application.openshift.KeycloakRealmImportOperatorApplication;
+import org.jboss.intersmash.tools.application.openshift.RhSsoOperatorApplication;
import org.jboss.intersmash.tools.provision.ProvisionerFactory;
import lombok.extern.slf4j.Slf4j;
@Slf4j
-public class KeycloakRealmImportOperatorProvisionerFactory
- implements ProvisionerFactory {
+public class RhSsoOperatorProvisionerFactory implements ProvisionerFactory {
@Override
- public KeycloakRealmImportOperatorProvisioner getProvisioner(Application application) {
- if (KeycloakRealmImportOperatorApplication.class.isAssignableFrom(application.getClass()))
- return new KeycloakRealmImportOperatorProvisioner((KeycloakRealmImportOperatorApplication) application);
+ public RhSsoOperatorProvisioner getProvisioner(Application application) {
+ if (RhSsoOperatorApplication.class.isAssignableFrom(application.getClass()))
+ return new RhSsoOperatorProvisioner((RhSsoOperatorApplication) application);
return null;
}
}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/backup/KeycloakBackup.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/backup/KeycloakBackup.java
deleted file mode 100644
index 595edafcc..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/backup/KeycloakBackup.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.backup;
-
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.backup.spec.KeycloakBackupSpec;
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.backup.status.KeycloakBackupStatus;
-import org.jboss.intersmash.tools.provision.openshift.operator.resources.OpenShiftResource;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import io.fabric8.kubernetes.api.model.ObjectMeta;
-import io.fabric8.kubernetes.client.CustomResource;
-import io.fabric8.kubernetes.model.annotation.Group;
-import io.fabric8.kubernetes.model.annotation.Version;
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-/**
- * https://access.redhat.com/documentation/en-us/red_hat_single_sign-on/7.4/html/server_installation_and_configuration_guide/operator#backup-cr
- *
- * https://github.com/keycloak/keycloak-operator/blob/master/pkg/apis/keycloak/v1alpha1/keycloakbackup_types.go
- * https://github.com/keycloak/keycloak-operator/blob/master/deploy/crds/keycloak.org_keycloakbackups_crd.yaml
- */
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-@Group("keycloak.org")
-@Version("v1alpha1")
-public class KeycloakBackup extends CustomResource implements OpenShiftResource {
- /**
- * Standard object’s metadata.
- */
- private ObjectMeta metadata;
-
- /**
- * KeycloakBackupSpec defines the desired state of KeycloakBackup.
- */
- private KeycloakBackupSpec spec;
-
- /**
- * KeycloakBackupStatus defines the observed state of KeycloakBackup.
- */
- private KeycloakBackupStatus status;
-
- @Override
- public KeycloakBackup load(KeycloakBackup loaded) {
- this.setMetadata(loaded.getMetadata());
- this.setSpec(loaded.getSpec());
- return this;
- }
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/backup/KeycloakBackupBuilder.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/backup/KeycloakBackupBuilder.java
index 4b6ef1ef2..d03082065 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/backup/KeycloakBackupBuilder.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/backup/KeycloakBackupBuilder.java
@@ -17,8 +17,9 @@
import java.util.Map;
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.backup.spec.KeycloakAWSSpec;
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.backup.spec.KeycloakBackupSpec;
+import org.keycloak.v1alpha1.KeycloakBackup;
+import org.keycloak.v1alpha1.KeycloakBackupSpec;
+import org.keycloak.v1alpha1.keycloakbackupspec.Aws;
import io.fabric8.kubernetes.api.model.ObjectMeta;
@@ -26,7 +27,7 @@ public final class KeycloakBackupBuilder {
private String name;
private Map labels;
private boolean restore;
- private KeycloakAWSSpec aws;
+ private Aws aws;
// private LabelSelector instanceSelector;
// private String storageClassName;
@@ -73,10 +74,10 @@ public KeycloakBackupBuilder restore(boolean restore) {
* a local Persistent Volume. If this property is not provided - a local
* Persistent Volume backup will be chosen.
*
- * @param aws A {@link KeycloakAWSSpec} instance storing configuration for creating a backup on AWS
+ * @param aws A {@link Aws} instance storing configuration for creating a backup on AWS
* @return this
*/
- public KeycloakBackupBuilder aws(KeycloakAWSSpec aws) {
+ public KeycloakBackupBuilder aws(Aws aws) {
this.aws = aws;
return this;
}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/backup/KeycloakBackupList.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/backup/KeycloakBackupList.java
index 9b5797973..8500c4943 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/backup/KeycloakBackupList.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/backup/KeycloakBackupList.java
@@ -15,6 +15,8 @@
*/
package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.backup;
+import org.keycloak.v1alpha1.KeycloakBackup;
+
import io.fabric8.kubernetes.client.CustomResourceList;
public class KeycloakBackupList extends CustomResourceList {
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/backup/spec/KeycloakAWSSpec.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/backup/spec/KeycloakAWSSpec.java
deleted file mode 100644
index 7185079ab..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/backup/spec/KeycloakAWSSpec.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.backup.spec;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-/**
- * If provided, an automatic database backup will be created on AWS S3 instead of
- * a local Persistent Volume. If this property is not provided - a local
- * Persistent Volume backup will be chosen.
- */
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-public class KeycloakAWSSpec {
- /**
- * If provided, the database backup will be encrypted.
- * Provides a secret name used for encrypting database data.
- * The secret needs to be in the following form:
- *
- * apiVersion: v1
- * kind: Secret
- * metadata:
- * name:
- * type: Opaque
- * stringData:
- * GPG_PUBLIC_KEY:
- * GPG_TRUST_MODEL:
- * GPG_RECIPIENT:
- *
- * For more information, please refer to the Operator documentation.
- */
- private String encryptionKeySecretName;
-
- /**
- * Provides a secret name used for connecting to AWS S3 Service.
- * The secret needs to be in the following form:
- *
- * apiVersion: v1
- * kind: Secret
- * metadata:
- * name:
- * type: Opaque
- * stringData:
- * AWS_S3_BUCKET_NAME:
- * AWS_ACCESS_KEY_ID:
- * AWS_SECRET_ACCESS_KEY:
- *
- * For more information, please refer to the Operator documentation.
- */
- private String credentialsSecretName;
-
- /**
- * If specified, it will be used as a schedule for creating a CronJob.
- */
- private String schedule;
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/backup/spec/KeycloakAWSSpecBuilder.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/backup/spec/KeycloakAWSSpecBuilder.java
index 22543dbcc..fdf036442 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/backup/spec/KeycloakAWSSpecBuilder.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/backup/spec/KeycloakAWSSpecBuilder.java
@@ -15,6 +15,8 @@
*/
package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.backup.spec;
+import org.keycloak.v1alpha1.keycloakbackupspec.Aws;
+
/**
* If provided, an automatic database backup will be created on AWS S3 instead of
* a local Persistent Volume. If this property is not provided - a local
@@ -85,8 +87,8 @@ public KeycloakAWSSpecBuilder schedule(String schedule) {
return this;
}
- public KeycloakAWSSpec build() {
- KeycloakAWSSpec keycloakAWSSpec = new KeycloakAWSSpec();
+ public Aws build() {
+ Aws keycloakAWSSpec = new Aws();
keycloakAWSSpec.setEncryptionKeySecretName(encryptionKeySecretName);
keycloakAWSSpec.setCredentialsSecretName(credentialsSecretName);
keycloakAWSSpec.setSchedule(schedule);
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/backup/spec/KeycloakBackupSpec.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/backup/spec/KeycloakBackupSpec.java
deleted file mode 100644
index d002e429e..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/backup/spec/KeycloakBackupSpec.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.backup.spec;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-public class KeycloakBackupSpec {
- /**
- * Controls automatic restore behavior.
- * Currently not implemented.
- *
- * In the future this will be used to trigger automatic restore for a given KeycloakBackup.
- * Each backup will correspond to a single snapshot of the database (stored either in a
- * Persistent Volume or AWS). If a user wants to restore it, all he/she needs to do is to
- * change this flag to true.
- * Potentially, it will be possible to restore a single backup multiple times.
- */
- private boolean restore;
-
- /**
- * If provided, an automatic database backup will be created on AWS S3 instead of
- * a local Persistent Volume. If this property is not provided - a local
- * Persistent Volume backup will be chosen.
- */
- private KeycloakAWSSpec aws;
-
- // /**
- // * Selector for looking up Keycloak Custom Resources.
- // */
- // private LabelSelector instanceSelector;
-
- // /**
- // * Name of the StorageClass for Postgresql Backup Persistent Volume Claim.
- // */
- // private String storageClassName;
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/backup/status/KeycloakBackupStatus.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/backup/status/KeycloakBackupStatus.java
deleted file mode 100644
index 6d5204786..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/backup/status/KeycloakBackupStatus.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.backup.status;
-
-import java.util.List;
-import java.util.Map;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-public class KeycloakBackupStatus {
-
- /**
- * Current phase of the operator.
- */
- private String phase;
-
- /**
- * Human-readable message indicating details about current operator phase or error.
- */
- private String message;
-
- /**
- * True if all resources are in a ready state and all work is done.
- */
- private boolean ready;
-
- /**
- * A map of all the secondary resources types and names created for this CR.
- * e.g "Deployment": [ "DeploymentName1", "DeploymentName2" ].
- */
- private Map> secondaryResources;
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/client/KeycloakClient.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/client/KeycloakClient.java
deleted file mode 100644
index be5883f4f..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/client/KeycloakClient.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.client;
-
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.client.spec.KeycloakClientSpec;
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.client.status.KeycloakClientStatus;
-import org.jboss.intersmash.tools.provision.openshift.operator.resources.OpenShiftResource;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import io.fabric8.kubernetes.api.model.ObjectMeta;
-import io.fabric8.kubernetes.client.CustomResource;
-import io.fabric8.kubernetes.model.annotation.Group;
-import io.fabric8.kubernetes.model.annotation.Version;
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-/**
- * https://access.redhat.com/documentation/en-us/red_hat_single_sign-on/7.4/html/server_installation_and_configuration_guide/operator#client-cr
- *
- * https://github.com/keycloak/keycloak-operator/blob/master/pkg/apis/keycloak/v1alpha1/keycloakbackup_types.go
- * https://github.com/keycloak/keycloak-operator/blob/master/deploy/crds/keycloak.org_keycloakbackups_crd.yaml
- */
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-@Group("keycloak.org")
-@Version("v1alpha1")
-public class KeycloakClient extends CustomResource implements OpenShiftResource {
- /**
- * Standard object’s metadata.
- */
- private ObjectMeta metadata;
-
- /**
- * KeycloakClientSpec defines the desired state of KeycloakClient.
- */
- private KeycloakClientSpec spec;
-
- /**
- * KeycloakClientStatus defines the observed state of KeycloakClient
- */
- private KeycloakClientStatus status;
-
- @Override
- public KeycloakClient load(KeycloakClient loaded) {
- this.setMetadata(loaded.getMetadata());
- this.setSpec(loaded.getSpec());
- return this;
- }
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/client/KeycloakClientBuilder.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/client/KeycloakClientBuilder.java
index aea14c3ee..a51924c69 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/client/KeycloakClientBuilder.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/client/KeycloakClientBuilder.java
@@ -17,17 +17,18 @@
import java.util.Map;
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.client.spec.KeycloakAPIClient;
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.client.spec.KeycloakClientSpec;
+import org.keycloak.v1alpha1.KeycloakClient;
+import org.keycloak.v1alpha1.KeycloakClientSpec;
+import org.keycloak.v1alpha1.keycloakclientspec.Client;
+import org.keycloak.v1alpha1.keycloakclientspec.RealmSelector;
-import io.fabric8.kubernetes.api.model.LabelSelector;
import io.fabric8.kubernetes.api.model.ObjectMeta;
public final class KeycloakClientBuilder {
private String name;
private Map labels;
- private LabelSelector realmSelector;
- private KeycloakAPIClient client;
+ private RealmSelector realmSelector;
+ private Client client;
/**
* Initialize the {@link KeycloakClientBuilder} with given resource name.
@@ -55,7 +56,7 @@ public KeycloakClientBuilder(String name, Map labels) {
* @param realmSelector Label selector for looking up KeycloakRealm Custom Resources.
* @return this
*/
- public KeycloakClientBuilder realmSelector(LabelSelector realmSelector) {
+ public KeycloakClientBuilder realmSelector(RealmSelector realmSelector) {
this.realmSelector = realmSelector;
return this;
}
@@ -66,7 +67,7 @@ public KeycloakClientBuilder realmSelector(LabelSelector realmSelector) {
* @param client Keycloak REST API client.
* @return this
*/
- public KeycloakClientBuilder client(KeycloakAPIClient client) {
+ public KeycloakClientBuilder client(Client client) {
this.client = client;
return this;
}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/client/KeycloakClientList.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/client/KeycloakClientList.java
index 247b4cf2a..7b69f18a6 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/client/KeycloakClientList.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/client/KeycloakClientList.java
@@ -15,6 +15,8 @@
*/
package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.client;
+import org.keycloak.v1alpha1.KeycloakClient;
+
import io.fabric8.kubernetes.client.CustomResourceList;
public class KeycloakClientList extends CustomResourceList {
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/client/spec/KeycloakAPIClient.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/client/spec/KeycloakAPIClient.java
deleted file mode 100644
index c5da7d84d..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/client/spec/KeycloakAPIClient.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.client.spec;
-
-import java.util.List;
-import java.util.Map;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-/**
- * Keycloak Client REST object.
- */
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-public class KeycloakAPIClient {
- /**
- * Client ID. If not specified, automatically generated.
- */
- private String id;
-
- /**
- * Client ID.
- */
- private String clientId;
-
- /**
- * Client name.
- */
- private String name;
-
- /**
- * Surrogate Authentication Required option.
- */
- private boolean surrogateAuthRequired;
-
- /**
- * Client enabled flag.
- */
- private boolean enabled;
-
- /**
- * What Client authentication type to use.
- */
- private String clientAuthenticatorType;
-
- /**
- * Client Secret. The Operator will automatically create a Secret based on this value.
- */
- private String secret;
-
- /**
- * Application base URL.
- */
- private String baseUrl;
-
- /**
- * Application Admin URL.
- */
- private String adminUrl;
-
- /**
- * Application root URL.
- */
- private String rootUrl;
-
- /**
- * Client description.
- */
- private String description;
-
- /**
- * Default Client roles.
- */
- private List defaultRoles;
-
- /**
- * A list of valid Redirection URLs.
- */
- private List redirectUris;
-
- /**
- * A list of valid Web Origins.
- */
- private List webOrigins;
-
- /**
- * Not Before setting.
- */
- private int notBefore;
-
- /**
- * True if a client supports only Bearer Tokens.
- */
- private boolean bearerOnly;
-
- /**
- * True if Consent Screen is required.
- */
- private boolean consentRequired;
-
- /**
- * True if Standard flow is enabled.
- */
- private boolean standardFlowEnabled;
-
- /**
- * True if Implicit flow is enabled.
- */
- private boolean implicitFlowEnabled;
-
- /**
- * True if Direct Grant is enabled.
- */
- private boolean directAccessGrantsEnabled;
-
- /**
- * True if Service Accounts are enabled.
- */
- private boolean serviceAccountsEnabled;
-
- /**
- * True if this is a public Client.
- */
- private boolean publicClient;
-
- /**
- * True if this client supports Front Channel logout.
- */
- private boolean frontchannelLogout;
-
- /**
- * Protocol used for this Client.
- */
- private String protocol;
-
- /**
- * Client Attributes.
- */
- private Map attributes;
-
- /**
- * True if Full Scope is allowed.
- */
- private boolean fullScopeAllowed;
-
- /**
- * Node registration timeout.
- */
- private int nodeReRegistrationTimeout;
-
- /**
- * Protocol Mappers.
- */
- private List protocolMappers;
-
- /**
- * True to use a Template Config.
- */
- private boolean useTemplateConfig;
-
- /**
- * True to use Template Scope.
- */
- private boolean useTemplateScope;
-
- /**
- * True to use Template Mappers.
- */
- private boolean useTemplateMappers;
-
- /**
- * Access options.
- */
- private Map access;
-
- // /**
- // * A list of optional client scopes. Optional client scopes are
- // * applied when issuing tokens for this client, but only when they
- // * are requested by the scope parameter in the OpenID Connect
- // * authorization request.
- // */
- // private List optionalClientScopes;
- //
- // /**
- // * A list of default client scopes. Default client scopes are
- // * always applied when issuing OpenID Connect tokens or SAML
- // * assertions for this client.
- // */
- // private List defaultClientScopes;
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/client/spec/KeycloakAPIClientBuilder.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/client/spec/KeycloakAPIClientBuilder.java
index 0b2beceab..b1f1a266e 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/client/spec/KeycloakAPIClientBuilder.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/client/spec/KeycloakAPIClientBuilder.java
@@ -20,6 +20,9 @@
import java.util.List;
import java.util.Map;
+import org.keycloak.v1alpha1.keycloakrealmspec.realm.Clients;
+import org.keycloak.v1alpha1.keycloakrealmspec.realm.clients.ProtocolMappers;
+
/**
* Keycloak Client REST object.
*/
@@ -38,7 +41,7 @@ public final class KeycloakAPIClientBuilder {
private List defaultRoles;
private List redirectUris;
private List webOrigins;
- private int notBefore;
+ private long notBefore;
private boolean bearerOnly;
private boolean consentRequired;
private boolean standardFlowEnabled;
@@ -50,8 +53,8 @@ public final class KeycloakAPIClientBuilder {
private String protocol;
private Map attributes;
private boolean fullScopeAllowed;
- private int nodeReRegistrationTimeout;
- private List protocolMappers;
+ private long nodeReRegistrationTimeout;
+ private List protocolMappers;
private boolean useTemplateConfig;
private boolean useTemplateScope;
private boolean useTemplateMappers;
@@ -416,10 +419,10 @@ public KeycloakAPIClientBuilder nodeReRegistrationTimeout(int nodeReRegistration
/**
* Set the Protocol Mappers.
*
- * @param protocolMappers List of {@link KeycloakProtocolMapper} instances that should be used
+ * @param protocolMappers List of {@link ProtocolMappers} instances that should be used
* @return this
*/
- public KeycloakAPIClientBuilder protocolMappers(List protocolMappers) {
+ public KeycloakAPIClientBuilder protocolMappers(List protocolMappers) {
this.protocolMappers = protocolMappers;
return this;
}
@@ -427,10 +430,10 @@ public KeycloakAPIClientBuilder protocolMappers(List pro
/**
* Add a Protocol Mapper.
*
- * @param protocolMapper {@link KeycloakProtocolMapper} instance that should be added
+ * @param protocolMapper {@link ProtocolMappers} instance that should be added
* @return this
*/
- public KeycloakAPIClientBuilder protocolMappers(KeycloakProtocolMapper protocolMapper) {
+ public KeycloakAPIClientBuilder protocolMappers(ProtocolMappers protocolMapper) {
if (protocolMappers == null) {
protocolMappers = new ArrayList<>();
}
@@ -545,8 +548,8 @@ public KeycloakAPIClientBuilder access(String key, boolean value) {
// return this;
// }
- public KeycloakAPIClient build() {
- KeycloakAPIClient keycloakAPIClient = new KeycloakAPIClient();
+ public Clients build() {
+ Clients keycloakAPIClient = new Clients();
keycloakAPIClient.setId(id);
keycloakAPIClient.setClientId(clientId);
keycloakAPIClient.setName(name);
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/client/spec/KeycloakClientSpec.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/client/spec/KeycloakClientSpec.java
deleted file mode 100644
index 152ba491b..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/client/spec/KeycloakClientSpec.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.client.spec;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import io.fabric8.kubernetes.api.model.LabelSelector;
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-/**
- * KeycloakClientSpec defines the desired state of KeycloakClient.
- */
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-public class KeycloakClientSpec {
-
- /**
- * Selector for looking up KeycloakRealm Custom Resources.
- */
- private LabelSelector realmSelector;
-
- /**
- * Keycloak Client REST object.
- */
- private KeycloakAPIClient client;
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/client/spec/KeycloakProtocolMapper.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/client/spec/KeycloakProtocolMapper.java
deleted file mode 100644
index 99b0f0958..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/client/spec/KeycloakProtocolMapper.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.client.spec;
-
-import java.util.Map;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-public class KeycloakProtocolMapper {
-
- /**
- * Protocol Mapper ID.
- */
- private String id;
-
- /**
- * Protocol Mapper Name.
- */
- private String name;
-
- /**
- * Protocol to use.
- */
- private String protocol;
-
- /**
- * Protocol Mapper to use.
- */
- private String protocolMapper;
-
- /**
- * True if Consent Screen is required.
- */
- private boolean consentRequired;
-
- /**
- * Text to use for displaying Consent Screen.
- */
- private String consentText;
-
- /**
- * Config options.
- */
- private Map config;
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/client/spec/KeycloakProtocolMapperBuilder.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/client/spec/KeycloakProtocolMapperBuilder.java
index abf8cdb1d..63d6ea63d 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/client/spec/KeycloakProtocolMapperBuilder.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/client/spec/KeycloakProtocolMapperBuilder.java
@@ -18,6 +18,8 @@
import java.util.HashMap;
import java.util.Map;
+import org.keycloak.v1alpha1.keycloakclientspec.client.ProtocolMappers;
+
public final class KeycloakProtocolMapperBuilder {
private String id;
private String name;
@@ -119,8 +121,8 @@ public KeycloakProtocolMapperBuilder config(String key, String value) {
return this;
}
- public KeycloakProtocolMapper build() {
- KeycloakProtocolMapper keycloakProtocolMapper = new KeycloakProtocolMapper();
+ public ProtocolMappers build() {
+ ProtocolMappers keycloakProtocolMapper = new ProtocolMappers();
keycloakProtocolMapper.setId(id);
keycloakProtocolMapper.setName(name);
keycloakProtocolMapper.setProtocol(protocol);
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/client/status/KeycloakClientStatus.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/client/status/KeycloakClientStatus.java
deleted file mode 100644
index 81e8275a0..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/client/status/KeycloakClientStatus.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.client.status;
-
-import java.util.List;
-import java.util.Map;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-/**
- * KeycloakClientStatus defines the observed state of KeycloakClient.
- */
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-public class KeycloakClientStatus {
-
- /**
- * Current phase of the operator.
- */
- private String phase;
-
- /**
- * Human-readable message indicating details about current operator phase or error.
- */
- private String message;
-
- /**
- * True if all resources are in a ready state and all work is done.
- */
- private boolean ready;
-
- /**
- * A map of all the secondary resources types and names created for this CR.
- * e.g "Deployment": [ "DeploymentName1", "DeploymentName2" ].
- */
- private Map> secondaryResources;
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/Keycloak.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/Keycloak.java
deleted file mode 100644
index f73c19b1b..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/Keycloak.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.keycloak;
-
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.keycloak.spec.KeycloakSpec;
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.keycloak.status.KeycloakStatus;
-import org.jboss.intersmash.tools.provision.openshift.operator.resources.OpenShiftResource;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import io.fabric8.kubernetes.api.model.ObjectMeta;
-import io.fabric8.kubernetes.client.CustomResource;
-import io.fabric8.kubernetes.model.annotation.Group;
-import io.fabric8.kubernetes.model.annotation.Version;
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-/**
- * https://github.com/keycloak/keycloak-operator/blob/master/pkg/apis/keycloak/v1alpha1/keycloak_types.go
- * https://github.com/keycloak/keycloak-operator/blob/master/deploy/crds/keycloak.org_keycloaks_crd.yaml
- */
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-@Group("keycloak.org")
-@Version("v1alpha1")
-public class Keycloak extends CustomResource implements OpenShiftResource {
-
- /**
- * Standard object’s metadata.
- */
- private ObjectMeta metadata;
-
- /**
- * KeycloakSpec defines the desired state of Keycloak.
- */
- private KeycloakSpec spec;
-
- /**
- * KeycloakStatus defines the observed state of Keycloak.
- */
- private KeycloakStatus status;
-
- @Override
- public Keycloak load(Keycloak loaded) {
- this.setMetadata(loaded.getMetadata());
- this.setSpec(loaded.getSpec());
- return this;
- }
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/KeycloakBuilder.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/KeycloakBuilder.java
index 765adcbba..ecb1ace99 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/KeycloakBuilder.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/KeycloakBuilder.java
@@ -19,10 +19,11 @@
import java.util.List;
import java.util.Map;
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.keycloak.spec.KeycloakExternalAccess;
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.keycloak.spec.KeycloakExternalDatabase;
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.keycloak.spec.KeycloakSpec;
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.keycloak.spec.PodDisruptionBudgetConfig;
+import org.keycloak.v1alpha1.Keycloak;
+import org.keycloak.v1alpha1.KeycloakSpec;
+import org.keycloak.v1alpha1.keycloakspec.ExternalAccess;
+import org.keycloak.v1alpha1.keycloakspec.ExternalDatabase;
+import org.keycloak.v1alpha1.keycloakspec.PodDisruptionBudget;
import io.fabric8.kubernetes.api.model.ObjectMeta;
@@ -32,11 +33,11 @@ public final class KeycloakBuilder {
// private boolean unmanaged;
// private KeycloakExternal external;
private List extensions;
- private int instances;
- private KeycloakExternalAccess externalAccess;
- private KeycloakExternalDatabase externalDatabase;
+ private long instances;
+ private ExternalAccess externalAccess;
+ private ExternalDatabase externalDatabase;
private String profile;
- private PodDisruptionBudgetConfig podDisruptionBudget;
+ private PodDisruptionBudget podDisruptionBudget;
// private KeycloakDeploymentSpec keycloakDeploymentSpec;
// private PostgresqlDeploymentSpec postgresDeploymentSpec;
// private MigrateConfig migration;
@@ -122,7 +123,7 @@ public KeycloakBuilder instances(int instances) {
* @param externalAccess Stores external access configuration for Keycloak
* @return this
*/
- public KeycloakBuilder externalAccess(KeycloakExternalAccess externalAccess) {
+ public KeycloakBuilder externalAccess(ExternalAccess externalAccess) {
this.externalAccess = externalAccess;
return this;
}
@@ -158,7 +159,7 @@ public KeycloakBuilder externalAccess(KeycloakExternalAccess externalAccess) {
* @param externalDatabase Stores external database configuration for Keycloak
* @return this
*/
- public KeycloakBuilder externalDatabase(KeycloakExternalDatabase externalDatabase) {
+ public KeycloakBuilder externalDatabase(ExternalDatabase externalDatabase) {
this.externalDatabase = externalDatabase;
return this;
}
@@ -180,7 +181,7 @@ public KeycloakBuilder profile(String profile) {
* @param podDisruptionBudget Stores pod disruption budget configuration
* @return this
*/
- public KeycloakBuilder podDisruptionBudget(PodDisruptionBudgetConfig podDisruptionBudget) {
+ public KeycloakBuilder podDisruptionBudget(PodDisruptionBudget podDisruptionBudget) {
this.podDisruptionBudget = podDisruptionBudget;
return this;
}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/KeycloakList.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/KeycloakList.java
index 4c56d8018..715ef7015 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/KeycloakList.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/KeycloakList.java
@@ -15,6 +15,8 @@
*/
package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.keycloak;
+import org.keycloak.v1alpha1.Keycloak;
+
import io.fabric8.kubernetes.client.CustomResourceList;
public class KeycloakList extends CustomResourceList {
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/BackupConfig.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/BackupConfig.java
deleted file mode 100644
index fe1bea769..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/BackupConfig.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.keycloak.spec;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-/**
- * Specify Migration configuration.
- */
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-public class BackupConfig {
-
- /**
- * If set to true, the operator will do database backup before doing migration.
- */
- private boolean enabled;
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/BackupConfigBuilder.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/BackupConfigBuilder.java
deleted file mode 100644
index 697a266a3..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/BackupConfigBuilder.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.keycloak.spec;
-
-/**
- * Specify Migration configuration.
- */
-public final class BackupConfigBuilder {
- private boolean enabled;
-
- /**
- * If set to true, the operator will do database backup before doing migration.
- *
- * @param enabled Whether the operator will do database backup before doing migration
- * @return this
- */
- public BackupConfigBuilder enabled(boolean enabled) {
- this.enabled = enabled;
- return this;
- }
-
- public BackupConfig build() {
- BackupConfig backupConfig = new BackupConfig();
- backupConfig.setEnabled(enabled);
- return backupConfig;
- }
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/ConfigMapVolumeSpec.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/ConfigMapVolumeSpec.java
deleted file mode 100644
index 5f1a190af..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/ConfigMapVolumeSpec.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.keycloak.spec;
-
-import java.util.List;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import io.fabric8.kubernetes.api.model.KeyToPath;
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-public class ConfigMapVolumeSpec {
-
- /**
- * ConfigMap name.
- */
- private String name;
-
- /**
- * An absolute path where to mount it.
- */
- private String mountPath;
-
- /**
- * ConfigMap mount details.
- */
- private List items;
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/ConfigMapVolumeSpecBuilder.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/ConfigMapVolumeSpecBuilder.java
index 66cc401a9..79446a052 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/ConfigMapVolumeSpecBuilder.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/ConfigMapVolumeSpecBuilder.java
@@ -18,12 +18,12 @@
import java.util.ArrayList;
import java.util.List;
-import io.fabric8.kubernetes.api.model.KeyToPath;
+import org.keycloak.v1alpha1.keycloakspec.keycloakdeploymentspec.experimental.volumes.items.Items;
public final class ConfigMapVolumeSpecBuilder {
private String name;
private String mountPath;
- private List items;
+ private List items;
/**
* Set the ConfigMap name.
@@ -50,10 +50,10 @@ public ConfigMapVolumeSpecBuilder mountPath(String mountPath) {
/**
* ConfigMap mount details.
*
- * @param items List of {@link KeyToPath} instances representing the ConfigMap mount details
+ * @param items List of {@link Items} instances representing the ConfigMap mount details
* @return this
*/
- public ConfigMapVolumeSpecBuilder items(List items) {
+ public ConfigMapVolumeSpecBuilder items(List items) {
this.items = items;
return this;
}
@@ -61,10 +61,10 @@ public ConfigMapVolumeSpecBuilder items(List items) {
/**
* Add one ConfigMap mount detail item.
*
- * @param item {@link KeyToPath} instances representing the ConfigMap mount details that should be added
+ * @param item {@link Items} instances representing the ConfigMap mount details that should be added
* @return this
*/
- public ConfigMapVolumeSpecBuilder items(KeyToPath item) {
+ public ConfigMapVolumeSpecBuilder items(Items item) {
if (items == null) {
items = new ArrayList<>();
}
@@ -72,8 +72,8 @@ public ConfigMapVolumeSpecBuilder items(KeyToPath item) {
return this;
}
- public ConfigMapVolumeSpec build() {
- ConfigMapVolumeSpec configMapVolumeSpec = new ConfigMapVolumeSpec();
+ public org.keycloak.v1alpha1.keycloakspec.keycloakdeploymentspec.experimental.volumes.Items build() {
+ org.keycloak.v1alpha1.keycloakspec.keycloakdeploymentspec.experimental.volumes.Items configMapVolumeSpec = new org.keycloak.v1alpha1.keycloakspec.keycloakdeploymentspec.experimental.volumes.Items();
configMapVolumeSpec.setName(name);
configMapVolumeSpec.setMountPath(mountPath);
configMapVolumeSpec.setItems(items);
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/ExperimentalSpec.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/ExperimentalSpec.java
deleted file mode 100644
index 7c831e548..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/ExperimentalSpec.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.keycloak.spec;
-
-import java.util.List;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import io.fabric8.kubernetes.api.model.EnvVar;
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-/**
- * Experimental section
- * NOTE: This section might change or get removed without any notice. It may also cause the deployment to behave
- * in an unpredictable fashion. Please use with care.
- */
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-public class ExperimentalSpec {
-
- /**
- * Arguments to the entrypoint. Translates into Container CMD.
- */
- private List args;
-
- /**
- * Container command. Translates into Container ENTRYPOINT.
- */
- private List command;
-
- /**
- * List of environment variables to set in the container.
- */
- private List env;
-
- /**
- * Additional volume mounts
- */
- private VolumesSpec volumes;
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/ExperimentalSpecBuilder.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/ExperimentalSpecBuilder.java
index b1802463f..1260f6cbd 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/ExperimentalSpecBuilder.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/ExperimentalSpecBuilder.java
@@ -18,7 +18,10 @@
import java.util.ArrayList;
import java.util.List;
-import io.fabric8.kubernetes.api.model.EnvVar;
+import org.keycloak.v1alpha1.keycloakspec.keycloakdeploymentspec.Experimental;
+import org.keycloak.v1alpha1.keycloakspec.keycloakdeploymentspec.experimental.Env;
+import org.keycloak.v1alpha1.keycloakspec.keycloakdeploymentspec.experimental.Volumes;
+import org.keycloak.v1alpha1.keycloakspec.keycloakdeploymentspec.experimental.volumes.Items;
/**
* Experimental section
@@ -28,8 +31,8 @@
public final class ExperimentalSpecBuilder {
private List args;
private List command;
- private List env;
- private VolumesSpec volumes;
+ private List env;
+ private Volumes volumes;
/**
* Set the arguments to the entrypoint. Translates into Container CMD.
@@ -87,7 +90,7 @@ public ExperimentalSpecBuilder command(String command) {
* @param env List of environment variables
* @return this
*/
- public ExperimentalSpecBuilder env(List env) {
+ public ExperimentalSpecBuilder env(List env) {
this.env = env;
return this;
}
@@ -98,7 +101,7 @@ public ExperimentalSpecBuilder env(List env) {
* @param env Environment variable that should be added
* @return this
*/
- public ExperimentalSpecBuilder env(EnvVar env) {
+ public ExperimentalSpecBuilder env(Env env) {
if (this.env == null) {
this.env = new ArrayList<>();
}
@@ -109,16 +112,16 @@ public ExperimentalSpecBuilder env(EnvVar env) {
/**
* Additional volume mounts.
*
- * @param volumes {@link VolumesSpec} instance storing volume mount definitions
+ * @param volumes {@link Items} instance storing volume mount definitions
* @return this
*/
- public ExperimentalSpecBuilder volumes(VolumesSpec volumes) {
+ public ExperimentalSpecBuilder volumes(Volumes volumes) {
this.volumes = volumes;
return this;
}
- public ExperimentalSpec build() {
- ExperimentalSpec experimentalSpec = new ExperimentalSpec();
+ public Experimental build() {
+ Experimental experimentalSpec = new Experimental();
experimentalSpec.setArgs(args);
experimentalSpec.setCommand(command);
experimentalSpec.setEnv(env);
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/KeycloakDeploymentSpec.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/KeycloakDeploymentSpec.java
deleted file mode 100644
index 2d2a345de..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/KeycloakDeploymentSpec.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.keycloak.spec;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import io.fabric8.kubernetes.api.model.ResourceRequirements;
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-/**
- * Resources (Requests and Limits) for KeycloakDeployment.
- */
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-public class KeycloakDeploymentSpec {
-
- /**
- * Resources (Requests and Limits) for the Pods.
- */
- private ResourceRequirements resources;
-
- /**
- * Experimental section
- * NOTE: This section might change or get removed without any notice. It may also cause the deployment to behave
- * in an unpredictable fashion. Please use with care.
- */
- private ExperimentalSpec experimental;
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/KeycloakDeploymentSpecBuilder.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/KeycloakDeploymentSpecBuilder.java
index 7b019a0a6..2fd4dd85d 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/KeycloakDeploymentSpecBuilder.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/KeycloakDeploymentSpecBuilder.java
@@ -15,14 +15,16 @@
*/
package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.keycloak.spec;
-import io.fabric8.kubernetes.api.model.ResourceRequirements;
+import org.keycloak.v1alpha1.keycloakspec.KeycloakDeploymentSpec;
+import org.keycloak.v1alpha1.keycloakspec.keycloakdeploymentspec.Experimental;
+import org.keycloak.v1alpha1.keycloakspec.keycloakdeploymentspec.Resources;
/**
* Resources (Requests and Limits) for KeycloakDeployment.
*/
public final class KeycloakDeploymentSpecBuilder {
- private ResourceRequirements resources;
- private ExperimentalSpec experimental;
+ private Resources resources;
+ private Experimental experimental;
/**
* Set the Resources (Requests and Limits) for the Pods.
@@ -30,7 +32,7 @@ public final class KeycloakDeploymentSpecBuilder {
* @param resources The Resources (Requests and Limits) for the Pods
* @return this
*/
- public KeycloakDeploymentSpecBuilder resources(ResourceRequirements resources) {
+ public KeycloakDeploymentSpecBuilder resources(Resources resources) {
this.resources = resources;
return this;
}
@@ -43,7 +45,7 @@ public KeycloakDeploymentSpecBuilder resources(ResourceRequirements resources) {
* @param experimental The experimental section definition
* @return this
*/
- public KeycloakDeploymentSpecBuilder experimental(ExperimentalSpec experimental) {
+ public KeycloakDeploymentSpecBuilder experimental(Experimental experimental) {
this.experimental = experimental;
return this;
}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/KeycloakExternal.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/KeycloakExternal.java
deleted file mode 100644
index a8abe549b..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/KeycloakExternal.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.keycloak.spec;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-/**
- * Contains configuration for external Keycloak instances. Unmanaged needs to be set to true to use this.
- */
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-public class KeycloakExternal {
- /**
- * If set to true, this Keycloak will be treated as an external instance.
- * The unmanaged field also needs to be set to true if this field is true.
- */
- private boolean enabled;
-
- /**
- * The URL to use for the keycloak admin API. Needs to be set if external is true.
- */
- private String url;
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/KeycloakExternalAccess.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/KeycloakExternalAccess.java
deleted file mode 100644
index 4eedc0019..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/KeycloakExternalAccess.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.keycloak.spec;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-/**
- * Controls external Ingress/Route settings.
- */
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-public class KeycloakExternalAccess {
-
- /**
- * If set to true, the Operator will create an Ingress or a Route pointing to Keycloak.
- */
- private boolean enabled;
- //
- // /**
- // * TLS Termination type for the external access. Setting this field to "reencrypt" will
- // * terminate TLS on the Ingress/Route level. Setting this field to "passthrough" will
- // * send encrypted traffic to the Pod. If unspecified, defaults to "reencrypt".
- // * Note, that this setting has no effect on Ingress
- // * as Ingress TLS settings are not reconciled by this operator. In other words,
- // * Ingress TLS configuration is the same in both cases and it is up to the user
- // * to configure TLS section of the Ingress.
- // */
- // private String tlsTermination;
- //
- // /**
- // * If set, the Operator will use value of host for Ingress/Route host instead of default value keycloak.local for
- // * ingress and automatically chosen name for Route.
- // */
- // private String host;
-
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/KeycloakExternalAccessBuilder.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/KeycloakExternalAccessBuilder.java
index 23dbcf75e..f65d475e9 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/KeycloakExternalAccessBuilder.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/KeycloakExternalAccessBuilder.java
@@ -15,6 +15,8 @@
*/
package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.keycloak.spec;
+import org.keycloak.v1alpha1.keycloakspec.ExternalAccess;
+
/**
* Controls external Ingress/Route settings.
*/
@@ -59,8 +61,8 @@ public KeycloakExternalAccessBuilder enabled(boolean enabled) {
// return this;
// }
- public KeycloakExternalAccess build() {
- KeycloakExternalAccess keycloakExternalAccess = new KeycloakExternalAccess();
+ public ExternalAccess build() {
+ ExternalAccess keycloakExternalAccess = new ExternalAccess();
keycloakExternalAccess.setEnabled(enabled);
// keycloakExternalAccess.setTlsTermination(tlsTermination);
// keycloakExternalAccess.setHost(host);
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/KeycloakExternalBuilder.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/KeycloakExternalBuilder.java
index fb660d289..beebbe243 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/KeycloakExternalBuilder.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/KeycloakExternalBuilder.java
@@ -15,6 +15,8 @@
*/
package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.keycloak.spec;
+import org.keycloak.v1alpha1.keycloakspec.External;
+
/**
* Contains configuration for external Keycloak instances. Unmanaged needs to be set to true to use this.
*/
@@ -45,8 +47,8 @@ public KeycloakExternalBuilder url(String url) {
return this;
}
- public KeycloakExternal build() {
- KeycloakExternal keycloakExternal = new KeycloakExternal();
+ public External build() {
+ External keycloakExternal = new External();
keycloakExternal.setEnabled(enabled);
keycloakExternal.setUrl(url);
return keycloakExternal;
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/KeycloakExternalDatabase.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/KeycloakExternalDatabase.java
deleted file mode 100644
index 11db35b8c..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/KeycloakExternalDatabase.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.keycloak.spec;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-/**
- * Controls external database settings.
- * Using an external database requires providing a secret containing credentials
- * as well as connection details. Here's an example of such secret:
- *
- * apiVersion: v1
- * kind: Secret
- * metadata:
- * name: keycloak-db-secret
- * namespace: keycloak
- * stringData:
- * POSTGRES_DATABASE: <Database Name>
- * POSTGRES_EXTERNAL_ADDRESS: <External Database IP or URL (resolvable by K8s)>
- * POSTGRES_EXTERNAL_PORT: <External Database Port>
- * # Strongly recommended to use <'Keycloak CR Name'-postgresql>
- * POSTGRES_HOST: <Database Service Name>
- * POSTGRES_PASSWORD: <Database Password>
- * # Required for AWS Backup functionality
- * POSTGRES_SUPERUSER: true
- * POSTGRES_USERNAME: <Database Username>
- * type: Opaque
- *
- * Both POSTGRES_EXTERNAL_ADDRESS and POSTGRES_EXTERNAL_PORT are specifically required for creating
- * connection to the external database. The secret name is created using the following convention:
- * <Custom Resource Name>-db-secret
- *
- * For more information, please refer to the Operator documentation.
- */
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-public class KeycloakExternalDatabase {
- /**
- * If set to true, the Operator will use an external database.
- */
- private boolean enabled;
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/KeycloakExternalDatabaseBuilder.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/KeycloakExternalDatabaseBuilder.java
index cf86523ef..6645ed137 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/KeycloakExternalDatabaseBuilder.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/KeycloakExternalDatabaseBuilder.java
@@ -15,6 +15,8 @@
*/
package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.keycloak.spec;
+import org.keycloak.v1alpha1.keycloakspec.ExternalDatabase;
+
/**
* Controls external database settings.
* Using an external database requires providing a secret containing credentials
@@ -57,8 +59,8 @@ public KeycloakExternalDatabaseBuilder enabled(boolean enabled) {
return this;
}
- public KeycloakExternalDatabase build() {
- KeycloakExternalDatabase keycloakExternalDatabase = new KeycloakExternalDatabase();
+ public ExternalDatabase build() {
+ ExternalDatabase keycloakExternalDatabase = new ExternalDatabase();
keycloakExternalDatabase.setEnabled(enabled);
return keycloakExternalDatabase;
}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/KeycloakSpec.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/KeycloakSpec.java
deleted file mode 100644
index 7db8f902e..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/KeycloakSpec.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.keycloak.spec;
-
-import java.util.List;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-/**
- * KeycloakSpec defines the desired state of Keycloak.
- */
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-public class KeycloakSpec {
-
- // /**
- // * When set to true, this Keycloak will be marked as unmanaged and will not be managed by this operator.
- // *
- // * It can then be used for targeting purposes.
- // */
- // private boolean unmanaged;
- //
- // /**
- // * Contains configuration for external Keycloak instances. Unmanaged needs to be set to true to use this.
- // */
- // private KeycloakExternal external;
-
- /**
- * A list of extensions, where each one is a URL to a JAR files that will be deployed in Keycloak.
- */
- private List extensions;
-
- /**
- * Number of Keycloak instances in HA mode. Default is 1.
- */
- private int instances;
-
- /**
- * Controls external Ingress/Route settings.
- */
- private KeycloakExternalAccess externalAccess;
-
- /**
- * Controls external database settings.
- * Using an external database requires providing a secret containing credentials
- * as well as connection details. Here's an example of such secret:
- *
- * apiVersion: v1
- * kind: Secret
- * metadata:
- * name: keycloak-db-secret
- * namespace: keycloak
- * stringData:
- * POSTGRES_DATABASE:
- * POSTGRES_EXTERNAL_ADDRESS:
- * POSTGRES_EXTERNAL_PORT:
- * # Strongly recommended to use <'Keycloak CR Name'-postgresql>
- * POSTGRES_HOST:
- * POSTGRES_PASSWORD:
- * # Required for AWS Backup functionality
- * POSTGRES_SUPERUSER: true
- * POSTGRES_USERNAME:
- * type: Opaque
- *
- * Both POSTGRES_EXTERNAL_ADDRESS and POSTGRES_EXTERNAL_PORT are specifically required for creating
- * connection to the external database. The secret name is created using the following convention:
- * -db-secret
- *
- * For more information, please refer to the Operator documentation.
- */
- private KeycloakExternalDatabase externalDatabase;
-
- /**
- * Profile used for controlling Operator behavior. Default is empty.
- */
- private String profile;
-
- /**
- * Specify PodDisruptionBudget configuration.
- */
- private PodDisruptionBudgetConfig podDisruptionBudget;
-
- // /**
- // * Resources (Requests and Limits) for KeycloakDeployment.
- // */
- // private KeycloakDeploymentSpec keycloakDeploymentSpec;
- //
- // /**
- // * Resources (Requests and Limits) for PostgresDeployment.
- // */
- // private PostgresqlDeploymentSpec postgresDeploymentSpec;
- //
- // /**
- // * Specify Migration configuration.
- // */
- // private MigrateConfig migration;
- //
- // /**
- // * Name of the StorageClass for Postgresql Persistent Volume Claim.
- // */
- // private String storageClassName;
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/MigrateConfig.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/MigrateConfig.java
deleted file mode 100644
index 9fb678570..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/MigrateConfig.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.keycloak.spec;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-/**
- * Specify Migration configuration.
- */
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-public class MigrateConfig {
- /**
- * Specify migration strategy.
- */
- private String strategy;
-
- /**
- * Set it to config backup policy for migration.
- */
- private BackupConfig backups;
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/MigrateConfigBuilder.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/MigrateConfigBuilder.java
deleted file mode 100644
index 911aec19b..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/MigrateConfigBuilder.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.keycloak.spec;
-
-/**
- * Specify Migration configuration.
- */
-public final class MigrateConfigBuilder {
- private String strategy;
- private BackupConfig backups;
-
- /**
- * Specify migration strategy.
- *
- * @param strategy The migration strategy that should be used
- * @return this
- */
- public MigrateConfigBuilder strategy(MigrationStrategy strategy) {
- if (strategy != MigrationStrategy.NO_STRATEGY) {
- this.strategy = strategy.getValue();
- }
- return this;
- }
-
- /**
- * Set it to config backup policy for migration.
- *
- * @param backups The backup configuration that should be used
- * @return this
- */
- public MigrateConfigBuilder backups(BackupConfig backups) {
- this.backups = backups;
- return this;
- }
-
- public MigrateConfig build() {
- MigrateConfig migrateConfig = new MigrateConfig();
- migrateConfig.setStrategy(strategy);
- migrateConfig.setBackups(backups);
- return migrateConfig;
- }
-
- public enum MigrationStrategy {
- NO_STRATEGY(""),
- STRATEGY_RECREATE("recreate"),
- STRATEGY_ROLLING("rolling");
-
- private String value;
-
- MigrationStrategy(String value) {
- this.value = value;
- }
-
- public String getValue() {
- return value;
- }
- }
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/PodDisruptionBudgetConfig.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/PodDisruptionBudgetConfig.java
deleted file mode 100644
index 6ed860490..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/PodDisruptionBudgetConfig.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.keycloak.spec;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-/**
- * Specify PodDisruptionBudget configuration.
- */
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-public class PodDisruptionBudgetConfig {
-
- /**
- * If set to true, the operator will create a PodDistruptionBudget for the Keycloak deployment and set its
- * `maxUnavailable` value to 1.
- */
- private boolean enabled;
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/PodDisruptionBudgetConfigBuilder.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/PodDisruptionBudgetConfigBuilder.java
index b4531f112..534d04db9 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/PodDisruptionBudgetConfigBuilder.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/PodDisruptionBudgetConfigBuilder.java
@@ -15,6 +15,8 @@
*/
package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.keycloak.spec;
+import org.keycloak.v1alpha1.keycloakspec.PodDisruptionBudget;
+
/**
* Specify PodDisruptionBudget configuration.
*/
@@ -33,8 +35,8 @@ public PodDisruptionBudgetConfigBuilder enabled(boolean enabled) {
return this;
}
- public PodDisruptionBudgetConfig build() {
- PodDisruptionBudgetConfig podDisruptionBudgetConfig = new PodDisruptionBudgetConfig();
+ public PodDisruptionBudget build() {
+ PodDisruptionBudget podDisruptionBudgetConfig = new PodDisruptionBudget();
podDisruptionBudgetConfig.setEnabled(enabled);
return podDisruptionBudgetConfig;
}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/PostgresqlDeploymentSpec.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/PostgresqlDeploymentSpec.java
deleted file mode 100644
index 53cf54e74..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/PostgresqlDeploymentSpec.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.keycloak.spec;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import io.fabric8.kubernetes.api.model.ResourceRequirements;
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-/**
- * Resources (Requests and Limits) for PostgresDeployment.
- */
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-public class PostgresqlDeploymentSpec {
-
- /**
- * Resources (Requests and Limits) for the Pods.
- */
- private ResourceRequirements resources;
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/PostgresqlDeploymentSpecBuilder.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/PostgresqlDeploymentSpecBuilder.java
index 1af3d6d6d..e068a32c3 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/PostgresqlDeploymentSpecBuilder.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/PostgresqlDeploymentSpecBuilder.java
@@ -15,13 +15,14 @@
*/
package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.keycloak.spec;
-import io.fabric8.kubernetes.api.model.ResourceRequirements;
+import org.keycloak.v1alpha1.keycloakspec.PostgresDeploymentSpec;
+import org.keycloak.v1alpha1.keycloakspec.postgresdeploymentspec.Resources;
/**
* Resources (Requests and Limits) for PostgresDeployment.
*/
public final class PostgresqlDeploymentSpecBuilder {
- private ResourceRequirements resources;
+ private Resources resources;
/**
* Set the Resources (Requests and Limits) for the Pods.
@@ -29,13 +30,13 @@ public final class PostgresqlDeploymentSpecBuilder {
* @param resources The Resources (Requests and Limits) for the Pods
* @return this
*/
- public PostgresqlDeploymentSpecBuilder resources(ResourceRequirements resources) {
+ public PostgresqlDeploymentSpecBuilder resources(Resources resources) {
this.resources = resources;
return this;
}
- public PostgresqlDeploymentSpec build() {
- PostgresqlDeploymentSpec postgresqlDeploymentSpec = new PostgresqlDeploymentSpec();
+ public PostgresDeploymentSpec build() {
+ PostgresDeploymentSpec postgresqlDeploymentSpec = new PostgresDeploymentSpec();
postgresqlDeploymentSpec.setResources(resources);
return postgresqlDeploymentSpec;
}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/VolumeSpec.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/VolumeSpec.java
deleted file mode 100644
index dd342be91..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/VolumeSpec.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.keycloak.spec;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-public class VolumeSpec {
-
- /**
- * ConfigMap mount.
- */
- private ConfigMapVolumeSpec configMap;
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/VolumeSpecBuilder.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/VolumeSpecBuilder.java
index f785808db..7ec460288 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/VolumeSpecBuilder.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/VolumeSpecBuilder.java
@@ -15,8 +15,12 @@
*/
package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.keycloak.spec;
+import java.util.List;
+
+import org.keycloak.v1alpha1.keycloakspec.keycloakdeploymentspec.experimental.volumes.Items;
+
public final class VolumeSpecBuilder {
- private ConfigMapVolumeSpec configMap;
+ private List configMap;
/**
* Set the ConfigMap mount.
@@ -24,14 +28,14 @@ public final class VolumeSpecBuilder {
* @param configMap The ConfigMap mount configuration
* @return this
*/
- public VolumeSpecBuilder configMap(ConfigMapVolumeSpec configMap) {
+ public VolumeSpecBuilder configMap(List configMap) {
this.configMap = configMap;
return this;
}
- public VolumeSpec build() {
- VolumeSpec volumeSpec = new VolumeSpec();
- volumeSpec.setConfigMap(configMap);
+ public Items build() {
+ Items volumeSpec = new Items();
+ volumeSpec.setConfigMaps(configMap);
return volumeSpec;
}
}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/VolumesSpec.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/VolumesSpec.java
deleted file mode 100644
index 7dbdbe9c3..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/VolumesSpec.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.keycloak.spec;
-
-import java.util.List;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-public class VolumesSpec {
-
- private List items;
-
- private int defaultMode;
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/VolumesSpecBuilder.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/VolumesSpecBuilder.java
index e38e73d96..507b4e355 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/VolumesSpecBuilder.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/spec/VolumesSpecBuilder.java
@@ -18,16 +18,19 @@
import java.util.ArrayList;
import java.util.List;
+import org.keycloak.v1alpha1.keycloakspec.keycloakdeploymentspec.experimental.Volumes;
+import org.keycloak.v1alpha1.keycloakspec.keycloakdeploymentspec.experimental.volumes.Items;
+
public final class VolumesSpecBuilder {
- private List items;
+ private List items;
private int defaultMode;
- public VolumesSpecBuilder items(List items) {
+ public VolumesSpecBuilder items(List items) {
this.items = items;
return this;
}
- public VolumesSpecBuilder items(VolumeSpec item) {
+ public VolumesSpecBuilder items(Items item) {
if (items == null) {
items = new ArrayList<>();
}
@@ -40,8 +43,8 @@ public VolumesSpecBuilder defaultMode(int defaultMode) {
return this;
}
- public VolumesSpec build() {
- VolumesSpec volumesSpec = new VolumesSpec();
+ public Volumes build() {
+ Volumes volumesSpec = new Volumes();
volumesSpec.setItems(items);
volumesSpec.setDefaultMode(defaultMode);
return volumesSpec;
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/status/KeycloakStatus.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/status/KeycloakStatus.java
deleted file mode 100644
index a49b2a476..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/keycloak/status/KeycloakStatus.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.keycloak.status;
-
-import java.util.List;
-import java.util.Map;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-/**
- * KeycloakStatus defines the observed state of Keycloak.
- */
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-public class KeycloakStatus {
-
- /**
- * Current phase of the operator.
- */
- private String phase;
-
- /**
- * Human-readable message indicating details about current operator phase or error.
- */
- private String message;
-
- /**
- * True if all resources are in a ready state and all work is done.
- */
- private boolean ready;
-
- /**
- * A map of all the secondary resources types and names created for this CR.
- * e.g "Deployment": [ "DeploymentName1", "DeploymentName2" ].
- */
- private Map> secondaryResources;
-
- /**
- * Version of Keycloak or RHSSO running on the cluster.
- */
- private String version;
-
- /**
- * Service IP and Port for in-cluster access to the keycloak instance.
- */
- private String internalURL;
-
- /**
- * Service IP and Port for external access to the keycloak instance.
- */
- private String externalURL;
-
- /**
- * The secret where the admin credentials are to be found.
- */
- private String credentialSecret;
-
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/KeycloakRealm.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/KeycloakRealm.java
deleted file mode 100644
index af978c955..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/KeycloakRealm.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.realm;
-
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.realm.spec.KeycloakRealmSpec;
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.realm.status.KeycloakRealmStatus;
-import org.jboss.intersmash.tools.provision.openshift.operator.resources.OpenShiftResource;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import io.fabric8.kubernetes.api.model.ObjectMeta;
-import io.fabric8.kubernetes.client.CustomResource;
-import io.fabric8.kubernetes.model.annotation.Group;
-import io.fabric8.kubernetes.model.annotation.Version;
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-/**
- * https://github.com/keycloak/keycloak-operator/blob/master/pkg/apis/keycloak/v1alpha1/keycloakrealm_types.go
- * https://github.com/keycloak/keycloak-operator/blob/master/deploy/crds/keycloak.org_keycloakrealms_crd.yaml
- */
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-@Group("keycloak.org")
-@Version("v1alpha1")
-public class KeycloakRealm extends CustomResource implements OpenShiftResource {
- /**
- * Standard object’s metadata.
- */
- private ObjectMeta metadata;
-
- /**
- * KeycloakRealmSpec defines the desired state of KeycloakRealm.
- */
- private KeycloakRealmSpec spec;
-
- /**
- * KeycloakRealmStatus defines the observed state of KeycloakRealm.
- */
- private KeycloakRealmStatus status;
-
- @Override
- public KeycloakRealm load(KeycloakRealm loaded) {
- this.setMetadata(loaded.getMetadata());
- this.setSpec(loaded.getSpec());
- return this;
- }
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/KeycloakRealmBuilder.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/KeycloakRealmBuilder.java
index 2adf5c928..4fc043631 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/KeycloakRealmBuilder.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/KeycloakRealmBuilder.java
@@ -19,20 +19,21 @@
import java.util.List;
import java.util.Map;
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.realm.spec.KeycloakAPIRealm;
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.realm.spec.KeycloakRealmSpec;
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.realm.spec.RedirectorIdentityProviderOverride;
+import org.keycloak.v1alpha1.KeycloakRealm;
+import org.keycloak.v1alpha1.KeycloakRealmSpec;
+import org.keycloak.v1alpha1.keycloakrealmspec.InstanceSelector;
+import org.keycloak.v1alpha1.keycloakrealmspec.Realm;
+import org.keycloak.v1alpha1.keycloakrealmspec.RealmOverrides;
-import io.fabric8.kubernetes.api.model.LabelSelector;
import io.fabric8.kubernetes.api.model.ObjectMeta;
public final class KeycloakRealmBuilder {
private String name;
private Map labels;
// private boolean unmanaged;
- private LabelSelector instanceSelector;
- private KeycloakAPIRealm realm;
- private List realmOverrides;
+ private InstanceSelector instanceSelector;
+ private Realm realm;
+ private List realmOverrides;
/**
* Initialize the {@link KeycloakRealmBuilder} with given resource name.
@@ -66,10 +67,10 @@ public KeycloakRealmBuilder(String name, Map labels) {
/**
* Set a selector for looking up Keycloak Custom Resources.
*
- * @param instanceSelector {@link LabelSelector} instance that should be used for looking up Keycloak Custom Resources.
+ * @param instanceSelector {@link InstanceSelector} instance that should be used for looking up Keycloak Custom Resources.
* @return this
*/
- public KeycloakRealmBuilder instanceSelector(LabelSelector instanceSelector) {
+ public KeycloakRealmBuilder instanceSelector(InstanceSelector instanceSelector) {
this.instanceSelector = instanceSelector;
return this;
}
@@ -77,10 +78,10 @@ public KeycloakRealmBuilder instanceSelector(LabelSelector instanceSelector) {
/**
* Keycloak Realm REST object.
*
- * @param realm {@link KeycloakAPIRealm} instance that should be used as the realm REST client
+ * @param realm {@link Realm} instance that should be used as the realm REST client
* @return this
*/
- public KeycloakRealmBuilder realm(KeycloakAPIRealm realm) {
+ public KeycloakRealmBuilder realm(Realm realm) {
this.realm = realm;
return this;
}
@@ -88,11 +89,11 @@ public KeycloakRealmBuilder realm(KeycloakAPIRealm realm) {
/**
* A list of overrides to the default Realm behavior.
*
- * @param realmOverrides A list of {@link RedirectorIdentityProviderOverride} instances that should be used to
+ * @param realmOverrides A list of {@link RealmOverrides} instances that should be used to
* override the default realm behavior
* @return this
*/
- public KeycloakRealmBuilder realmOverrides(List realmOverrides) {
+ public KeycloakRealmBuilder realmOverrides(List realmOverrides) {
this.realmOverrides = realmOverrides;
return this;
}
@@ -100,11 +101,11 @@ public KeycloakRealmBuilder realmOverrides(List();
}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/KeycloakRealmList.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/KeycloakRealmList.java
index 3ff561f3e..a83df7a51 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/KeycloakRealmList.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/KeycloakRealmList.java
@@ -15,6 +15,8 @@
*/
package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.realm;
+import org.keycloak.v1alpha1.KeycloakRealm;
+
import io.fabric8.kubernetes.client.CustomResourceList;
public class KeycloakRealmList extends CustomResourceList {
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIAuthenticationExecution.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIAuthenticationExecution.java
deleted file mode 100644
index 83ebc2eec..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIAuthenticationExecution.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.realm.spec;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-public class KeycloakAPIAuthenticationExecution {
-
- /**
- * Authenticator.
- */
- private String authenticator;
-
- /**
- * Authenticator Config.
- */
- private String authenticatorConfig;
-
- /**
- * Authenticator flow.
- */
- private String authenticatorFlow;
-
- /**
- * Flow Alias.
- */
- private String flowAlias;
-
- /**
- * Priority.
- */
- private int priority;
-
- /**
- * Requirement [REQUIRED, OPTIONAL, ALTERNATIVE, DISABLED].
- */
- private String requirement;
-
- /**
- * User setup allowed.
- */
- private boolean userSetupAllowed;
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIAuthenticationExecutionBuilder.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIAuthenticationExecutionBuilder.java
index 9577fc381..1000b2fe7 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIAuthenticationExecutionBuilder.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIAuthenticationExecutionBuilder.java
@@ -15,10 +15,12 @@
*/
package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.realm.spec;
+import org.keycloak.v1alpha1.keycloakrealmspec.realm.authenticationflows.AuthenticationExecutions;
+
public final class KeycloakAPIAuthenticationExecutionBuilder {
private String authenticator;
private String authenticatorConfig;
- private String authenticatorFlow;
+ private boolean authenticatorFlow;
private String flowAlias;
private int priority;
private String requirement;
@@ -52,7 +54,7 @@ public KeycloakAPIAuthenticationExecutionBuilder authenticatorConfig(String auth
* @param authenticatorFlow String representing a valid authenticator flow
* @return this
*/
- public KeycloakAPIAuthenticationExecutionBuilder authenticatorFlow(String authenticatorFlow) {
+ public KeycloakAPIAuthenticationExecutionBuilder authenticatorFlow(boolean authenticatorFlow) {
this.authenticatorFlow = authenticatorFlow;
return this;
}
@@ -101,8 +103,8 @@ public KeycloakAPIAuthenticationExecutionBuilder userSetupAllowed(boolean userSe
return this;
}
- public KeycloakAPIAuthenticationExecution build() {
- KeycloakAPIAuthenticationExecution keycloakAPIAuthenticationExecution = new KeycloakAPIAuthenticationExecution();
+ public AuthenticationExecutions build() {
+ AuthenticationExecutions keycloakAPIAuthenticationExecution = new AuthenticationExecutions();
keycloakAPIAuthenticationExecution.setAuthenticator(authenticator);
keycloakAPIAuthenticationExecution.setAuthenticatorConfig(authenticatorConfig);
keycloakAPIAuthenticationExecution.setAuthenticatorFlow(authenticatorFlow);
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIAuthenticationFlow.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIAuthenticationFlow.java
deleted file mode 100644
index deaa25601..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIAuthenticationFlow.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.realm.spec;
-
-import java.util.List;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-public class KeycloakAPIAuthenticationFlow {
-
- /**
- * Alias.
- */
- private String alias;
-
- /**
- * Authentication executions.
- */
- private List authenticationExecutions;
-
- /**
- * Built in.
- */
- private boolean builtIn;
-
- /**
- * Description.
- */
- private String description;
-
- /**
- * ID.
- */
- private String id;
-
- /**
- * Provider ID.
- */
- private String providerId;
-
- /**
- * Top level.
- */
- private boolean topLevel;
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIAuthenticationFlowBuilder.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIAuthenticationFlowBuilder.java
index 1dbc67bcd..b4f766786 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIAuthenticationFlowBuilder.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIAuthenticationFlowBuilder.java
@@ -18,9 +18,12 @@
import java.util.ArrayList;
import java.util.List;
+import org.keycloak.v1alpha1.keycloakrealmspec.realm.AuthenticationFlows;
+import org.keycloak.v1alpha1.keycloakrealmspec.realm.authenticationflows.AuthenticationExecutions;
+
public final class KeycloakAPIAuthenticationFlowBuilder {
private String alias;
- private List authenticationExecutions;
+ private List authenticationExecutions;
private boolean builtIn;
private String description;
private String id;
@@ -45,7 +48,7 @@ public KeycloakAPIAuthenticationFlowBuilder alias(String alias) {
* @return this
*/
public KeycloakAPIAuthenticationFlowBuilder authenticationExecutions(
- List authenticationExecutions) {
+ List authenticationExecutions) {
this.authenticationExecutions = authenticationExecutions;
return this;
}
@@ -57,7 +60,7 @@ public KeycloakAPIAuthenticationFlowBuilder authenticationExecutions(
* @return this
*/
public KeycloakAPIAuthenticationFlowBuilder authenticationExecutions(
- KeycloakAPIAuthenticationExecution authenticationExecution) {
+ AuthenticationExecutions authenticationExecution) {
if (authenticationExecutions == null) {
authenticationExecutions = new ArrayList<>();
}
@@ -120,8 +123,8 @@ public KeycloakAPIAuthenticationFlowBuilder topLevel(boolean topLevel) {
return this;
}
- public KeycloakAPIAuthenticationFlow build() {
- KeycloakAPIAuthenticationFlow keycloakAPIAuthenticationFlow = new KeycloakAPIAuthenticationFlow();
+ public AuthenticationFlows build() {
+ AuthenticationFlows keycloakAPIAuthenticationFlow = new AuthenticationFlows();
keycloakAPIAuthenticationFlow.setAlias(alias);
keycloakAPIAuthenticationFlow.setAuthenticationExecutions(authenticationExecutions);
keycloakAPIAuthenticationFlow.setBuiltIn(builtIn);
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIAuthenticatorConfig.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIAuthenticatorConfig.java
deleted file mode 100644
index d6fb8ff43..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIAuthenticatorConfig.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.realm.spec;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-public class KeycloakAPIAuthenticatorConfig {
-
- /**
- * Alias.
- */
- private String alias;
-
- /**
- * Config.
- */
- private String config;
-
- /**
- * ID.
- */
- private String id;
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIAuthenticatorConfigBuilder.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIAuthenticatorConfigBuilder.java
index 96471f29e..63ad4f9c3 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIAuthenticatorConfigBuilder.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIAuthenticatorConfigBuilder.java
@@ -15,9 +15,13 @@
*/
package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.realm.spec;
+import java.util.Map;
+
+import org.keycloak.v1alpha1.keycloakrealmspec.realm.AuthenticatorConfig;
+
public final class KeycloakAPIAuthenticatorConfigBuilder {
private String alias;
- private String config;
+ private Map config;
private String id;
/**
@@ -37,7 +41,7 @@ public KeycloakAPIAuthenticatorConfigBuilder alias(String alias) {
* @param config The Config that should be used
* @return this
*/
- public KeycloakAPIAuthenticatorConfigBuilder config(String config) {
+ public KeycloakAPIAuthenticatorConfigBuilder config(Map config) {
this.config = config;
return this;
}
@@ -53,8 +57,8 @@ public KeycloakAPIAuthenticatorConfigBuilder id(String id) {
return this;
}
- public KeycloakAPIAuthenticatorConfig build() {
- KeycloakAPIAuthenticatorConfig keycloakAPIAuthenticatorConfig = new KeycloakAPIAuthenticatorConfig();
+ public AuthenticatorConfig build() {
+ AuthenticatorConfig keycloakAPIAuthenticatorConfig = new AuthenticatorConfig();
keycloakAPIAuthenticatorConfig.setAlias(alias);
keycloakAPIAuthenticatorConfig.setConfig(config);
keycloakAPIAuthenticatorConfig.setId(id);
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIRealm.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIRealm.java
deleted file mode 100644
index bb0fadc4b..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIRealm.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.realm.spec;
-
-import java.util.Set;
-
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.client.spec.KeycloakAPIClient;
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.user.spec.KeycloakAPIUser;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-public class KeycloakAPIRealm {
-
- private String id;
-
- /**
- * Realm name.
- */
- private String realm;
-
- /**
- * Realm enabled flag.
- */
- private boolean enabled;
-
- /**
- * Realm display name.
- */
- private String displayName;
-
- /**
- * A set of Keycloak Users.
- */
- private Set users;
-
- /**
- * A set of Keycloak Clients.
- */
- private Set clients;
-
- /**
- * A set of Identity Providers.
- */
- private Set identityProviders;
-
- /**
- * A set of Event Listeners.
- */
- private Set eventsListeners;
-
- /**
- * Enable events recording.
- */
- private boolean eventsEnabled;
-
- /**
- * Enable events recording.
- */
- private boolean adminEventsEnabled;
-
- /**
- * Enable admin events details.
- */
- private boolean adminEventsDetailsEnabled;
- //
- // /**
- // * Client scopes.
- // */
- // private List clientScopes;
- //
- // /**
- // * Authentication flows.
- // */
- // private List authenticationFlows;
- //
- // /**
- // * Authenticator config.
- // */
- // private List authenticatorConfig;
- //
- // /**
- // * Point keycloak to an external user provider to validate credentials or pull in identity information.
- // */
- // private List userFederationProviders;
- //
- // /**
- // * User federation mappers are extension points triggered by the user federation at various points.
- // */
- // private List userFederationMappers;
- //
- // /**
- // * User registration.
- // */
- // private boolean registrationAllowed;
- //
- // /**
- // * Email as username.
- // */
- // private boolean registrationEmailAsUsername;
- //
- // /**
- // * Edit username.
- // */
- // private boolean editUsernameAllowed;
- //
- // /**
- // * Forgot password.
- // */
- // private boolean resetPasswordAllowed;
- //
- // /**
- // * Remember me.
- // */
- // private boolean rememberMe;
- //
- // /**
- // * Verify email.
- // */
- // private boolean verifyEmail;
- //
- // /**
- // * Login with email.
- // */
- // private boolean loginWithEmailAllowed;
- //
- // /**
- // * Duplicate emails.
- // */
- // private boolean duplicateEmailsAllowed;
- //
- // /**
- // * Require SSL.
- // */
- // private String sslRequired;
- //
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIRealmBuilder.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIRealmBuilder.java
index e9b2584ee..aeec56a82 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIRealmBuilder.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIRealmBuilder.java
@@ -15,29 +15,32 @@
*/
package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.realm.spec;
-import java.util.HashSet;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Set;
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.client.spec.KeycloakAPIClient;
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.user.spec.KeycloakAPIUser;
+import org.keycloak.v1alpha1.keycloakrealmspec.Realm;
+import org.keycloak.v1alpha1.keycloakrealmspec.realm.Clients;
+import org.keycloak.v1alpha1.keycloakrealmspec.realm.IdentityProviders;
+import org.keycloak.v1alpha1.keycloakrealmspec.realm.Users;
public final class KeycloakAPIRealmBuilder {
private String id;
private String realm;
private boolean enabled;
private String displayName;
- private Set users;
- private Set clients;
- private Set identityProviders;
- private Set eventsListeners;
+ private List users;
+ private List clients;
+ private List identityProviders;
+ private List eventsListeners;
private boolean eventsEnabled;
private boolean adminEventsEnabled;
private boolean adminEventsDetailsEnabled;
// private List clientScopes;
// private List authenticationFlows;
// private List authenticatorConfig;
- // private List userFederationProviders;
- // private List userFederationMappers;
+ // private List userFederationProviders;
+ // private List userFederationMappers;
// private boolean registrationAllowed;
// private boolean registrationEmailAsUsername;
// private boolean editUsernameAllowed;
@@ -89,10 +92,10 @@ public KeycloakAPIRealmBuilder displayName(String displayName) {
/**
* Set Keycloak users
*
- * @param users A {@link Set} of {@link KeycloakAPIUser} instances
+ * @param users A {@link Set} of {@link Users} instances
* @return this
*/
- public KeycloakAPIRealmBuilder users(Set users) {
+ public KeycloakAPIRealmBuilder users(List users) {
this.users = users;
return this;
}
@@ -100,12 +103,12 @@ public KeycloakAPIRealmBuilder users(Set users) {
/**
* Add one Keycloak User
*
- * @param user The {@link KeycloakAPIUser} instance representing the user that should be added
+ * @param user The {@link Users} instance representing the user that should be added
* @return this
*/
- public KeycloakAPIRealmBuilder users(KeycloakAPIUser user) {
+ public KeycloakAPIRealmBuilder users(Users user) {
if (users == null) {
- users = new HashSet<>();
+ users = new ArrayList<>();
}
users.add(user);
return this;
@@ -114,10 +117,10 @@ public KeycloakAPIRealmBuilder users(KeycloakAPIUser user) {
/**
* Set Keycloak Clients.
*
- * @param clients A {@link Set} of {@link KeycloakAPIClient} instances
+ * @param clients A {@link Set} of {@link Clients} instances
* @return this
*/
- public KeycloakAPIRealmBuilder clients(Set clients) {
+ public KeycloakAPIRealmBuilder clients(List clients) {
this.clients = clients;
return this;
}
@@ -125,12 +128,12 @@ public KeycloakAPIRealmBuilder clients(Set clients) {
/**
* Add one Keycloak Client.
*
- * @param client The {@link KeycloakAPIClient} instance representing the client that should be added
+ * @param client The {@link Clients} instance representing the client that should be added
* @return this
*/
- public KeycloakAPIRealmBuilder clients(KeycloakAPIClient client) {
+ public KeycloakAPIRealmBuilder clients(Clients client) {
if (clients == null) {
- clients = new HashSet<>();
+ clients = new ArrayList<>();
}
clients.add(client);
return this;
@@ -139,10 +142,10 @@ public KeycloakAPIRealmBuilder clients(KeycloakAPIClient client) {
/**
* Set Identity Providers.
*
- * @param identityProviders A {@link Set} of {@link KeycloakIdentityProvider} instances
+ * @param identityProviders A {@link Set} of {@link IdentityProviders} instances
* @return this
*/
- public KeycloakAPIRealmBuilder identityProviders(Set identityProviders) {
+ public KeycloakAPIRealmBuilder identityProviders(List identityProviders) {
this.identityProviders = identityProviders;
return this;
}
@@ -150,13 +153,13 @@ public KeycloakAPIRealmBuilder identityProviders(Set i
/**
* Add one Identity Provider.
*
- * @param identityProvider The {@link KeycloakIdentityProvider} instance representing the identity provider that
+ * @param identityProvider The {@link IdentityProviders} instance representing the identity provider that
* should be added
* @return this
*/
- public KeycloakAPIRealmBuilder identityProviders(KeycloakIdentityProvider identityProvider) {
+ public KeycloakAPIRealmBuilder identityProviders(IdentityProviders identityProvider) {
if (identityProviders == null) {
- identityProviders = new HashSet<>();
+ identityProviders = new ArrayList<>();
}
identityProviders.add(identityProvider);
return this;
@@ -168,7 +171,7 @@ public KeycloakAPIRealmBuilder identityProviders(KeycloakIdentityProvider identi
* @param eventsListeners A {@link Set} of events listeners
* @return this
*/
- public KeycloakAPIRealmBuilder eventsListeners(Set eventsListeners) {
+ public KeycloakAPIRealmBuilder eventsListeners(List eventsListeners) {
this.eventsListeners = eventsListeners;
return this;
}
@@ -182,7 +185,7 @@ public KeycloakAPIRealmBuilder eventsListeners(Set eventsListeners) {
*/
public KeycloakAPIRealmBuilder eventsListeners(String eventsListener) {
if (eventsListeners == null) {
- eventsListeners = new HashSet<>();
+ eventsListeners = new ArrayList<>();
}
eventsListeners.add(eventsListener);
return this;
@@ -281,7 +284,7 @@ public KeycloakAPIRealmBuilder adminEventsDetailsEnabled(boolean adminEventsDeta
// /**
// * Point keycloak to an external user provider to validate credentials or pull in identity information.
// */
- // public KeycloakAPIRealmBuilder userFederationProviders(List userFederationProviders) {
+ // public KeycloakAPIRealmBuilder userFederationProviders(List userFederationProviders) {
// this.userFederationProviders = userFederationProviders;
// return this;
// }
@@ -289,7 +292,7 @@ public KeycloakAPIRealmBuilder adminEventsDetailsEnabled(boolean adminEventsDeta
// /**
// * Add external user provider to validate credentials or pull in identity information.
// */
- // public KeycloakAPIRealmBuilder userFederationProviders(KeycloakAPIUserFederationProvider userFederationProvider) {
+ // public KeycloakAPIRealmBuilder userFederationProviders(UsersFederationProvider userFederationProvider) {
// if (userFederationProviders == null) {
// userFederationProviders = new ArrayList<>();
// }
@@ -300,7 +303,7 @@ public KeycloakAPIRealmBuilder adminEventsDetailsEnabled(boolean adminEventsDeta
// /**
// * User federation mappers are extension points triggered by the user federation at various points.
// */
- // public KeycloakAPIRealmBuilder userFederationMappers(List userFederationMappers) {
+ // public KeycloakAPIRealmBuilder userFederationMappers(List userFederationMappers) {
// this.userFederationMappers = userFederationMappers;
// return this;
// }
@@ -309,7 +312,7 @@ public KeycloakAPIRealmBuilder adminEventsDetailsEnabled(boolean adminEventsDeta
// * Add user federation mapper. User federation mappers are extension points triggered by the user federation at
// * various points.
// */
- // public KeycloakAPIRealmBuilder userFederationMappers(KeycloakAPIUserFederationMapper userFederationMapper) {
+ // public KeycloakAPIRealmBuilder userFederationMappers(UsersFederationMapper userFederationMapper) {
// if (userFederationMappers == null) {
// userFederationMappers = new ArrayList<>();
// }
@@ -389,8 +392,8 @@ public KeycloakAPIRealmBuilder adminEventsDetailsEnabled(boolean adminEventsDeta
// return this;
// }
- public KeycloakAPIRealm build() {
- KeycloakAPIRealm keycloakAPIRealm = new KeycloakAPIRealm();
+ public Realm build() {
+ Realm keycloakAPIRealm = new Realm();
keycloakAPIRealm.setId(id);
keycloakAPIRealm.setRealm(realm);
keycloakAPIRealm.setEnabled(enabled);
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIUserFederationMapper.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIUserFederationMapper.java
deleted file mode 100644
index f56e42666..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIUserFederationMapper.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.realm.spec;
-
-import java.util.Map;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-public class KeycloakAPIUserFederationMapper {
-
- /**
- * User federation mapper config.
- */
- private Map config;
-
- private String name;
-
- private String id;
-
- private String federationMapperType;
-
- /**
- * The displayName for the user federation provider this mapper applies to.
- */
- private String federationProviderDisplayName;
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIUserFederationMapperBuilder.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIUserFederationMapperBuilder.java
index 16a1bb57a..2c6d932e5 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIUserFederationMapperBuilder.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIUserFederationMapperBuilder.java
@@ -18,6 +18,8 @@
import java.util.HashMap;
import java.util.Map;
+import org.keycloak.v1alpha1.keycloakrealmspec.realm.UserFederationMappers;
+
public final class KeycloakAPIUserFederationMapperBuilder {
private Map config;
private String name;
@@ -95,8 +97,8 @@ public KeycloakAPIUserFederationMapperBuilder federationProviderDisplayName(Stri
return this;
}
- public KeycloakAPIUserFederationMapper build() {
- KeycloakAPIUserFederationMapper keycloakAPIUserFederationMapper = new KeycloakAPIUserFederationMapper();
+ public UserFederationMappers build() {
+ UserFederationMappers keycloakAPIUserFederationMapper = new UserFederationMappers();
keycloakAPIUserFederationMapper.setConfig(config);
keycloakAPIUserFederationMapper.setName(name);
keycloakAPIUserFederationMapper.setId(id);
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIUserFederationProvider.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIUserFederationProvider.java
deleted file mode 100644
index ac9d4af46..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIUserFederationProvider.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.realm.spec;
-
-import java.util.Map;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-public class KeycloakAPIUserFederationProvider {
-
- /**
- * User federation provider config.
- */
- private Map config;
-
- /**
- * The display name of this provider instance.
- */
- private String displayName;
-
- private int fullSyncPeriod;
-
- /**
- * The ID of this provider.
- */
- private String id;
-
- /**
- * The priority of this provider when looking up users or adding a user.
- */
- private int priority;
-
- /**
- * The name of the user provider, such as "ldap", "kerberos" or a custom SPI.
- */
- private String providerName;
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIUserFederationProviderBuilder.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIUserFederationProviderBuilder.java
index 7e60d4b48..bbd6bac0c 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIUserFederationProviderBuilder.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakAPIUserFederationProviderBuilder.java
@@ -18,6 +18,8 @@
import java.util.HashMap;
import java.util.Map;
+import org.keycloak.v1alpha1.keycloakrealmspec.realm.UserFederationProviders;
+
public final class KeycloakAPIUserFederationProviderBuilder {
private Map config;
private String displayName;
@@ -101,8 +103,8 @@ public KeycloakAPIUserFederationProviderBuilder providerName(String providerName
return this;
}
- public KeycloakAPIUserFederationProvider build() {
- KeycloakAPIUserFederationProvider keycloakAPIUserFederationProvider = new KeycloakAPIUserFederationProvider();
+ public UserFederationProviders build() {
+ UserFederationProviders keycloakAPIUserFederationProvider = new UserFederationProviders();
keycloakAPIUserFederationProvider.setConfig(config);
keycloakAPIUserFederationProvider.setDisplayName(displayName);
keycloakAPIUserFederationProvider.setFullSyncPeriod(fullSyncPeriod);
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakClientScope.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakClientScope.java
deleted file mode 100644
index e7a4fa120..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakClientScope.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.realm.spec;
-
-import java.util.List;
-import java.util.Map;
-
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.client.spec.KeycloakProtocolMapper;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-public class KeycloakClientScope {
-
- private Map attributes;
-
- private String description;
-
- private String id;
-
- private String name;
-
- private String protocol;
-
- /**
- * Protocol Mappers.
- */
- private List protocolMappers;
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakClientScopeBuilder.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakClientScopeBuilder.java
index d0dceef96..451fb0a98 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakClientScopeBuilder.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakClientScopeBuilder.java
@@ -19,7 +19,8 @@
import java.util.List;
import java.util.Map;
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.client.spec.KeycloakProtocolMapper;
+import org.keycloak.v1alpha1.keycloakrealmspec.realm.ClientScopes;
+import org.keycloak.v1alpha1.keycloakrealmspec.realm.clientscopes.ProtocolMappers;
public final class KeycloakClientScopeBuilder {
private Map attributes;
@@ -27,7 +28,7 @@ public final class KeycloakClientScopeBuilder {
private String id;
private String name;
private String protocol;
- private List protocolMappers;
+ private List protocolMappers;
/**
* Add a list of attributes.
@@ -105,13 +106,13 @@ public KeycloakClientScopeBuilder protocol(String protocol) {
* @param protocolMappers A list of protocol mappers that should be used
* @return this
*/
- public KeycloakClientScopeBuilder protocolMappers(List protocolMappers) {
+ public KeycloakClientScopeBuilder protocolMappers(List protocolMappers) {
this.protocolMappers = protocolMappers;
return this;
}
- public KeycloakClientScope build() {
- KeycloakClientScope keycloakClientScope = new KeycloakClientScope();
+ public ClientScopes build() {
+ ClientScopes keycloakClientScope = new ClientScopes();
keycloakClientScope.setAttributes(attributes);
keycloakClientScope.setDescription(description);
keycloakClientScope.setId(id);
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakIdentityProvider.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakIdentityProvider.java
deleted file mode 100644
index af3085312..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakIdentityProvider.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.realm.spec;
-
-import java.util.Map;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-public class KeycloakIdentityProvider {
-
- /**
- * Identity Provider Alias.
- */
- private String alias;
-
- /**
- * Identity Provider Display Name.
- */
- private String displayName;
-
- /**
- * Identity Provider Internal ID.
- */
- private String internalId;
-
- /**
- * Identity Provider ID.
- */
- private String providerId;
-
- /**
- * Identity Provider enabled flag.
- */
- private boolean enabled;
-
- /**
- * Identity Provider Trust Email.
- */
- private boolean trustEmail;
-
- /**
- * Identity Provider Store to Token.
- */
- private boolean storeToken;
-
- /**
- * Adds Read Token role when creating this Identity Provider.
- */
- private boolean addReadTokenRoleOnCreate;
-
- /**
- * Identity Provider First Broker Login Flow Alias.
- */
- private String firstBrokerLoginFlowAlias;
-
- /**
- * Identity Provider Post Broker Login Flow Alias.
- */
- private String postBrokerLoginFlowAlias;
-
- /**
- * Identity Provider Link Only setting.
- */
- private boolean linkOnly;
-
- /**
- * Identity Provider config.
- */
- private Map omitempty;
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakIdentityProviderBuilder.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakIdentityProviderBuilder.java
index 8e56f934a..f9fc52edd 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakIdentityProviderBuilder.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakIdentityProviderBuilder.java
@@ -18,6 +18,8 @@
import java.util.HashMap;
import java.util.Map;
+import org.keycloak.v1alpha1.keycloakrealmspec.realm.IdentityProviders;
+
public final class KeycloakIdentityProviderBuilder {
private String alias;
private String displayName;
@@ -179,8 +181,8 @@ public KeycloakIdentityProviderBuilder omitempty(String key, String value) {
return this;
}
- public KeycloakIdentityProvider build() {
- KeycloakIdentityProvider keycloakIdentityProvider = new KeycloakIdentityProvider();
+ public IdentityProviders build() {
+ IdentityProviders keycloakIdentityProvider = new IdentityProviders();
keycloakIdentityProvider.setAlias(alias);
keycloakIdentityProvider.setDisplayName(displayName);
keycloakIdentityProvider.setInternalId(internalId);
@@ -192,7 +194,7 @@ public KeycloakIdentityProvider build() {
keycloakIdentityProvider.setFirstBrokerLoginFlowAlias(firstBrokerLoginFlowAlias);
keycloakIdentityProvider.setPostBrokerLoginFlowAlias(postBrokerLoginFlowAlias);
keycloakIdentityProvider.setLinkOnly(linkOnly);
- keycloakIdentityProvider.setOmitempty(omitempty);
+ ///keycloakIdentityProvider.setOmitempty(omitempty);
return keycloakIdentityProvider;
}
}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakRealmSpec.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakRealmSpec.java
deleted file mode 100644
index ea7c27e34..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/KeycloakRealmSpec.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.realm.spec;
-
-import java.util.List;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import io.fabric8.kubernetes.api.model.LabelSelector;
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-/**
- * KeycloakRealmSpec defines the desired state of KeycloakRealm.
- */
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-public class KeycloakRealmSpec {
-
- // /**
- // * When set to true, this KeycloakRealm will be marked as unmanaged and not be managed by this operator.
- // * It can then be used for targeting purposes.
- // */
- // private boolean unmanaged;
-
- /**
- * Selector for looking up Keycloak Custom Resources.
- */
- private LabelSelector instanceSelector;
-
- /**
- * Keycloak Realm REST object.
- */
- private KeycloakAPIRealm realm;
-
- /**
- * A list of overrides to the default Realm behavior.
- */
- private List realmOverrides;
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/RedirectorIdentityProviderOverride.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/RedirectorIdentityProviderOverride.java
deleted file mode 100644
index 99a305a88..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/RedirectorIdentityProviderOverride.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.realm.spec;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-public class RedirectorIdentityProviderOverride {
-
- /**
- * Identity Provider to be overridden.
- */
- private String identityProvider;
-
- /**
- * Flow to be overridden.
- */
- private String forFlow;
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/RedirectorIdentityProviderOverrideBuilder.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/RedirectorIdentityProviderOverrideBuilder.java
index 91d3716bf..655e3b866 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/RedirectorIdentityProviderOverrideBuilder.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/spec/RedirectorIdentityProviderOverrideBuilder.java
@@ -15,6 +15,8 @@
*/
package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.realm.spec;
+import org.keycloak.v1alpha1.keycloakrealmspec.RealmOverrides;
+
public final class RedirectorIdentityProviderOverrideBuilder {
private String identityProvider;
private String forFlow;
@@ -41,8 +43,8 @@ public RedirectorIdentityProviderOverrideBuilder forFlow(String forFlow) {
return this;
}
- public RedirectorIdentityProviderOverride build() {
- RedirectorIdentityProviderOverride redirectorIdentityProviderOverride = new RedirectorIdentityProviderOverride();
+ public RealmOverrides build() {
+ RealmOverrides redirectorIdentityProviderOverride = new RealmOverrides();
redirectorIdentityProviderOverride.setIdentityProvider(identityProvider);
redirectorIdentityProviderOverride.setForFlow(forFlow);
return redirectorIdentityProviderOverride;
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/status/KeycloakRealmStatus.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/status/KeycloakRealmStatus.java
deleted file mode 100644
index 59ad13fd7..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/realm/status/KeycloakRealmStatus.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.realm.status;
-
-import java.util.List;
-import java.util.Map;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-/**
- * KeycloakRealmStatus defines the observed state of KeycloakRealm.
- */
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-public class KeycloakRealmStatus {
- /**
- * Current phase of the operator.
- */
- private String phase;
-
- /**
- * Human-readable message indicating details about current operator phase or error.
- */
- private String message;
-
- /**
- * True if all resources are in a ready state and all work is done.
- */
- private boolean ready;
-
- /**
- * A map of all the secondary resources types and names created for this CR.
- * e.g "Deployment": [ "DeploymentName1", "DeploymentName2" ].
- */
- private Map> secondaryResources;
-
- private String loginURL;
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/user/KeycloakUser.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/user/KeycloakUser.java
deleted file mode 100644
index 2da07a9fe..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/user/KeycloakUser.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.user;
-
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.user.spec.KeycloakUserSpec;
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.user.status.KeycloakUserStatus;
-import org.jboss.intersmash.tools.provision.openshift.operator.resources.OpenShiftResource;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import io.fabric8.kubernetes.api.model.ObjectMeta;
-import io.fabric8.kubernetes.client.CustomResource;
-import io.fabric8.kubernetes.model.annotation.Group;
-import io.fabric8.kubernetes.model.annotation.Version;
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-/**
- * https://github.com/keycloak/keycloak-operator/blob/master/pkg/apis/keycloak/v1alpha1/keycloakuser_types.go
- * https://github.com/keycloak/keycloak-operator/blob/master/deploy/crds/keycloak.org_keycloakusers_crd.yaml
- */
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-@Group("keycloak.org")
-@Version("v1alpha1")
-public class KeycloakUser extends CustomResource implements OpenShiftResource {
- /**
- * Standard object’s metadata.
- */
- private ObjectMeta metadata;
-
- /**
- * KeycloakUserSpec defines the desired state of KeycloakUser.
- */
- private KeycloakUserSpec spec;
-
- /**
- * KeycloakUserStatus defines the observed state of KeycloakUser.
- */
- private KeycloakUserStatus status;
-
- @Override
- public KeycloakUser load(KeycloakUser loaded) {
- this.setMetadata(loaded.getMetadata());
- this.setSpec(loaded.getSpec());
- return this;
- }
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/user/KeycloakUserBuilder.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/user/KeycloakUserBuilder.java
index f65cabbeb..2b2bc199e 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/user/KeycloakUserBuilder.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/user/KeycloakUserBuilder.java
@@ -17,17 +17,18 @@
import java.util.Map;
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.user.spec.KeycloakAPIUser;
-import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.user.spec.KeycloakUserSpec;
+import org.keycloak.v1alpha1.KeycloakUser;
+import org.keycloak.v1alpha1.KeycloakUserSpec;
+import org.keycloak.v1alpha1.keycloakuserspec.RealmSelector;
+import org.keycloak.v1alpha1.keycloakuserspec.User;
-import io.fabric8.kubernetes.api.model.LabelSelector;
import io.fabric8.kubernetes.api.model.ObjectMeta;
public final class KeycloakUserBuilder {
private String name;
private Map labels;
- private LabelSelector realmSelector;
- private KeycloakAPIUser user;
+ private RealmSelector realmSelector;
+ private User user;
/**
* Initialize the {@link KeycloakUserBuilder} with given resource name.
@@ -55,7 +56,7 @@ public KeycloakUserBuilder(String name, Map labels) {
* @param realmSelector The selector for looking up KeycloakRealm Custom Resources
* @return this
*/
- public KeycloakUserBuilder realmSelector(LabelSelector realmSelector) {
+ public KeycloakUserBuilder realmSelector(RealmSelector realmSelector) {
this.realmSelector = realmSelector;
return this;
}
@@ -66,7 +67,7 @@ public KeycloakUserBuilder realmSelector(LabelSelector realmSelector) {
* @param user The Keycloak User REST object.
* @return this
*/
- public KeycloakUserBuilder user(KeycloakAPIUser user) {
+ public KeycloakUserBuilder user(User user) {
this.user = user;
return this;
}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/user/KeycloakUserList.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/user/KeycloakUserList.java
index 7a4b1fa2a..b723a1f4d 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/user/KeycloakUserList.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/user/KeycloakUserList.java
@@ -15,6 +15,8 @@
*/
package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.user;
+import org.keycloak.v1alpha1.KeycloakUser;
+
import io.fabric8.kubernetes.client.CustomResourceList;
public class KeycloakUserList extends CustomResourceList {
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/user/spec/FederatedIdentity.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/user/spec/FederatedIdentity.java
deleted file mode 100644
index fb2887d2a..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/user/spec/FederatedIdentity.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.user.spec;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-public class FederatedIdentity {
-
- /**
- * Federated Identity Provider.
- */
- private String identityProvider;
-
- /**
- * Federated Identity User ID.
- */
- private String userId;
-
- /**
- * Federated Identity User Name.
- */
- private String userName;
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/user/spec/FederatedIdentityBuilder.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/user/spec/FederatedIdentityBuilder.java
index 93ff69535..e6239ee2f 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/user/spec/FederatedIdentityBuilder.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/user/spec/FederatedIdentityBuilder.java
@@ -15,6 +15,8 @@
*/
package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.user.spec;
+import org.keycloak.v1alpha1.keycloakuserspec.user.FederatedIdentities;
+
public final class FederatedIdentityBuilder {
private String identityProvider;
private String userId;
@@ -53,8 +55,8 @@ public FederatedIdentityBuilder userName(String userName) {
return this;
}
- public FederatedIdentity build() {
- FederatedIdentity federatedIdentity = new FederatedIdentity();
+ public FederatedIdentities build() {
+ FederatedIdentities federatedIdentity = new FederatedIdentities();
federatedIdentity.setIdentityProvider(identityProvider);
federatedIdentity.setUserId(userId);
federatedIdentity.setUserName(userName);
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/user/spec/KeycloakAPIUser.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/user/spec/KeycloakAPIUser.java
deleted file mode 100644
index eb889b6ad..000000000
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/user/spec/KeycloakAPIUser.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/**
- * Copyright (C) 2023 Red Hat, Inc.
- *
- * 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.
- */
-package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.user.spec;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter
-@Setter
-@EqualsAndHashCode
-@ToString
-public class KeycloakAPIUser {
-
- /**
- * User ID.
- */
- private String id;
-
- /**
- * User Name.
- */
- private String username;
-
- /**
- * First Name.
- */
- private String firstName;
-
- /**
- * Last Name.
- */
- private String lastName;
-
- /**
- * Email.
- */
- private String email;
-
- /**
- * True if email has already been verified.
- */
- private boolean emailVerified;
-
- /**
- * User enabled flag.
- */
- private boolean enabled;
-
- /**
- * A set of Realm Roles.
- */
- private Set realmRoles;
-
- /**
- * A set of Client Roles.
- */
- private Map> clientRoles;
-
- /**
- * A set of Required Actions
- */
- private Set requiredActions;
-
- /**
- * A set of Groups.
- */
- private Set groups;
-
- /**
- * A set of Federated Identities.
- */
- private Set federatedIdentities;
-
- /**
- * A set of Credentials.
- */
- private Set credentials;
-
- // /**
- // * A set of Attributes.
- // */
- // private Map> attributes;
-}
diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/user/spec/KeycloakAPIUserBuilder.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/user/spec/KeycloakAPIUserBuilder.java
index 10aa32dc8..2ea7f43e8 100644
--- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/user/spec/KeycloakAPIUserBuilder.java
+++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/operator/keycloak/user/spec/KeycloakAPIUserBuilder.java
@@ -15,11 +15,14 @@
*/
package org.jboss.intersmash.tools.provision.openshift.operator.keycloak.user.spec;
+import java.util.ArrayList;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.Set;
+
+import org.keycloak.v1alpha1.keycloakrealmspec.realm.Users;
+import org.keycloak.v1alpha1.keycloakrealmspec.realm.users.Credentials;
+import org.keycloak.v1alpha1.keycloakrealmspec.realm.users.FederatedIdentities;
public final class KeycloakAPIUserBuilder {
private String id;
@@ -29,12 +32,12 @@ public final class KeycloakAPIUserBuilder {
private String email;
private boolean emailVerified;
private boolean enabled;
- private Set realmRoles;
+ private List realmRoles;
private Map> clientRoles;
- private Set requiredActions;
- private Set groups;
- private Set federatedIdentities;
- private Set credentials;
+ private List requiredActions;
+ private List groups;
+ private List federatedIdentities;
+ private List credentials;
// private Map> attributes;
/**
@@ -120,7 +123,7 @@ public KeycloakAPIUserBuilder enabled(boolean enabled) {
* @param realmRoles A set of Realm Roles that should be added the user
* @return this
*/
- public KeycloakAPIUserBuilder realmRoles(Set realmRoles) {
+ public KeycloakAPIUserBuilder realmRoles(List realmRoles) {
this.realmRoles = realmRoles;
return this;
}
@@ -133,7 +136,7 @@ public KeycloakAPIUserBuilder realmRoles(Set realmRoles) {
*/
public KeycloakAPIUserBuilder realmRoles(String realmRole) {
if (realmRoles == null) {
- realmRoles = new HashSet<>();
+ realmRoles = new ArrayList<>();
}
realmRoles.add(realmRole);
return this;
@@ -171,7 +174,7 @@ public KeycloakAPIUserBuilder clientRole(String clientRole, List additio
* @param requiredActions A set of Required Actions that should be added the user
* @return this
*/
- public KeycloakAPIUserBuilder requiredActions(Set