use of io.fabric8.openshift.api.model.ImageChangeTrigger in project strimzi by strimzi.
the class KafkaConnectS2ICluster method generateBuildConfig.
/**
* Generate new BuildConfig
*
* @return BuildConfig resource definition
*/
public BuildConfig generateBuildConfig() {
BuildTriggerPolicy triggerConfigChange = new BuildTriggerPolicy();
triggerConfigChange.setType("ConfigChange");
BuildTriggerPolicy triggerImageChange = new BuildTriggerPolicy();
triggerImageChange.setType("ImageChange");
triggerImageChange.setImageChange(new ImageChangeTrigger());
BuildConfig build = new BuildConfigBuilder().withNewMetadata().withName(name).withLabels(getLabelsWithName()).withNamespace(namespace).endMetadata().withNewSpec().withFailedBuildsHistoryLimit(5).withNewOutput().withNewTo().withKind("ImageStreamTag").withName(image).endTo().endOutput().withRunPolicy("Serial").withNewSource().withType("Binary").withBinary(new BinaryBuildSource()).endSource().withNewStrategy().withType("Source").withNewSourceStrategy().withNewFrom().withKind("ImageStreamTag").withName(getSourceImageStreamName() + ":" + sourceImageTag).endFrom().endSourceStrategy().endStrategy().withTriggers(triggerConfigChange, triggerImageChange).endSpec().build();
return build;
}
use of io.fabric8.openshift.api.model.ImageChangeTrigger in project strimzi by strimzi.
the class KafkaConnectS2IClusterTest method testGenerateBuildConfig.
@Test
public void testGenerateBuildConfig() {
BuildConfig bc = kc.generateBuildConfig();
assertEquals(kc.kafkaConnectClusterName(cluster), bc.getMetadata().getName());
assertEquals(namespace, bc.getMetadata().getNamespace());
assertEquals(ResourceUtils.labels(Labels.STRIMZI_CLUSTER_LABEL, cluster, Labels.STRIMZI_TYPE_LABEL, "kafka-connect-s2i", "my-user-label", "cromulent", Labels.STRIMZI_NAME_LABEL, kc.kafkaConnectClusterName(cluster)), bc.getMetadata().getLabels());
assertEquals("ImageStreamTag", bc.getSpec().getOutput().getTo().getKind());
assertEquals(kc.image, bc.getSpec().getOutput().getTo().getName());
assertEquals("Serial", bc.getSpec().getRunPolicy());
assertEquals("Binary", bc.getSpec().getSource().getType());
assertEquals(new BinaryBuildSource(), bc.getSpec().getSource().getBinary());
assertEquals("Source", bc.getSpec().getStrategy().getType());
assertEquals("ImageStreamTag", bc.getSpec().getStrategy().getSourceStrategy().getFrom().getKind());
assertEquals(kc.getSourceImageStreamName() + ":" + kc.sourceImageTag, bc.getSpec().getStrategy().getSourceStrategy().getFrom().getName());
assertEquals(2, bc.getSpec().getTriggers().size());
assertEquals("ConfigChange", bc.getSpec().getTriggers().get(0).getType());
assertEquals("ImageChange", bc.getSpec().getTriggers().get(1).getType());
assertEquals(new ImageChangeTrigger(), bc.getSpec().getTriggers().get(1).getImageChange());
}
use of io.fabric8.openshift.api.model.ImageChangeTrigger in project strimzi by strimzi.
the class KafkaConnectS2ICluster method generateDeploymentConfig.
/**
* Generate new DeploymentConfig
*
* @return Source ImageStream resource definition
*/
public DeploymentConfig generateDeploymentConfig() {
Container container = new ContainerBuilder().withName(name).withImage(image).withEnv(getEnvVars()).withPorts(Collections.singletonList(createContainerPort(REST_API_PORT_NAME, REST_API_PORT, "TCP"))).withLivenessProbe(createHttpProbe(healthCheckPath, REST_API_PORT_NAME, healthCheckInitialDelay, healthCheckTimeout)).withReadinessProbe(createHttpProbe(healthCheckPath, REST_API_PORT_NAME, healthCheckInitialDelay, healthCheckTimeout)).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(getLabelsWithName()).withNamespace(namespace).endMetadata().withNewSpec().withReplicas(replicas).withNewTemplate().withNewMetadata().withLabels(getLabelsWithName()).endMetadata().withNewSpec().withContainers(container).endSpec().endTemplate().withTriggers(configChangeTrigger, imageChangeTrigger).withStrategy(updateStrategy).endSpec().build();
return dc;
}
Aggregations