Skip to content

Commit

Permalink
Fix Intersmash#37: modifications after review
Browse files Browse the repository at this point in the history
  • Loading branch information
tommaso-borgato committed Jun 6, 2023
1 parent 8b80b74 commit bd5a779
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 30 deletions.
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,16 @@ 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 | KeycloakOpenShiftApplication | KeycloakTemplateOpenShiftProvisioner | |
| Keycloak | KeycloakOperatorApplication | KeycloakOperatorProvisioner | |
| 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 | KeycloakOpenShiftApplication | KeycloakTemplateOpenShiftProvisioner | |
| 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:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.keycloak.k8s.v2alpha1.Keycloak;
import org.keycloak.k8s.v2alpha1.KeycloakRealmImport;
Expand Down Expand Up @@ -71,7 +70,6 @@
*/
@Slf4j
@CleanBeforeAll
//@Disabled("WIP - Disabled until global-test.properties is configured with the required property")
public class KeycloakRealmImportOperatorProvisionerTest {
private static KeycloakRealmImportOperatorProvisioner KEYCLOAK_OPERATOR_PROVISIONER;

Expand Down Expand Up @@ -135,12 +133,6 @@ public static void createOperatorGroup() throws IOException {
OpenShifts.adminBinary().execute("apply", "-f", OperatorGroup.SINGLE_NAMESPACE.save().getAbsolutePath());
}

@BeforeEach
public void cleanup() throws IOException {
if (!Objects.isNull(KEYCLOAK_OPERATOR_PROVISIONER))
KEYCLOAK_OPERATOR_PROVISIONER.unsubscribe();
}

@AfterAll
public static void removeOperatorGroup() {
OpenShifts.adminBinary().execute("delete", "operatorgroup", "--all");
Expand Down Expand Up @@ -225,6 +217,7 @@ public void exampleSso() {
@Test
public void exampleSsoWithDatabase() {
try {
POSTGRESQL_IMAGE_PROVISIONER.configure();
POSTGRESQL_IMAGE_PROVISIONER.preDeploy();
POSTGRESQL_IMAGE_PROVISIONER.deploy();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ public class IntersmashConfig {
// KEYCLOAK
private static final String KEYCLOAK_IMAGE_URL = "intersmash.keycloak.image";
private static final String KEYCLOAK_REALM_IMPORT_IMAGE_URL = "intersmash.keycloak.realm_import.image";
private static final String KEYCLOAK_TEMPLATES = "intersmash.keycloak.templates";

// ACTIVEMQ
private static final String ACTIVEMQ_IMAGE_URL = "intersmash.activemq.image";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public Map<String, String> getImageVariables() {
return vars;
}

public void customizeApplicationBuilder(ApplicationBuilder appBuilder) {
public void customizeApplication(ApplicationBuilder appBuilder) {
}

public abstract String getSymbolicName();
Expand Down Expand Up @@ -99,7 +99,7 @@ public void deploy() {
.addContainerSelector("deploymentconfig", dbApplication.getName())
.addContainerSelector("name", dbApplication.getName());

customizeApplicationBuilder(appBuilder);
customizeApplication(appBuilder);

appBuilder.buildApplication(openShift).deploy();

Expand Down Expand Up @@ -137,7 +137,8 @@ public String getUrl(String routeName, boolean secure) {
}

/**
* When using {@link ApplicationBuilder} to build the application, then the service name defaults to the application nane
* Returns the service name used to expose the database functionality inside OpenShift;
* When using {@link ApplicationBuilder} to build the application (which is always the case here), then the service name defaults to the application nane
* @return service name to access the database
*/
public String getServiceName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,13 @@ public void subscribe() {
if (Strings.isNullOrEmpty(IntersmashConfig.keycloakRealmImportImageURL())) {
super.subscribe();
} else {
// RELATED_IMAGE_RHSSO_OPENJ9 and RELATED_IMAGE_RHSSO_OPENJDK, determine the final value for RELATED_IMAGE_RHSSO
subscribe(
INSTALLPLAN_APPROVAL_MANUAL,
// TODO: check if these env variables still make sense in the new quarkus operator
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()
// "PROFILE", "RHSSO"
));
"OPERATOR_KEYCLOAK_IMAGE", IntersmashConfig.keycloakRealmImportImageURL()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public Map<String, String> getImageVariables() {
}

@Override
public void customizeApplicationBuilder(ApplicationBuilder appBuilder) {
public void customizeApplication(ApplicationBuilder appBuilder) {
// the secret is supposed to be used by applications connecting to the database
appBuilder.secret(getSecretName())
.setType(SecretType.OPAQUE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ public static class CertificateAndKey {

/**
* Generates a key and self-signed certificate for that key; it also generates a truststore containing the certificate;
* @return
* @param hostname: to be used as Common Name (CN) for the certificate
* @param tlsSecretName: name of the secret to be created in OpenShift containing key and certificate
* @return wrapper object {@link CertificateAndKey} containing details about the newly created key, certificate and secret
*/
public static CertificateAndKey generateSelfSignedCertificateAndKey(String hostname, String tlsSecretName) {
CertificateAndKey certificateAndKey = new CertificateAndKey();
Expand Down Expand Up @@ -113,11 +115,11 @@ private static void processCall(Path cwd, String... args) {
}
}
} catch (IOException | InterruptedException e) {
throw new IllegalStateException("Failed executing " + String.join(" ", args));
throw new RuntimeException("Failed executing " + String.join(" ", args));
}

if (result != 0) {
throw new IllegalStateException("Failed executing " + String.join(" ", args));
throw new RuntimeException("Failed executing " + String.join(" ", args));
}
}

Expand Down

0 comments on commit bd5a779

Please sign in to comment.