diff --git a/README.md b/README.md index 6d3722fa8..3530986fd 100644 --- a/README.md +++ b/README.md @@ -245,22 +245,23 @@ 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: | 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 JBoss EAP 7 | :x: | :heavy_check_mark: | Eap7TemplateOpenShiftApplication | Eap7TemplateOpenShiftProvisioner | Available Git sources and template based EAP 7 s2i (legacy) build | -| 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 JBoss EAP 7 | :x: | :heavy_check_mark: | Eap7TemplateOpenShiftApplication | Eap7TemplateOpenShiftProvisioner | Available Git sources and template based EAP 7 s2i (legacy) build | +| Red Hat JBoss EAP 7 | :x: | :heavy_check_mark: | Eap7LegacyS2iBuildTemplateApplication | Eap7LegacyS2iBuildTemplateProvisioner | Git based EAP 7 s2i (legacy) build, used to generate image streams that can be deployed by WildflyOperatorProvisioner | +| 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/testsuite/src/test/java/org/jboss/intersmash/testsuite/provision/openshift/OpenShiftProvisionerTestBase.java b/testsuite/src/test/java/org/jboss/intersmash/testsuite/provision/openshift/OpenShiftProvisionerTestBase.java index b0d7c8a00..f4d1e26c1 100644 --- a/testsuite/src/test/java/org/jboss/intersmash/testsuite/provision/openshift/OpenShiftProvisionerTestBase.java +++ b/testsuite/src/test/java/org/jboss/intersmash/testsuite/provision/openshift/OpenShiftProvisionerTestBase.java @@ -33,6 +33,7 @@ import org.jboss.intersmash.tools.IntersmashConfig; import org.jboss.intersmash.tools.application.openshift.BootableJarOpenShiftApplication; import org.jboss.intersmash.tools.application.openshift.Eap7ImageOpenShiftApplication; +import org.jboss.intersmash.tools.application.openshift.Eap7LegacyS2iBuildTemplateApplication; import org.jboss.intersmash.tools.application.openshift.Eap7TemplateOpenShiftApplication; import org.jboss.intersmash.tools.application.openshift.KafkaOperatorApplication; import org.jboss.intersmash.tools.application.openshift.MysqlImageOpenShiftApplication; @@ -42,10 +43,12 @@ import org.jboss.intersmash.tools.application.openshift.input.BuildInput; import org.jboss.intersmash.tools.application.openshift.input.BuildInputBuilder; import org.jboss.intersmash.tools.application.openshift.template.Eap7Template; +import org.jboss.intersmash.tools.util.openshift.WildflyOpenShiftUtils; import org.jboss.intersmash.tools.util.wildfly.Eap7CliScriptBuilder; import cz.xtf.builder.builders.SecretBuilder; import cz.xtf.builder.builders.secret.SecretType; +import cz.xtf.core.config.OpenShiftConfig; import io.fabric8.kubernetes.api.model.EnvVar; import io.fabric8.kubernetes.api.model.EnvVarBuilder; import io.fabric8.kubernetes.api.model.Secret; @@ -118,6 +121,51 @@ public String getName() { }; } + public static Eap7LegacyS2iBuildTemplateApplication getEap7LegacyS2iBuildTemplateApplication() { + return new Eap7LegacyS2iBuildTemplateApplication() { + private String eapImage; + private String eapRuntimeImage; + private final Map parameters; + private final List envVars; + + { + eapImage = WildflyOpenShiftUtils.importBuilderImage(IntersmashConfig.eap7ImageURL()).getMetadata().getName(); + eapRuntimeImage = WildflyOpenShiftUtils.importRuntimeImage(IntersmashConfig.eap7RuntimeImageUrl()).getMetadata() + .getName(); + String deployment = "deployments/intersmash-deployments-shared/intersmash-deployments-shared-eap7/eap7-helloworld"; + //params + parameters = new HashMap<>(); + parameters.put("APPLICATION_IMAGE", getName()); + parameters.put("EAP_IMAGE", eapImage); + parameters.put("EAP_RUNTIME_IMAGE", eapRuntimeImage); + parameters.put("EAP_IMAGESTREAM_NAMESPACE", OpenShiftConfig.namespace()); + parameters.put("SOURCE_REPOSITORY_URL", IntersmashConfig.deploymentsRepositoryUrl()); + parameters.put("SOURCE_REPOSITORY_REF", IntersmashConfig.deploymentsRepositoryRef()); + parameters.put("ARTIFACT_DIR", deployment + "/target"); + + // envvars + envVars = new ArrayList<>(); + // Set to allow cloning from Gitlab - any value here do the job + envVars.add(new EnvVarBuilder().withName("GIT_SSL_NO_VERIFY").withValue("").build()); + } + + @Override + public List getEnvVars() { + return envVars; + } + + @Override + public Map getParameters() { + return parameters; + } + + @Override + public String getName() { + return "eap-s2i-build-application"; + } + }; + } + static BootableJarOpenShiftApplication getWildflyBootableJarOpenShiftApplication() { return new BootableJarOpenShiftApplication() { @Override diff --git a/testsuite/src/test/java/org/jboss/intersmash/testsuite/provision/openshift/ProvisionerCleanupTestCase.java b/testsuite/src/test/java/org/jboss/intersmash/testsuite/provision/openshift/ProvisionerCleanupTestCase.java index b5f998faf..996c8401e 100644 --- a/testsuite/src/test/java/org/jboss/intersmash/testsuite/provision/openshift/ProvisionerCleanupTestCase.java +++ b/testsuite/src/test/java/org/jboss/intersmash/testsuite/provision/openshift/ProvisionerCleanupTestCase.java @@ -18,12 +18,14 @@ import java.util.stream.Stream; import org.jboss.intersmash.testsuite.IntersmashTestsuiteProperties; +import org.jboss.intersmash.tools.provision.openshift.Eap7LegacyS2iBuildTemplateProvisioner; import org.jboss.intersmash.tools.provision.openshift.MysqlImageOpenShiftProvisioner; import org.jboss.intersmash.tools.provision.openshift.OpenShiftProvisioner; import org.jboss.intersmash.tools.provision.openshift.PostgreSQLImageOpenShiftProvisioner; import org.jboss.intersmash.tools.provision.openshift.WildflyBootableJarImageOpenShiftProvisioner; import org.jboss.intersmash.tools.provision.openshift.WildflyImageOpenShiftProvisioner; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; @@ -80,4 +82,30 @@ public void testProvisioningWorkflowCleanup(OpenShiftProvisioner provisioner) { openShift.configMaps().withName("no-delete").delete(); openShift.waiters().isProjectClean().waitFor(); } + + /** + * EapS2iBuild application requires additional image streams to be created. CleanBeforeEach would delete it if the + * provisioner is initialized in {@link #provisionerProvider()}, so we need a separate test method. + */ + @Test + public void eapS2iBuild() { + Eap7LegacyS2iBuildTemplateProvisioner provisioner = new Eap7LegacyS2iBuildTemplateProvisioner( + OpenShiftProvisionerTestBase.getEap7LegacyS2iBuildTemplateApplication()); + provisioner.preDeploy(); + provisioner.deploy(); + openShift.configMaps().create(new ConfigMapBuilder().withNewMetadata().withName("no-delete").endMetadata().build()); + provisioner.undeploy(); + provisioner.postUndeploy(); + Assertions.assertNotNull(openShift.configMaps().withName("no-delete").get()); + openShift.configMaps().withName("no-delete").delete(); + // delete the images streams created by EapS2iBuildTemplateApplication + openShift.imageStreams() + .withName(((String) provisioner.getApplication().getParameters().get("EAP_IMAGE")).split(":")[0]) + .delete(); + openShift.imageStreams() + .withName(((String) provisioner.getApplication().getParameters().get("EAP_RUNTIME_IMAGE")).split(":")[0]) + .delete(); + + openShift.waiters().isProjectClean().waitFor(); + } } diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/application/openshift/WildflyLegacyS2iBuildTemplateApplication.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/application/openshift/Eap7LegacyS2iBuildTemplateApplication.java similarity index 80% rename from tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/application/openshift/WildflyLegacyS2iBuildTemplateApplication.java rename to tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/application/openshift/Eap7LegacyS2iBuildTemplateApplication.java index 1accef0a2..660cba5bb 100644 --- a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/application/openshift/WildflyLegacyS2iBuildTemplateApplication.java +++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/application/openshift/Eap7LegacyS2iBuildTemplateApplication.java @@ -18,6 +18,7 @@ import java.util.Collections; import java.util.List; +import org.jboss.intersmash.tools.provision.openshift.Eap7LegacyS2iBuildTemplateProvisioner; import org.jboss.intersmash.tools.provision.openshift.template.OpenShiftTemplate; import io.fabric8.kubernetes.api.model.EnvVar; @@ -26,15 +27,18 @@ * End user Application interface which presents resources on OpenShift Container Platform created by deploying the * eap-s2i-build build template. * - * The template is supposed to be used in conjunction with the WILDFLY Operator - the later can be used to deploy the + * The template is supposed to be used in conjunction with the WILDFLY Operator - the latter can be used to deploy the * application image (can be referenced by an actual image link to local image registry, or by an image stream produced * by the eap-s2i-build build). * - * See https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.3/html-single/getting_started_with_jboss_eap_for_openshift_container_platform/index#the-eap-s2i-build-template-for-creating-application-images_default - * + * See https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.4/html-single/getting_started_with_jboss_eap_for_openshift_container_platform/index#the-eap-s2i-build-template-for-creating-application-images_default * + * The application will be deployed by: + *
    + *
  • {@link Eap7LegacyS2iBuildTemplateProvisioner}
  • + *
*/ -public interface WildflyLegacyS2iBuildTemplateApplication extends TemplateApplication, HasEnvVars { +public interface Eap7LegacyS2iBuildTemplateApplication extends TemplateApplication, HasEnvVars { /** * Defaults to https://raw.githubusercontent.com/jboss-container-images/jboss-eap-openshift-templates/master/eap-s2i-build.yaml template diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/Eap7LegacyS2iBuildTemplateProvisioner.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/Eap7LegacyS2iBuildTemplateProvisioner.java new file mode 100644 index 000000000..247055498 --- /dev/null +++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/Eap7LegacyS2iBuildTemplateProvisioner.java @@ -0,0 +1,118 @@ +package org.jboss.intersmash.tools.provision.openshift; + +import java.io.IOException; +import java.net.URL; +import java.util.List; + +import org.jboss.intersmash.tools.application.openshift.Eap7LegacyS2iBuildTemplateApplication; +import org.slf4j.event.Level; + +import cz.xtf.core.event.helpers.EventHelper; +import cz.xtf.core.openshift.OpenShiftWaiters; +import cz.xtf.core.waiting.failfast.FailFastCheck; +import io.fabric8.kubernetes.api.model.KubernetesList; +import io.fabric8.kubernetes.api.model.Pod; +import io.fabric8.openshift.api.model.BuildConfig; +import io.fabric8.openshift.api.model.Template; +import lombok.extern.slf4j.Slf4j; + +/** + * Provisioner used process and deploy eap-s2i-build template to OpenShift Container Platform cluster. + * + * @see Eap7LegacyS2iBuildTemplateApplication + */ +@Slf4j +public class Eap7LegacyS2iBuildTemplateProvisioner implements OpenShiftProvisioner { + // we can parametrize this one once required, but its location should be static + private String EAP_S2I_BUILD = "https://raw.githubusercontent.com/jboss-container-images/jboss-eap-openshift-templates/master/eap-s2i-build.yaml"; + private KubernetesList deployedResources; + private Eap7LegacyS2iBuildTemplateApplication application; + private FailFastCheck ffCheck = () -> false; + private Template template; + + public Eap7LegacyS2iBuildTemplateProvisioner(Eap7LegacyS2iBuildTemplateApplication application) { + this.application = application; + } + + @Override + public Eap7LegacyS2iBuildTemplateApplication getApplication() { + return application; + } + + @Override + public void deploy() { + ffCheck = FailFastUtils.getFailFastCheck(EventHelper.timeOfLastEventBMOrTestNamespaceOrEpoch(), + application.getName()); + + if (application.getParameters().getOrDefault("APPLICATION_IMAGE", "null") != application.getName()) { + throw new IllegalArgumentException("APPLICATION_IMAGE template parameters has to match the application name!"); + } + try { + template = openShift.templates().load(new URL(EAP_S2I_BUILD)).get(); + } catch (IOException e) { + throw new RuntimeException("Failed to load eap-s2i-build template from " + EAP_S2I_BUILD, e); + } + template.setApiVersion("template.openshift.io/v1"); + openShift.createTemplate(template); + deployedResources = openShift.processTemplate(template.getMetadata().getName(), + application.getParameters()); + // add additional environment variables to the build config resources + deployedResources.getItems().stream() + .filter(hasMetadata -> hasMetadata.getKind().equals(BuildConfig.class.getSimpleName())) + .forEach(hasMetadata -> setEnvToBuildConfig((BuildConfig) hasMetadata)); + openShift.createResources(deployedResources); + + // two build configs has to be built (builder/runtime) in order to proceed + waitForBuilds(); + } + + private void setEnvToBuildConfig(BuildConfig buildConfig) { + // Update Git based build config + if (buildConfig.getSpec().getStrategy().getSourceStrategy() != null) { + if (buildConfig.getSpec().getStrategy().getSourceStrategy().getEnv() == null) { + buildConfig.getSpec().getStrategy().getSourceStrategy().setEnv(application.getEnvVars()); + } else { + buildConfig.getSpec().getStrategy().getSourceStrategy().getEnv().addAll(application.getEnvVars()); + } + } + // Update dockerile based build config + if (buildConfig.getSpec().getStrategy().getDockerStrategy() != null) { + if (buildConfig.getSpec().getStrategy().getDockerStrategy().getEnv() == null) { + buildConfig.getSpec().getStrategy().getDockerStrategy().setEnv(application.getEnvVars()); + } else { + buildConfig.getSpec().getStrategy().getDockerStrategy().getEnv().addAll(application.getEnvVars()); + } + } + } + + private void waitForBuilds() { + OpenShiftWaiters.get(openShift, ffCheck).hasBuildCompleted(application.getName() + "-build-artifacts") + .level(Level.DEBUG) + .waitFor(); + OpenShiftWaiters.get(openShift, ffCheck).hasBuildCompleted(application.getName()) + .level(Level.DEBUG) + .waitFor(); + } + + @Override + public void undeploy() { + openShift.deleteResources(deployedResources); + openShift.deleteTemplate(template); + } + + @Override + public URL getURL() { + throw new UnsupportedOperationException("No route for eap-s2i-build template instance."); + } + + @Override + public List getPods() { + throw new UnsupportedOperationException( + "eap-s2i-build does not provide any running pods - all pods are completed once builds are done."); + } + + @Override + public void scale(int replicas, boolean wait) { + throw new UnsupportedOperationException("eap-s2i-build template is not suppose to be scaled - no running pods."); + } +} diff --git a/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/Eap7LegacyS2iBuildTemplateProvisionerFactory.java b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/Eap7LegacyS2iBuildTemplateProvisionerFactory.java new file mode 100644 index 000000000..ad2e51fa9 --- /dev/null +++ b/tools/intersmash-tools-provisioners/src/main/java/org/jboss/intersmash/tools/provision/openshift/Eap7LegacyS2iBuildTemplateProvisionerFactory.java @@ -0,0 +1,18 @@ +package org.jboss.intersmash.tools.provision.openshift; + +import org.jboss.intersmash.tools.application.Application; +import org.jboss.intersmash.tools.application.openshift.Eap7LegacyS2iBuildTemplateApplication; +import org.jboss.intersmash.tools.provision.ProvisionerFactory; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class Eap7LegacyS2iBuildTemplateProvisionerFactory implements ProvisionerFactory { + + @Override + public Eap7LegacyS2iBuildTemplateProvisioner getProvisioner(Application application) { + if (Eap7LegacyS2iBuildTemplateApplication.class.isAssignableFrom(application.getClass())) + return new Eap7LegacyS2iBuildTemplateProvisioner((Eap7LegacyS2iBuildTemplateApplication) application); + return null; + } +} diff --git a/tools/intersmash-tools-provisioners/src/test/java/org/jboss/intersmash/tools/provision/ProvisionerManagerTestCase.java b/tools/intersmash-tools-provisioners/src/test/java/org/jboss/intersmash/tools/provision/ProvisionerManagerTestCase.java index 06bcb31a5..9836f2c4e 100644 --- a/tools/intersmash-tools-provisioners/src/test/java/org/jboss/intersmash/tools/provision/ProvisionerManagerTestCase.java +++ b/tools/intersmash-tools-provisioners/src/test/java/org/jboss/intersmash/tools/provision/ProvisionerManagerTestCase.java @@ -20,12 +20,14 @@ import org.jboss.intersmash.tools.application.Application; import org.jboss.intersmash.tools.application.openshift.ActiveMQOperatorApplication; import org.jboss.intersmash.tools.application.openshift.BootableJarOpenShiftApplication; +import org.jboss.intersmash.tools.application.openshift.Eap7LegacyS2iBuildTemplateApplication; import org.jboss.intersmash.tools.application.openshift.KafkaOperatorApplication; import org.jboss.intersmash.tools.application.openshift.MysqlImageOpenShiftApplication; import org.jboss.intersmash.tools.application.openshift.PostgreSQLImageOpenShiftApplication; import org.jboss.intersmash.tools.application.openshift.WildflyImageOpenShiftApplication; import org.jboss.intersmash.tools.application.openshift.WildflyOperatorApplication; import org.jboss.intersmash.tools.provision.openshift.ActiveMQOperatorProvisioner; +import org.jboss.intersmash.tools.provision.openshift.Eap7LegacyS2iBuildTemplateProvisioner; import org.jboss.intersmash.tools.provision.openshift.KafkaOperatorProvisioner; import org.jboss.intersmash.tools.provision.openshift.MysqlImageOpenShiftProvisioner; import org.jboss.intersmash.tools.provision.openshift.PostgreSQLImageOpenShiftProvisioner; @@ -42,7 +44,7 @@ * | InfinispanImageOpenShiftApplication | IMAGE | InfinispanImageOpenShiftProvisioner | * | MysqlImageOpenShiftApplication | IMAGE | MysqlImageOpenShiftProvisioner | * | PostgreSQLImageOpenShiftApplication | IMAGE | PostgreSQLImageOpenShiftProvisioner | - * | EapS2iBuildTemplateApplication | TEMPLATE | EapS2iBuildTemplateProvisioner | + * | Eap7LegacyS2iBuildTemplateApplication | TEMPLATE | Eap7LegacyS2iBuildTemplateProvisioner | * | WildflyOperatorApplication | OPERATOR | WildflyOperatorProvisioner | * | ActiveMQOperatorApplication | OPERATOR | ActiveMQOperatorProvisioner | * | KafkaOperatorApplication | OPERATOR | KafkaOperatorProvisioner | @@ -128,6 +130,17 @@ public void kafkaOperatorProvisioner() { Assertions.assertEquals(KafkaOperatorProvisioner.class, actual.getClass()); } + /** + * Eap7LegacyS2iBuildTemplateApplication/Eap7LegacyS2iBuildTemplateProvisioner + */ + @Test + public void eapS2iBuildTemplateProvisioner() { + application = mock(Eap7LegacyS2iBuildTemplateApplication.class); + + Provisioner actual = ProvisionerManager.getProvisioner(application); + Assertions.assertEquals(Eap7LegacyS2iBuildTemplateProvisioner.class, actual.getClass()); + } + @Test public void unsupportedProvisioner() { Assertions.assertThrows(UnsupportedOperationException.class,