@Test public void testDeploy() throws InterruptedException, JsonProcessingException { final String name = "test-deployment"; final DeploymentData deploymentData = new DeploymentData.Builder() .addAnnotation("testName", testName.getMethodName()) .addLabel("type", "test") .addSecretEntry("secret-key", "secret-val") .withImage("testimage") .build(); final Secret expectedSecret = secretFor(name, deploymentData); final DeploymentConfig expectedDeploymentConfig = baseDeploymentFor(name, deploymentData).build(); server.expect() .post() .withPath("/api/v1/namespaces/test/secrets") .andReturn(200, expectedSecret) .always(); expectDeploymentOf(name, expectedDeploymentConfig); service.deploy(name, deploymentData); final List<Request> issuedRequests = gatherRequests(); assertThat(issuedRequests).contains(Request.with("POST", "/apis/apps.openshift.io/v1/namespaces/test/deploymentconfigs", expectedDeploymentConfig)); assertThat(issuedRequests).contains(Request.with("POST", "/api/v1/namespaces/test/secrets", expectedSecret)); }
@Override public String deploy(String name, DeploymentData deploymentData) { final String sanitizedName = openshiftName(name); LOGGER.debug("Deploy {}", sanitizedName); ensureDeploymentConfig(sanitizedName, deploymentData); ensureSecret(sanitizedName, deploymentData); ensureExposure(sanitizedName, deploymentData); DeploymentConfig deployment = openShiftClient.deploymentConfigs().withName(sanitizedName).deployLatest(); return String.valueOf(deployment.getStatus().getLatestVersion()); }
OpenShiftServiceImpl implements OpenShiftService { @Override public String deploy(String name, DeploymentData deploymentData) { final String sanitizedName = openshiftName(name); LOGGER.debug("Deploy {}", sanitizedName); ensureDeploymentConfig(sanitizedName, deploymentData); ensureSecret(sanitizedName, deploymentData); ensureExposure(sanitizedName, deploymentData); DeploymentConfig deployment = openShiftClient.deploymentConfigs().withName(sanitizedName).deployLatest(); return String.valueOf(deployment.getStatus().getLatestVersion()); } }
OpenShiftServiceImpl implements OpenShiftService { @Override public String deploy(String name, DeploymentData deploymentData) { final String sanitizedName = openshiftName(name); LOGGER.debug("Deploy {}", sanitizedName); ensureDeploymentConfig(sanitizedName, deploymentData); ensureSecret(sanitizedName, deploymentData); ensureExposure(sanitizedName, deploymentData); DeploymentConfig deployment = openShiftClient.deploymentConfigs().withName(sanitizedName).deployLatest(); return String.valueOf(deployment.getStatus().getLatestVersion()); } OpenShiftServiceImpl(NamespacedOpenShiftClient openShiftClient, OpenShiftConfigurationProperties config); }
OpenShiftServiceImpl implements OpenShiftService { @Override public String deploy(String name, DeploymentData deploymentData) { final String sanitizedName = openshiftName(name); LOGGER.debug("Deploy {}", sanitizedName); ensureDeploymentConfig(sanitizedName, deploymentData); ensureSecret(sanitizedName, deploymentData); ensureExposure(sanitizedName, deploymentData); DeploymentConfig deployment = openShiftClient.deploymentConfigs().withName(sanitizedName).deployLatest(); return String.valueOf(deployment.getStatus().getLatestVersion()); } OpenShiftServiceImpl(NamespacedOpenShiftClient openShiftClient, OpenShiftConfigurationProperties config); @Override String build(String name, DeploymentData deploymentData, InputStream tarInputStream); @Override String deploy(String name, DeploymentData deploymentData); @Override boolean isDeploymentReady(String name); @Override boolean delete(String name); @Override boolean exists(String name); @Override void scale(String name, Map<String, String> labels, int desiredReplicas, long amount, TimeUnit timeUnit); @Override boolean isScaled(String name, int desiredMinimumReplicas, Map<String, String> labels); @Override boolean isBuildStarted(String name); @Override boolean isBuildFailed(String name); @Override List<DeploymentConfig> getDeploymentsByLabel(Map<String, String> labels); @Override User whoAmI(String username); @Override Optional<String> getExposedHost(String name); @Override List<HasMetadata> createOrReplaceCRD(InputStream crdYamlStream); @Override CustomResourceDefinition createOrReplaceCRD(CustomResourceDefinition crd); @Override Optional<CustomResourceDefinition> getCRD(String crdName); @Override @SuppressWarnings({"unchecked"}) boolean deleteCR(CustomResourceDefinition crd, Class<T> resourceType, Class<L> resourceListType, Class<D> doneableResourceType, String customResourceName); @Override Watch watchCR(CustomResourceDefinition crd, Class<T> resourceType, Class<L> resourceListType, Class<D> doneableResourceType, BiConsumer<Watcher.Action,T> watcher); @Override @SuppressWarnings({"unchecked"}) boolean deleteCR(CustomResourceDefinition crd, Class<T> resourceType, Class<L> resourceListType, Class<D> doneableResourceType, String customResourceName, boolean cascading); @Override @SuppressWarnings({"unchecked"}) T createOrReplaceCR(CustomResourceDefinition crd, Class<T> resourceType, Class<L> resourceListType, Class<D> doneableResourceType, T customResource); @Override T getCR(CustomResourceDefinition crd, Class<T> resourceType, Class<L> resourceListType, Class<D> doneableResourceType, String customResourceName); @Override List<T> getCRBylabel(CustomResourceDefinition crd, Class<T> resourceType, Class<L> resourceListType, Class<D> doneableResourceType, Map<String, String> labels); @Override void createOrReplaceSecret(Secret secret); @Override ConfigMap createOrReplaceConfigMap(ConfigMap configMap); }
OpenShiftServiceImpl implements OpenShiftService { @Override public String deploy(String name, DeploymentData deploymentData) { final String sanitizedName = openshiftName(name); LOGGER.debug("Deploy {}", sanitizedName); ensureDeploymentConfig(sanitizedName, deploymentData); ensureSecret(sanitizedName, deploymentData); ensureExposure(sanitizedName, deploymentData); DeploymentConfig deployment = openShiftClient.deploymentConfigs().withName(sanitizedName).deployLatest(); return String.valueOf(deployment.getStatus().getLatestVersion()); } OpenShiftServiceImpl(NamespacedOpenShiftClient openShiftClient, OpenShiftConfigurationProperties config); @Override String build(String name, DeploymentData deploymentData, InputStream tarInputStream); @Override String deploy(String name, DeploymentData deploymentData); @Override boolean isDeploymentReady(String name); @Override boolean delete(String name); @Override boolean exists(String name); @Override void scale(String name, Map<String, String> labels, int desiredReplicas, long amount, TimeUnit timeUnit); @Override boolean isScaled(String name, int desiredMinimumReplicas, Map<String, String> labels); @Override boolean isBuildStarted(String name); @Override boolean isBuildFailed(String name); @Override List<DeploymentConfig> getDeploymentsByLabel(Map<String, String> labels); @Override User whoAmI(String username); @Override Optional<String> getExposedHost(String name); @Override List<HasMetadata> createOrReplaceCRD(InputStream crdYamlStream); @Override CustomResourceDefinition createOrReplaceCRD(CustomResourceDefinition crd); @Override Optional<CustomResourceDefinition> getCRD(String crdName); @Override @SuppressWarnings({"unchecked"}) boolean deleteCR(CustomResourceDefinition crd, Class<T> resourceType, Class<L> resourceListType, Class<D> doneableResourceType, String customResourceName); @Override Watch watchCR(CustomResourceDefinition crd, Class<T> resourceType, Class<L> resourceListType, Class<D> doneableResourceType, BiConsumer<Watcher.Action,T> watcher); @Override @SuppressWarnings({"unchecked"}) boolean deleteCR(CustomResourceDefinition crd, Class<T> resourceType, Class<L> resourceListType, Class<D> doneableResourceType, String customResourceName, boolean cascading); @Override @SuppressWarnings({"unchecked"}) T createOrReplaceCR(CustomResourceDefinition crd, Class<T> resourceType, Class<L> resourceListType, Class<D> doneableResourceType, T customResource); @Override T getCR(CustomResourceDefinition crd, Class<T> resourceType, Class<L> resourceListType, Class<D> doneableResourceType, String customResourceName); @Override List<T> getCRBylabel(CustomResourceDefinition crd, Class<T> resourceType, Class<L> resourceListType, Class<D> doneableResourceType, Map<String, String> labels); @Override void createOrReplaceSecret(Secret secret); @Override ConfigMap createOrReplaceConfigMap(ConfigMap configMap); static final String SECRET_VOLUME; static final String IMAGE_STREAM_TAG; static final String IMAGE_CHANGE; static final String MEMORY; static final CustomResourceDefinition SYNDESIS_CRD; }