KafkaConnectS2ICluster extends KafkaConnectCluster { public DeploymentConfig generateDeploymentConfig(Map<String, String> annotations, boolean isOpenShift, ImagePullPolicy imagePullPolicy, List<LocalObjectReference> imagePullSecrets) { Container container = new ContainerBuilder() .withName(name) .withImage(image) .withEnv(getEnvVars()) .withCommand("/opt/kafka/s2i/run") .withPorts(getContainerPortList()) .withLivenessProbe(ProbeGenerator.httpProbe(livenessProbeOptions, livenessPath, REST_API_PORT_NAME)) .withReadinessProbe(ProbeGenerator.httpProbe(readinessProbeOptions, readinessPath, REST_API_PORT_NAME)) .withVolumeMounts(getVolumeMounts()) .withResources(getResources()) .withImagePullPolicy(determineImagePullPolicy(imagePullPolicy, image)) .withSecurityContext(templateContainerSecurityContext) .build(); DeploymentTriggerPolicy configChangeTrigger = new DeploymentTriggerPolicyBuilder() .withType("ConfigChange") .build(); DeploymentTriggerPolicy imageChangeTrigger = new DeploymentTriggerPolicyBuilder() .withType("ImageChange") .withNewImageChangeParams() .withAutomatic(true) .withContainerNames(name) .withNewFrom() .withKind("ImageStreamTag") .withName(image) .endFrom() .endImageChangeParams() .build(); DeploymentStrategy updateStrategy = new DeploymentStrategyBuilder() .withType("Rolling") .withNewRollingParams() .withMaxSurge(new IntOrString(1)) .withMaxUnavailable(new IntOrString(0)) .endRollingParams() .build(); DeploymentConfig dc = new DeploymentConfigBuilder() .withNewMetadata() .withName(name) .withLabels(getLabelsWithStrimziName(name, templateDeploymentLabels).toMap()) .withAnnotations(Util.mergeLabelsOrAnnotations(null, templateDeploymentAnnotations)) .withNamespace(namespace) .withOwnerReferences(createOwnerReference()) .endMetadata() .withNewSpec() .withReplicas(replicas) .withSelector(getSelectorLabels().toMap()) .withNewTemplate() .withNewMetadata() .withAnnotations(Util.mergeLabelsOrAnnotations(annotations, templatePodAnnotations)) .withLabels(getLabelsWithStrimziName(name, templatePodLabels).toMap()) .endMetadata() .withNewSpec() .withContainers(container) .withVolumes(getVolumes(isOpenShift)) .withTolerations(getTolerations()) .withAffinity(getMergedAffinity()) .withTerminationGracePeriodSeconds(Long.valueOf(templateTerminationGracePeriodSeconds)) .withImagePullSecrets(templateImagePullSecrets != null ? templateImagePullSecrets : imagePullSecrets) .withSecurityContext(templateSecurityContext) .withPriorityClassName(templatePodPriorityClassName) .withSchedulerName(templatePodSchedulerName) .withHostAliases(templatePodHostAliases) .endSpec() .endTemplate() .withTriggers(configChangeTrigger, imageChangeTrigger) .withStrategy(updateStrategy) .endSpec() .build(); return dc; } private  KafkaConnectS2ICluster(HasMetadata resource); static KafkaConnectS2ICluster fromCrd(KafkaConnectS2I kafkaConnectS2I, KafkaVersion.Lookup versions); DeploymentConfig generateDeploymentConfig(Map<String, String> annotations, boolean isOpenShift, ImagePullPolicy imagePullPolicy,
                                                     List<LocalObjectReference> imagePullSecrets); ImageStream generateSourceImageStream(); ImageStream generateTargetImageStream(); BuildConfig generateBuildConfig(); boolean isInsecureSourceRepository(); void setInsecureSourceRepository(boolean insecureSourceRepository); void setBuildResourceRequirements(ResourceRequirements buildRequirements);  }
@Test public void testGenerateDeploymentConfig() { DeploymentConfig dep = kc.generateDeploymentConfig(Collections.EMPTY_MAP, true, null, null); assertThat(dep.getMetadata().getName(), is(KafkaConnectS2IResources.deploymentName(cluster))); assertThat(dep.getMetadata().getNamespace(), is(namespace)); Map<String, String> expectedLabels = expectedLabels(KafkaConnectS2IResources.deploymentName(cluster)); assertThat(dep.getMetadata().getLabels(), is(expectedLabels)); assertThat(dep.getSpec().getSelector(), is(expectedSelectorLabels())); assertThat(dep.getSpec().getReplicas(), is(Integer.valueOf(replicas))); assertThat(dep.getSpec().getTemplate().getMetadata().getLabels(), is(expectedLabels)); assertThat(dep.getSpec().getTemplate().getSpec().getContainers().size(), is(1)); assertThat(dep.getSpec().getTemplate().getSpec().getContainers().get(0).getName(), is(KafkaConnectS2IResources.deploymentName(this.cluster))); assertThat(dep.getSpec().getTemplate().getSpec().getContainers().get(0).getImage(), is(KafkaConnectS2IResources.deploymentName(this.cluster) + ":latest")); assertThat(dep.getSpec().getTemplate().getSpec().getContainers().get(0).getEnv(), is(getExpectedEnvVars())); assertThat(dep.getSpec().getTemplate().getSpec().getContainers().get(0).getLivenessProbe().getInitialDelaySeconds(), is(Integer.valueOf(healthDelay))); assertThat(dep.getSpec().getTemplate().getSpec().getContainers().get(0).getLivenessProbe().getTimeoutSeconds(), is(Integer.valueOf(healthTimeout))); assertThat(dep.getSpec().getTemplate().getSpec().getContainers().get(0).getReadinessProbe().getInitialDelaySeconds(), is(Integer.valueOf(healthDelay))); assertThat(dep.getSpec().getTemplate().getSpec().getContainers().get(0).getReadinessProbe().getTimeoutSeconds(), is(Integer.valueOf(healthTimeout))); assertThat(dep.getSpec().getTemplate().getSpec().getContainers().get(0).getPorts().size(), is(2)); assertThat(dep.getSpec().getTemplate().getSpec().getContainers().get(0).getPorts().get(0).getContainerPort(), is(Integer.valueOf(KafkaConnectCluster.REST_API_PORT))); assertThat(dep.getSpec().getTemplate().getSpec().getContainers().get(0).getPorts().get(0).getName(), is(KafkaConnectCluster.REST_API_PORT_NAME)); assertThat(dep.getSpec().getTemplate().getSpec().getContainers().get(0).getPorts().get(0).getProtocol(), is("TCP")); assertThat(dep.getSpec().getTriggers().size(), is(2)); assertThat(dep.getSpec().getTriggers().get(0).getType(), is("ConfigChange")); assertThat(dep.getSpec().getTriggers().get(1).getType(), is("ImageChange")); assertThat(dep.getSpec().getTriggers().get(1).getImageChangeParams().getAutomatic(), is(true)); assertThat(dep.getSpec().getTriggers().get(1).getImageChangeParams().getContainerNames().size(), is(1)); assertThat(dep.getSpec().getTriggers().get(1).getImageChangeParams().getContainerNames().get(0), is(KafkaConnectS2IResources.deploymentName(this.cluster))); assertThat(dep.getSpec().getTriggers().get(1).getImageChangeParams().getFrom().getName(), is(KafkaConnectS2IResources.deploymentName(this.cluster) + ":latest")); assertThat(dep.getSpec().getTriggers().get(1).getImageChangeParams().getFrom().getKind(), is("ImageStreamTag")); assertThat(dep.getSpec().getStrategy().getType(), is("Rolling")); assertThat(dep.getSpec().getStrategy().getRollingParams().getMaxSurge().getIntVal(), is(Integer.valueOf(1))); assertThat(dep.getSpec().getStrategy().getRollingParams().getMaxUnavailable().getIntVal(), is(Integer.valueOf(0))); assertThat(AbstractModel.containerEnvVars(dep.getSpec().getTemplate().getSpec().getContainers().get(0)).get(KafkaConnectCluster.ENV_VAR_KAFKA_CONNECT_TLS), is(nullValue())); checkOwnerReference(kc.createOwnerReference(), dep); }