From c1dbbe4f6aba4185cbc4267ff84ae82cb2c2e41a Mon Sep 17 00:00:00 2001 From: Fabio Burzigotti Date: Thu, 19 Oct 2023 15:56:48 +0200 Subject: [PATCH] [issue 100] - Renaming KeycloakRealmImport* classes to Keycloak --- README.md | 30 ++++++------ global-test.properties | 6 +-- ...a => KeycloakOperatorProvisionerTest.java} | 22 ++++----- .../OperatorSubscriptionTestCase.java | 6 +-- .../intersmash/tools/IntersmashConfig.java | 46 +++++++++---------- .../docs/operator-howto.md | 17 +++---- ....java => KeycloakOperatorApplication.java} | 6 +-- ....java => KeycloakOperatorProvisioner.java} | 42 ++++++++--------- ...> KeycloakOperatorProvisionerFactory.java} | 12 ++--- .../openshift/RhSsoOperatorProvisioner.java | 4 +- ...java => KeycloakOperatorKeycloakList.java} | 2 +- ...a => KeycloakOperatorRealmImportList.java} | 2 +- 12 files changed, 94 insertions(+), 101 deletions(-) rename testsuite/src/test/java/org/jboss/intersmash/testsuite/provision/openshift/{KeycloakRealmImportOperatorProvisionerTest.java => KeycloakOperatorProvisionerTest.java} (93%) rename tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/application/openshift/{KeycloakRealmImportOperatorApplication.java => KeycloakOperatorApplication.java} (82%) rename tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/{KeycloakRealmImportOperatorProvisioner.java => KeycloakOperatorProvisioner.java} (89%) rename tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/{KeycloakRealmImportOperatorProvisionerFactory.java => KeycloakOperatorProvisionerFactory.java} (67%) rename tools/intersmash-tools-provisioners/src/main/java/org/keycloak/k8s/v2alpha1/{KeycloakRealmImportOperatorKeycloakList.java => KeycloakOperatorKeycloakList.java} (85%) rename tools/intersmash-tools-provisioners/src/main/java/org/keycloak/k8s/v2alpha1/{KeycloakRealmImportOperatorRealmImportList.java => KeycloakOperatorRealmImportList.java} (93%) diff --git a/README.md b/README.md index 22d8c204a..5efd882c8 100644 --- a/README.md +++ b/README.md @@ -245,21 +245,21 @@ public class PostgresqlProvisionTest { Mapping of implemented provisioners: -| 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: | KeycloakRealmImportOperatorApplication | KeycloakRealmImportOperatorProvisioner | 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) | +| 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 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/testsuite/src/test/java/org/jboss/intersmash/testsuite/provision/openshift/KeycloakRealmImportOperatorProvisionerTest.java b/testsuite/src/test/java/org/jboss/intersmash/testsuite/provision/openshift/KeycloakOperatorProvisionerTest.java similarity index 93% rename from testsuite/src/test/java/org/jboss/intersmash/testsuite/provision/openshift/KeycloakRealmImportOperatorProvisionerTest.java rename to testsuite/src/test/java/org/jboss/intersmash/testsuite/provision/openshift/KeycloakOperatorProvisionerTest.java index 61d5b8e1c..53596568d 100644 --- a/testsuite/src/test/java/org/jboss/intersmash/testsuite/provision/openshift/KeycloakRealmImportOperatorProvisionerTest.java +++ b/testsuite/src/test/java/org/jboss/intersmash/testsuite/provision/openshift/KeycloakOperatorProvisionerTest.java @@ -23,10 +23,10 @@ import java.util.Objects; import org.jboss.intersmash.testsuite.junit5.categories.NotForProductizedExecutionProfile; -import org.jboss.intersmash.tools.application.openshift.KeycloakRealmImportOperatorApplication; +import org.jboss.intersmash.tools.application.openshift.KeycloakOperatorApplication; import org.jboss.intersmash.tools.application.openshift.PostgreSQLImageOpenShiftApplication; import org.jboss.intersmash.tools.junit5.IntersmashExtension; -import org.jboss.intersmash.tools.provision.openshift.KeycloakRealmImportOperatorProvisioner; +import org.jboss.intersmash.tools.provision.openshift.KeycloakOperatorProvisioner; import org.jboss.intersmash.tools.provision.openshift.PostgreSQLImageOpenShiftProvisioner; import org.jboss.intersmash.tools.provision.openshift.operator.resources.OperatorGroup; import org.jboss.intersmash.tools.util.tls.CertificatesUtils; @@ -36,9 +36,9 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; 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.KeycloakRealmImportOperatorKeycloakList; -import org.keycloak.k8s.v2alpha1.KeycloakRealmImportOperatorRealmImportList; import org.keycloak.k8s.v2alpha1.KeycloakRealmImportSpec; import org.keycloak.k8s.v2alpha1.KeycloakSpec; import org.keycloak.k8s.v2alpha1.keycloakrealmimportspec.Realm; @@ -73,8 +73,8 @@ @Slf4j @CleanBeforeAll @NotForProductizedExecutionProfile -public class KeycloakRealmImportOperatorProvisionerTest { - private static KeycloakRealmImportOperatorProvisioner KEYCLOAK_OPERATOR_PROVISIONER; +public class KeycloakOperatorProvisionerTest { + private static KeycloakOperatorProvisioner KEYCLOAK_OPERATOR_PROVISIONER; private static final String POSTGRESQL_NAME = "postgresql"; private static final String POSTGRESQL_DATABASE = "keycloak"; @@ -105,10 +105,10 @@ public String getDbName() { private static final PostgreSQLImageOpenShiftProvisioner POSTGRESQL_IMAGE_PROVISIONER = new PostgreSQLImageOpenShiftProvisioner( pgSQLApplication); - private static KeycloakRealmImportOperatorProvisioner initializeOperatorProvisioner(final Keycloak keycloak, + private static KeycloakOperatorProvisioner initializeOperatorProvisioner(final Keycloak keycloak, final String appName) { - KeycloakRealmImportOperatorProvisioner operatorProvisioner = new KeycloakRealmImportOperatorProvisioner( - new KeycloakRealmImportOperatorApplication() { + KeycloakOperatorProvisioner operatorProvisioner = new KeycloakOperatorProvisioner( + new KeycloakOperatorApplication() { @Override public Keycloak getKeycloak() { @@ -316,9 +316,9 @@ private void verifyKeycloak(Keycloak keycloak, boolean waitForPods) { } private void verifyKeycloak(Keycloak keycloak, KeycloakRealmImport realmImport, boolean waitForPods) { - NonNamespaceOperation> keycloakClient = KEYCLOAK_OPERATOR_PROVISIONER + NonNamespaceOperation> keycloakClient = KEYCLOAK_OPERATOR_PROVISIONER .keycloakClient(); - NonNamespaceOperation> keycloakRealmImportClient = KEYCLOAK_OPERATOR_PROVISIONER + NonNamespaceOperation> keycloakRealmImportClient = KEYCLOAK_OPERATOR_PROVISIONER .keycloakRealmImportClient(); // create and verify that object exists keycloakClient.createOrReplace(keycloak); diff --git a/testsuite/src/test/java/org/jboss/intersmash/testsuite/provision/openshift/operator/OperatorSubscriptionTestCase.java b/testsuite/src/test/java/org/jboss/intersmash/testsuite/provision/openshift/operator/OperatorSubscriptionTestCase.java index e26b1d237..f7efb4d9b 100644 --- a/testsuite/src/test/java/org/jboss/intersmash/testsuite/provision/openshift/operator/OperatorSubscriptionTestCase.java +++ b/testsuite/src/test/java/org/jboss/intersmash/testsuite/provision/openshift/operator/OperatorSubscriptionTestCase.java @@ -25,7 +25,7 @@ import org.jboss.intersmash.tools.application.openshift.HyperfoilOperatorApplication; import org.jboss.intersmash.tools.application.openshift.InfinispanOperatorApplication; import org.jboss.intersmash.tools.application.openshift.KafkaOperatorApplication; -import org.jboss.intersmash.tools.application.openshift.KeycloakRealmImportOperatorApplication; +import org.jboss.intersmash.tools.application.openshift.KeycloakOperatorApplication; import org.jboss.intersmash.tools.application.openshift.RhSsoOperatorApplication; import org.jboss.intersmash.tools.application.openshift.WildflyOperatorApplication; import org.jboss.intersmash.tools.junit5.IntersmashExtension; @@ -33,7 +33,7 @@ import org.jboss.intersmash.tools.provision.openshift.HyperfoilOperatorProvisioner; import org.jboss.intersmash.tools.provision.openshift.InfinispanOperatorProvisioner; import org.jboss.intersmash.tools.provision.openshift.KafkaOperatorProvisioner; -import org.jboss.intersmash.tools.provision.openshift.KeycloakRealmImportOperatorProvisioner; +import org.jboss.intersmash.tools.provision.openshift.KeycloakOperatorProvisioner; import org.jboss.intersmash.tools.provision.openshift.RhSsoOperatorProvisioner; import org.jboss.intersmash.tools.provision.openshift.WildflyOperatorProvisioner; import org.jboss.intersmash.tools.provision.openshift.operator.OperatorProvisioner; @@ -63,7 +63,7 @@ public class OperatorSubscriptionTestCase { private static final Stream COMMUNITY_ONLY_PROVISIONERS = Stream.of( new HyperfoilOperatorProvisioner(mock(HyperfoilOperatorApplication.class)), - new KeycloakRealmImportOperatorProvisioner(mock(KeycloakRealmImportOperatorApplication.class))); + new KeycloakOperatorProvisioner(mock(KeycloakOperatorApplication.class))); private static final Stream PRODUCT_ONLY_PROVISIONERS = Stream.of( new RhSsoOperatorProvisioner(mock(RhSsoOperatorApplication.class))); diff --git a/tools/intersmash-tools-core/src/main/java/org/jboss/intersmash/tools/IntersmashConfig.java b/tools/intersmash-tools-core/src/main/java/org/jboss/intersmash/tools/IntersmashConfig.java index aec7da869..284d1aa22 100644 --- a/tools/intersmash-tools-core/src/main/java/org/jboss/intersmash/tools/IntersmashConfig.java +++ b/tools/intersmash-tools-core/src/main/java/org/jboss/intersmash/tools/IntersmashConfig.java @@ -43,18 +43,17 @@ public class IntersmashConfig { private static final String PRODUCT_INFINISPAN_OPERATOR_PACKAGE_MANIFEST = "datagrid"; private static final String DEFAULT_INFINISPAN_OPERATOR_PACKAGE_MANIFEST = COMMUNITY_INFINISPAN_OPERATOR_PACKAGE_MANIFEST; private static final String RHSSO_OPERATOR_CATALOG_SOURCE_NAME = "intersmash.rhsso.operators.catalog_source"; - private static final String KEYCLOAK_REALM_IMPORT_OPERATOR_CATALOG_SOURCE_NAME = "intersmash.keycloak.realm_import.operators.catalog_source"; + private static final String KEYCLOAK_OPERATOR_CATALOG_SOURCE_NAME = "intersmash.keycloak.operators.catalog_source"; private static final String RHSSO_OPERATOR_INDEX_IMAGE = "intersmash.rhsso.operators.index_image"; - private static final String KEYCLOAK_REALM_IMPORT_OPERATOR_INDEX_IMAGE = "intersmash.keycloak.realm_import.operators.index_image"; + private static final String KEYCLOAK_OPERATOR_INDEX_IMAGE = "intersmash.keycloak.operators.index_image"; private static final String RHSSO_OPERATOR_CHANNEL = "intersmash.rhsso.operators.channel"; - private static final String KEYCLOAK_REALM_IMPORT_OPERATOR_CHANNEL = "intersmash.keycloak.realm_import.operators.channel"; + private static final String KEYCLOAK_OPERATOR_CHANNEL = "intersmash.keycloak.operators.channel"; private static final String RHSSO_OPERATOR_PACKAGE_MANIFEST = "intersmash.rhsso.operators.package_manifest"; - private static final String KEYCLOAK_REALM_IMPORT_OPERATOR_PACKAGE_MANIFEST = "intersmash.keycloak.realm_import.operators.package_manifest"; + private static final String KEYCLOAK_OPERATOR_PACKAGE_MANIFEST = "intersmash.keycloak.operators.package_manifest"; private static final String COMMUNITY_KEYCLOAK_OPERATOR_PACKAGE_MANIFEST = "keycloak-operator"; private static final String PRODUCT_KEYCLOAK_OPERATOR_PACKAGE_MANIFEST = "rhsso-operator"; private static final String DEFAULT_KEYCLOAK_OPERATOR_PACKAGE_MANIFEST = COMMUNITY_KEYCLOAK_OPERATOR_PACKAGE_MANIFEST; - private static final String DEFAULT_KEYCLOAK_REALM_IMPORT_OPERATOR_PACKAGE_MANIFEST = COMMUNITY_KEYCLOAK_OPERATOR_PACKAGE_MANIFEST; private static final String WILDFLY_OPERATOR_CATALOG_SOURCE_NAME = "intersmash.wildfly.operators.catalog_source"; private static final String WILDFLY_OPERATOR_INDEX_IMAGE = "intersmash.wildfly.operators.index_image"; private static final String WILDFLY_OPERATOR_CHANNEL = "intersmash.wildfly.operators.channel"; @@ -110,9 +109,9 @@ public class IntersmashConfig { // INFINISPAN private static final String INFINISPAN_IMAGE_URL = "intersmash.infinispan.image"; - // KEYCLOAK + // KEYCLOAK/RHSSO + private static final String RHSSO_IMAGE_URL = "intersmash.rhsso.image"; private static final String KEYCLOAK_IMAGE_URL = "intersmash.keycloak.image"; - private static final String KEYCLOAK_REALM_IMPORT_IMAGE_URL = "intersmash.keycloak.realm_import.image"; // ACTIVEMQ private static final String ACTIVEMQ_IMAGE_URL = "intersmash.activemq.image"; @@ -292,16 +291,16 @@ public static String infinispanProductCode() { return getProductCode(infinispanImageURL()); } - public static String keycloakImageURL() { - return XTFConfig.get(KEYCLOAK_IMAGE_URL); + public static String rhSsoImageURL() { + return XTFConfig.get(RHSSO_IMAGE_URL); } - public static String keycloakRealmImportImageURL() { - return XTFConfig.get(KEYCLOAK_REALM_IMPORT_IMAGE_URL); + public static String keycloakImageURL() { + return XTFConfig.get(KEYCLOAK_IMAGE_URL); } - public static String keycloakProductCode() { - return getProductCode(keycloakImageURL()); + public static String rhSsoProductCode() { + return getProductCode(rhSsoImageURL()); } public static String activeMQImageUrl() { @@ -316,8 +315,8 @@ public static String getPostgreSQLImage() { return XTFConfig.get(PGSQL_IMAGE_URL); } - public static String keycloakImageName() { - return getImageName(keycloakImageURL()); + public static String rhSsoImageName() { + return getImageName(rhSsoImageURL()); } public static String scriptDebug() { @@ -414,20 +413,19 @@ public static String getWildflyHelmChartsBranch() { return XTFConfig.get(WILDFLY_HELM_CHARTS_BRANCH); } - public static String keycloakRealmImportOperatorCatalogSource() { - return XTFConfig.get(KEYCLOAK_REALM_IMPORT_OPERATOR_CATALOG_SOURCE_NAME, DEFAULT_OPERATOR_CATALOG_SOURCE_NAME); + public static String keycloakOperatorCatalogSource() { + return XTFConfig.get(KEYCLOAK_OPERATOR_CATALOG_SOURCE_NAME, DEFAULT_OPERATOR_CATALOG_SOURCE_NAME); } - public static String keycloakRealmImportOperatorIndexImage() { - return XTFConfig.get(KEYCLOAK_REALM_IMPORT_OPERATOR_INDEX_IMAGE); + public static String keycloakOperatorIndexImage() { + return XTFConfig.get(KEYCLOAK_OPERATOR_INDEX_IMAGE); } - public static String keycloakRealmImportOperatorChannel() { - return XTFConfig.get(KEYCLOAK_REALM_IMPORT_OPERATOR_CHANNEL); + public static String keycloakOperatorChannel() { + return XTFConfig.get(KEYCLOAK_OPERATOR_CHANNEL); } - public static String keycloakRealmImportOperatorPackageManifest() { - return XTFConfig.get(KEYCLOAK_REALM_IMPORT_OPERATOR_PACKAGE_MANIFEST, - DEFAULT_KEYCLOAK_REALM_IMPORT_OPERATOR_PACKAGE_MANIFEST); + public static String keycloakOperatorPackageManifest() { + return XTFConfig.get(KEYCLOAK_OPERATOR_PACKAGE_MANIFEST, DEFAULT_KEYCLOAK_OPERATOR_PACKAGE_MANIFEST); } } diff --git a/tools/intersmash-tools-provisioners/docs/operator-howto.md b/tools/intersmash-tools-provisioners/docs/operator-howto.md index af45b2e3c..afed50169 100644 --- a/tools/intersmash-tools-provisioners/docs/operator-howto.md +++ b/tools/intersmash-tools-provisioners/docs/operator-howto.md @@ -53,11 +53,6 @@ community project operator sources and CRDs could be a year away from the one su * use `throw new UnsupportedOperationException("TODO");` to implement the mandatory methods inherited from Provisioner interfaces for now * add a new test to OperatorSubscriptionTestCase -#### Example Outcome -* `openshift.application.org.jboss.intersmash.tools.KeycloakRealmImportOperatorApplication` -* `openshift.provision.org.jboss.intersmash.tools.KeycloakRealmImportOperatorProvisioner` - * operator id = `keycloak-operator` - ### Create builders It's useful to have two kinds of builders for `*Spec` model classes. The one for the ${CR_KIND}Spec class, which will act as an entry point for users to build the ${CR_KIND} objects, and the rest for the remaining model classes in `spec` package. Prefer using some plugin (e.g. https://plugins.jetbrains.com/plugin/6585-builder-generator) rather than creating builders manually. @@ -172,15 +167,15 @@ https://github.com/fabric8io/kubernetes-client/blob/master/kubernetes-examples/s Update the ${PRODUCT}OperatorProvisioner. Create CR na name constant and NonNamespaceOperation for every custom resource provided by an operator (look into existing operator Provisioners for more details). Create method to initialize the client and to obtain a reference to custom resource instance running on OPC (this one will have to be parametrized in case there could be more than one resource of same kind managed by a single operator - e.g. ActiveMQ operator can have multiple addresses). #### Example Output -`KeycloakRealmImportOperatorProvisioner` client methods example. The methods and resources names are aligned with CR name and kind. +`KeycloakOperatorProvisioner` client methods example. The methods and resources names are aligned with CR name and kind. ```java - public class KeycloakRealmImportOperatorProvisioner extends OperatorProvisioner { + public class KeycloakOperatorProvisioner 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; + private static NonNamespaceOperation> KEYCLOAK_CUSTOM_RESOURCE_CLIENT; + private static NonNamespaceOperation> KEYCLOAK_REALM_IMPORT_CUSTOM_RESOURCE_CLIENT; - public NonNamespaceOperation> keycloakClient() { + public NonNamespaceOperation> keycloakClient() { if (KEYCLOAK_CUSTOM_RESOURCE_CLIENT == null) { CustomResourceDefinition crd = OpenShifts.admin().apiextensions().v1().customResourceDefinitions() .withName(KEYCLOAK_RESOURCE).get(); @@ -189,7 +184,7 @@ Update the ${PRODUCT}OperatorProvisioner. Create CR na name constant and NonName throw new RuntimeException(String.format("[%s] custom resource is not provided by [%s] operator.", KEYCLOAK_RESOURCE, OPERATOR_ID)); } - MixedOperation> crClient = OpenShifts + MixedOperation> crClient = OpenShifts .master().newHasMetadataOperation(crdc, Keycloak.class, KeycloakRealmImportOperatorKeycloakList.class); KEYCLOAK_CUSTOM_RESOURCE_CLIENT = crClient.inNamespace(OpenShiftConfig.namespace()); } 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/KeycloakOperatorApplication.java similarity index 82% 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/KeycloakOperatorApplication.java index 2af2c7efd..a5c1b9a23 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/KeycloakOperatorApplication.java @@ -18,7 +18,7 @@ import java.util.Collections; import java.util.List; -import org.jboss.intersmash.tools.provision.openshift.KeycloakRealmImportOperatorProvisioner; +import org.jboss.intersmash.tools.provision.openshift.KeycloakOperatorProvisioner; import org.keycloak.k8s.v2alpha1.Keycloak; import org.keycloak.k8s.v2alpha1.KeycloakRealmImport; @@ -27,10 +27,10 @@ * * The application will be deployed by: *
    - *
  • {@link KeycloakRealmImportOperatorProvisioner}
  • + *
  • {@link KeycloakOperatorProvisioner}
  • *
*/ -public interface KeycloakRealmImportOperatorApplication extends OperatorApplication { +public interface KeycloakOperatorApplication extends OperatorApplication { Keycloak getKeycloak(); 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/KeycloakOperatorProvisioner.java similarity index 89% rename from tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/KeycloakRealmImportOperatorProvisioner.java rename to tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/KeycloakOperatorProvisioner.java index 6af11f3fe..f7e1fb8ab 100644 --- 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/KeycloakOperatorProvisioner.java @@ -26,13 +26,13 @@ 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.application.openshift.KeycloakOperatorApplication; 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.KeycloakOperatorKeycloakList; +import org.keycloak.k8s.v2alpha1.KeycloakOperatorRealmImportList; 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; @@ -55,13 +55,13 @@ /** * Keycloak operator provisioner */ -public class KeycloakRealmImportOperatorProvisioner extends OperatorProvisioner { +public class KeycloakOperatorProvisioner 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; + private static NonNamespaceOperation> KEYCLOAK_CUSTOM_RESOURCE_CLIENT; + private static NonNamespaceOperation> KEYCLOAK_REALM_IMPORT_CUSTOM_RESOURCE_CLIENT; - public NonNamespaceOperation> keycloakClient() { + public NonNamespaceOperation> keycloakClient() { if (KEYCLOAK_CUSTOM_RESOURCE_CLIENT == null) { CustomResourceDefinition crd = OpenShifts.admin().apiextensions().v1().customResourceDefinitions() .withName(KEYCLOAK_RESOURCE).get(); @@ -70,14 +70,14 @@ public NonNamespaceOperation> crClient = OpenShifts - .master().newHasMetadataOperation(crdc, Keycloak.class, KeycloakRealmImportOperatorKeycloakList.class); + MixedOperation> crClient = OpenShifts + .master().newHasMetadataOperation(crdc, Keycloak.class, KeycloakOperatorKeycloakList.class); KEYCLOAK_CUSTOM_RESOURCE_CLIENT = crClient.inNamespace(OpenShiftConfig.namespace()); } return KEYCLOAK_CUSTOM_RESOURCE_CLIENT; } - public NonNamespaceOperation> keycloakRealmImportClient() { + public NonNamespaceOperation> keycloakRealmImportClient() { if (KEYCLOAK_REALM_IMPORT_CUSTOM_RESOURCE_CLIENT == null) { CustomResourceDefinition crd = OpenShifts.admin().apiextensions().v1().customResourceDefinitions() .withName(KEYCLOAK_REALM_IMPORT_RESOURCE).get(); @@ -86,18 +86,18 @@ public NonNamespaceOperation> crClient = OpenShifts + MixedOperation> crClient = OpenShifts .master() - .newHasMetadataOperation(crdc, KeycloakRealmImport.class, KeycloakRealmImportOperatorRealmImportList.class); + .newHasMetadataOperation(crdc, KeycloakRealmImport.class, KeycloakOperatorRealmImportList.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(); + private static final String OPERATOR_ID = IntersmashConfig.keycloakOperatorPackageManifest(); protected FailFastCheck ffCheck = () -> false; - public KeycloakRealmImportOperatorProvisioner(@NonNull KeycloakRealmImportOperatorApplication application) { + public KeycloakOperatorProvisioner(@NonNull KeycloakOperatorApplication application) { super(application, OPERATOR_ID); } @@ -107,22 +107,22 @@ public static String getOperatorId() { @Override protected String getOperatorCatalogSource() { - return IntersmashConfig.keycloakRealmImportOperatorCatalogSource(); + return IntersmashConfig.keycloakOperatorCatalogSource(); } @Override protected String getOperatorIndexImage() { - return IntersmashConfig.keycloakRealmImportOperatorIndexImage(); + return IntersmashConfig.keycloakOperatorIndexImage(); } @Override protected String getOperatorChannel() { - return IntersmashConfig.keycloakRealmImportOperatorChannel(); + return IntersmashConfig.keycloakOperatorChannel(); } @Override public void subscribe() { - if (Strings.isNullOrEmpty(IntersmashConfig.keycloakRealmImportImageURL())) { + if (Strings.isNullOrEmpty(IntersmashConfig.keycloakImageURL())) { super.subscribe(); } else { subscribe( @@ -131,7 +131,7 @@ public void subscribe() { // 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())); + "OPERATOR_KEYCLOAK_IMAGE", IntersmashConfig.keycloakImageURL())); } } @@ -145,8 +145,8 @@ public void deploy() { // 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()); + if (!Strings.isNullOrEmpty(IntersmashConfig.keycloakImageURL())) { + getApplication().getKeycloak().getSpec().setImage(IntersmashConfig.keycloakImageURL()); } // create keys/certificates and add them to the Keycloak resource: 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/KeycloakOperatorProvisionerFactory.java similarity index 67% 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/KeycloakOperatorProvisionerFactory.java index 21906bc2c..74942e5f9 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/KeycloakOperatorProvisionerFactory.java @@ -16,19 +16,19 @@ 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.KeycloakOperatorApplication; import org.jboss.intersmash.tools.provision.ProvisionerFactory; import lombok.extern.slf4j.Slf4j; @Slf4j -public class KeycloakRealmImportOperatorProvisionerFactory - implements ProvisionerFactory { +public class KeycloakOperatorProvisionerFactory + implements ProvisionerFactory { @Override - public KeycloakRealmImportOperatorProvisioner getProvisioner(Application application) { - if (KeycloakRealmImportOperatorApplication.class.isAssignableFrom(application.getClass())) - return new KeycloakRealmImportOperatorProvisioner((KeycloakRealmImportOperatorApplication) application); + public KeycloakOperatorProvisioner getProvisioner(Application application) { + if (KeycloakOperatorApplication.class.isAssignableFrom(application.getClass())) + return new KeycloakOperatorProvisioner((KeycloakOperatorApplication) application); return null; } } 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 index de238f4d6..a8ab7b82c 100644 --- 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 @@ -103,14 +103,14 @@ protected String getOperatorChannel() { @Override public void subscribe() { - if (Strings.isNullOrEmpty(IntersmashConfig.keycloakImageURL())) { + 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.keycloakImageURL(), + "RELATED_IMAGE_RHSSO", IntersmashConfig.rhSsoImageURL(), "PROFILE", "RHSSO")); } } diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/keycloak/k8s/v2alpha1/KeycloakRealmImportOperatorKeycloakList.java b/tools/intersmash-tools-provisioners/src/main/java/org/keycloak/k8s/v2alpha1/KeycloakOperatorKeycloakList.java similarity index 85% rename from tools/intersmash-tools-provisioners/src/main/java/org/keycloak/k8s/v2alpha1/KeycloakRealmImportOperatorKeycloakList.java rename to tools/intersmash-tools-provisioners/src/main/java/org/keycloak/k8s/v2alpha1/KeycloakOperatorKeycloakList.java index 2e0e46583..d89cc2179 100644 --- a/tools/intersmash-tools-provisioners/src/main/java/org/keycloak/k8s/v2alpha1/KeycloakRealmImportOperatorKeycloakList.java +++ b/tools/intersmash-tools-provisioners/src/main/java/org/keycloak/k8s/v2alpha1/KeycloakOperatorKeycloakList.java @@ -17,5 +17,5 @@ import io.fabric8.kubernetes.client.CustomResourceList; -public class KeycloakRealmImportOperatorKeycloakList extends CustomResourceList { +public class KeycloakOperatorKeycloakList extends CustomResourceList { } diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/keycloak/k8s/v2alpha1/KeycloakRealmImportOperatorRealmImportList.java b/tools/intersmash-tools-provisioners/src/main/java/org/keycloak/k8s/v2alpha1/KeycloakOperatorRealmImportList.java similarity index 93% rename from tools/intersmash-tools-provisioners/src/main/java/org/keycloak/k8s/v2alpha1/KeycloakRealmImportOperatorRealmImportList.java rename to tools/intersmash-tools-provisioners/src/main/java/org/keycloak/k8s/v2alpha1/KeycloakOperatorRealmImportList.java index 94dfb9343..582c1638f 100644 --- a/tools/intersmash-tools-provisioners/src/main/java/org/keycloak/k8s/v2alpha1/KeycloakRealmImportOperatorRealmImportList.java +++ b/tools/intersmash-tools-provisioners/src/main/java/org/keycloak/k8s/v2alpha1/KeycloakOperatorRealmImportList.java @@ -17,6 +17,6 @@ import io.fabric8.kubernetes.client.CustomResourceList; -public class KeycloakRealmImportOperatorRealmImportList +public class KeycloakOperatorRealmImportList extends CustomResourceList { }