Skip to content

Commit

Permalink
[issue 100] - Renaming KeycloakRealmImport* classes to Keycloak
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiobrz committed Oct 26, 2023
1 parent 3ffc204 commit c1dbbe4
Show file tree
Hide file tree
Showing 12 changed files with 94 additions and 101 deletions.
30 changes: 15 additions & 15 deletions README.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions global-test.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -316,9 +316,9 @@ private void verifyKeycloak(Keycloak keycloak, boolean waitForPods) {
}

private void verifyKeycloak(Keycloak keycloak, KeycloakRealmImport realmImport, boolean waitForPods) {
NonNamespaceOperation<Keycloak, KeycloakRealmImportOperatorKeycloakList, Resource<Keycloak>> keycloakClient = KEYCLOAK_OPERATOR_PROVISIONER
NonNamespaceOperation<Keycloak, KeycloakOperatorKeycloakList, Resource<Keycloak>> keycloakClient = KEYCLOAK_OPERATOR_PROVISIONER
.keycloakClient();
NonNamespaceOperation<KeycloakRealmImport, KeycloakRealmImportOperatorRealmImportList, Resource<KeycloakRealmImport>> keycloakRealmImportClient = KEYCLOAK_OPERATOR_PROVISIONER
NonNamespaceOperation<KeycloakRealmImport, KeycloakOperatorRealmImportList, Resource<KeycloakRealmImport>> keycloakRealmImportClient = KEYCLOAK_OPERATOR_PROVISIONER
.keycloakRealmImportClient();
// create and verify that object exists
keycloakClient.createOrReplace(keycloak);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
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;
import org.jboss.intersmash.tools.provision.openshift.ActiveMQOperatorProvisioner;
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;
Expand Down Expand Up @@ -63,7 +63,7 @@ public class OperatorSubscriptionTestCase {

private static final Stream<OperatorProvisioner> COMMUNITY_ONLY_PROVISIONERS = Stream.of(
new HyperfoilOperatorProvisioner(mock(HyperfoilOperatorApplication.class)),
new KeycloakRealmImportOperatorProvisioner(mock(KeycloakRealmImportOperatorApplication.class)));
new KeycloakOperatorProvisioner(mock(KeycloakOperatorApplication.class)));

private static final Stream<OperatorProvisioner> PRODUCT_ONLY_PROVISIONERS = Stream.of(
new RhSsoOperatorProvisioner(mock(RhSsoOperatorApplication.class)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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() {
Expand All @@ -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() {
Expand Down Expand Up @@ -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);
}
}
17 changes: 6 additions & 11 deletions tools/intersmash-tools-provisioners/docs/operator-howto.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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<KeycloakRealmImportOperatorApplication> {
public class KeycloakOperatorProvisioner extends OperatorProvisioner<KeycloakOperatorApplication> {
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, KeycloakRealmImportOperatorKeycloakList, Resource<Keycloak>> KEYCLOAK_CUSTOM_RESOURCE_CLIENT;
private static NonNamespaceOperation<KeycloakRealmImport, KeycloakRealmImportOperatorRealmImportList, Resource<KeycloakRealmImport>> KEYCLOAK_REALM_IMPORT_CUSTOM_RESOURCE_CLIENT;
private static NonNamespaceOperation<Keycloak, KeycloakOperatorKeycloakList, Resource<Keycloak>> KEYCLOAK_CUSTOM_RESOURCE_CLIENT;
private static NonNamespaceOperation<KeycloakRealmImport, KeycloakOperatorRealmImportList, Resource<KeycloakRealmImport>> KEYCLOAK_REALM_IMPORT_CUSTOM_RESOURCE_CLIENT;

public NonNamespaceOperation<Keycloak, KeycloakRealmImportOperatorKeycloakList, Resource<Keycloak>> keycloakClient() {
public NonNamespaceOperation<Keycloak, KeycloakOperatorKeycloakList, Resource<Keycloak>> keycloakClient() {
if (KEYCLOAK_CUSTOM_RESOURCE_CLIENT == null) {
CustomResourceDefinition crd = OpenShifts.admin().apiextensions().v1().customResourceDefinitions()
.withName(KEYCLOAK_RESOURCE).get();
Expand All @@ -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<Keycloak, KeycloakRealmImportOperatorKeycloakList, Resource<Keycloak>> crClient = OpenShifts
MixedOperation<Keycloak, KeycloakOperatorKeycloakList, Resource<Keycloak>> crClient = OpenShifts
.master().newHasMetadataOperation(crdc, Keycloak.class, KeycloakRealmImportOperatorKeycloakList.class);
KEYCLOAK_CUSTOM_RESOURCE_CLIENT = crClient.inNamespace(OpenShiftConfig.namespace());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -27,10 +27,10 @@
*
* The application will be deployed by:
* <ul>
* <li>{@link KeycloakRealmImportOperatorProvisioner}</li>
* <li>{@link KeycloakOperatorProvisioner}</li>
* </ul>
*/
public interface KeycloakRealmImportOperatorApplication extends OperatorApplication {
public interface KeycloakOperatorApplication extends OperatorApplication {

Keycloak getKeycloak();

Expand Down
Loading

0 comments on commit c1dbbe4

Please sign in to comment.