From e0344fac15b56dc3c7ac96ae706def1c6dc46103 Mon Sep 17 00:00:00 2001 From: Andrej Vano Date: Mon, 12 Oct 2020 16:16:56 +0200 Subject: [PATCH] [Deploy] Replace deployCrd with installCluster --- .../syndesis/qe/OperatorValidationSteps.java | 2 +- .../java/io/syndesis/qe/UpgradeSteps.java | 2 +- .../qe/resource/impl/PreviousSyndesis.java | 2 +- .../syndesis/qe/resource/impl/Syndesis.java | 59 ------------------- 4 files changed, 3 insertions(+), 62 deletions(-) diff --git a/operator-tests/src/test/java/io/syndesis/qe/OperatorValidationSteps.java b/operator-tests/src/test/java/io/syndesis/qe/OperatorValidationSteps.java index 3cfb69b3e..0a3dadad6 100644 --- a/operator-tests/src/test/java/io/syndesis/qe/OperatorValidationSteps.java +++ b/operator-tests/src/test/java/io/syndesis/qe/OperatorValidationSteps.java @@ -82,7 +82,7 @@ public class OperatorValidationSteps { @Given("^deploy Syndesis CRD$") public void deployCRD() { - ResourceFactory.get(Syndesis.class).deployCrd(); + ResourceFactory.get(Syndesis.class).installCluster(); } @Given("^install cluster resources$") diff --git a/upgrade-tests/src/test/java/io/syndesis/qe/UpgradeSteps.java b/upgrade-tests/src/test/java/io/syndesis/qe/UpgradeSteps.java index e59c43f21..7a59e23c4 100644 --- a/upgrade-tests/src/test/java/io/syndesis/qe/UpgradeSteps.java +++ b/upgrade-tests/src/test/java/io/syndesis/qe/UpgradeSteps.java @@ -108,7 +108,7 @@ public void upgradeUsingOperator() { Syndesis syndesis = ResourceFactory.get(Syndesis.class); syndesis.defaultValues(); syndesis.pullOperatorImage(); - syndesis.deployCrd(); + syndesis.installCluster(); syndesis.grantPermissions(); syndesis.deployOperator(); } diff --git a/utilities/src/main/java/io/syndesis/qe/resource/impl/PreviousSyndesis.java b/utilities/src/main/java/io/syndesis/qe/resource/impl/PreviousSyndesis.java index df2f23475..df09c75e2 100644 --- a/utilities/src/main/java/io/syndesis/qe/resource/impl/PreviousSyndesis.java +++ b/utilities/src/main/java/io/syndesis/qe/resource/impl/PreviousSyndesis.java @@ -12,8 +12,8 @@ public void deploy() { log.info(" Cluster: " + TestConfiguration.openShiftUrl()); log.info(" Namespace: " + TestConfiguration.openShiftNamespace()); super.createPullSecret(); - super.deployCrd(); super.pullOperatorImage(); + super.installCluster(); super.grantPermissions(); super.deployOperator(); deploySyndesisViaOperator(); diff --git a/utilities/src/main/java/io/syndesis/qe/resource/impl/Syndesis.java b/utilities/src/main/java/io/syndesis/qe/resource/impl/Syndesis.java index 2ae10f5f4..eacdf17ae 100644 --- a/utilities/src/main/java/io/syndesis/qe/resource/impl/Syndesis.java +++ b/utilities/src/main/java/io/syndesis/qe/resource/impl/Syndesis.java @@ -46,9 +46,7 @@ import io.fabric8.kubernetes.api.model.Pod; import io.fabric8.kubernetes.api.model.ServiceAccount; import io.fabric8.kubernetes.api.model.apiextensions.CustomResourceDefinition; -import io.fabric8.kubernetes.api.model.apiextensions.CustomResourceDefinitionFluent; import io.fabric8.kubernetes.api.model.apiextensions.CustomResourceDefinitionVersion; -import io.fabric8.kubernetes.api.model.apiextensions.DoneableCustomResourceDefinition; import io.fabric8.kubernetes.api.model.apps.Deployment; import io.fabric8.kubernetes.client.KubernetesClientException; import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext; @@ -89,7 +87,6 @@ public void deploy() { log.info(" Cluster: " + TestConfiguration.openShiftUrl()); log.info(" Namespace: " + TestConfiguration.openShiftNamespace()); createPullSecret(); - deployCrd(); pullOperatorImage(); installCluster(); grantPermissions(); @@ -370,62 +367,6 @@ private CustomResourceDefinitionContext makeSyndesisContext(String version) { return builder.build(); } - public void deployCrd() { - log.info("Creating custom resource definition from " + crdUrl); - CustomResourceDefinition newCrd; - try (InputStream is = new URL(crdUrl).openStream()) { - newCrd = OpenShiftUtils.getInstance().customResourceDefinitions().load(is).get(); - } catch (IOException ex) { - throw new IllegalArgumentException("Unable to load CRD", ex); - } - - CustomResourceDefinition existingCrd = OpenShiftUtils.getInstance().customResourceDefinitions() - .withName(newCrd.getMetadata().getName()).get(); - if (existingCrd == null) { - // Just create a new CRD - OpenShiftUtils.getInstance().customResourceDefinitions().create(newCrd); - } else { - // Edit the existing CRD, if it doesn't contain the version we want to deploy now - // else do nothing, as the existing crd and new crd are probably the same - List versions = OpenShiftUtils.getInstance().customResourceDefinitions() - .withName(existingCrd.getMetadata().getName()).get().getSpec().getVersions(); - if (existingCrd.getSpec().getVersions().stream().noneMatch(v -> newCrd.getSpec().getVersion().equals(v.getName()))) { - CustomResourceDefinitionFluent.SpecNested crd = - OpenShiftUtils.getInstance().customResourceDefinitions().withName(existingCrd.getMetadata().getName()) - .edit() - .editSpec() - // Add a new version - .addNewVersion() - .withName(newCrd.getSpec().getVersion()) - .withServed(true) - .withStorage(true) - .endVersion(); - versions.stream().filter(v -> !v.getName().equals(newCrd.getSpec().getVersion())) - .forEach(v -> crd.editMatchingVersion(mv -> mv.getName().equals(v.getName())).withServed(true).withStorage(false).endVersion()); - crd.endSpec() - .editStatus() - // Also add it to stored versions - .addToStoredVersions(newCrd.getSpec().getVersion()) - .endStatus() - .done(); - } else { - // We need to make "current" CRD version "served" and with "storage" - CustomResourceDefinitionFluent.SpecNested crd = - OpenShiftUtils.getInstance().customResourceDefinitions().withName(existingCrd.getMetadata().getName()) - .edit() - .editSpec() - // Edit the version we want to deploy now - .editMatchingVersion(v -> v.getName().equals(newCrd.getSpec().getVersion())) - .withServed(true) - .withStorage(true) - .endVersion(); - versions.stream().filter(v -> !v.getName().equals(newCrd.getSpec().getVersion())) - .forEach(v -> crd.editMatchingVersion(mv -> mv.getName().equals(v.getName())).withServed(true).withStorage(false).endVersion()); - crd.endSpec().done(); - } - } - } - public List getOperatorResources() { String imageName = StringUtils.substringBeforeLast(operatorImage, ":"); String imageTag = StringUtils.substringAfterLast(operatorImage, ":");