Search in sources :

Example 1 with ImageChangeTrigger

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;
}
Also used : BinaryBuildSource(io.fabric8.openshift.api.model.BinaryBuildSource) BuildConfig(io.fabric8.openshift.api.model.BuildConfig) ImageChangeTrigger(io.fabric8.openshift.api.model.ImageChangeTrigger) BuildConfigBuilder(io.fabric8.openshift.api.model.BuildConfigBuilder) BuildTriggerPolicy(io.fabric8.openshift.api.model.BuildTriggerPolicy)

Example 2 with ImageChangeTrigger

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());
}
Also used : BinaryBuildSource(io.fabric8.openshift.api.model.BinaryBuildSource) BuildConfig(io.fabric8.openshift.api.model.BuildConfig) ImageChangeTrigger(io.fabric8.openshift.api.model.ImageChangeTrigger) Test(org.junit.Test)

Example 3 with ImageChangeTrigger

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;
}
Also used : Container(io.fabric8.kubernetes.api.model.Container) ContainerBuilder(io.fabric8.kubernetes.api.model.ContainerBuilder) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) DeploymentConfigBuilder(io.fabric8.openshift.api.model.DeploymentConfigBuilder) DeploymentStrategyBuilder(io.fabric8.openshift.api.model.DeploymentStrategyBuilder) DeploymentConfig(io.fabric8.openshift.api.model.DeploymentConfig) DeploymentTriggerPolicy(io.fabric8.openshift.api.model.DeploymentTriggerPolicy) DeploymentTriggerPolicyBuilder(io.fabric8.openshift.api.model.DeploymentTriggerPolicyBuilder) DeploymentStrategy(io.fabric8.openshift.api.model.DeploymentStrategy)

Aggregations

BinaryBuildSource (io.fabric8.openshift.api.model.BinaryBuildSource)2 BuildConfig (io.fabric8.openshift.api.model.BuildConfig)2 ImageChangeTrigger (io.fabric8.openshift.api.model.ImageChangeTrigger)2 Container (io.fabric8.kubernetes.api.model.Container)1 ContainerBuilder (io.fabric8.kubernetes.api.model.ContainerBuilder)1 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)1 BuildConfigBuilder (io.fabric8.openshift.api.model.BuildConfigBuilder)1 BuildTriggerPolicy (io.fabric8.openshift.api.model.BuildTriggerPolicy)1 DeploymentConfig (io.fabric8.openshift.api.model.DeploymentConfig)1 DeploymentConfigBuilder (io.fabric8.openshift.api.model.DeploymentConfigBuilder)1 DeploymentStrategy (io.fabric8.openshift.api.model.DeploymentStrategy)1 DeploymentStrategyBuilder (io.fabric8.openshift.api.model.DeploymentStrategyBuilder)1 DeploymentTriggerPolicy (io.fabric8.openshift.api.model.DeploymentTriggerPolicy)1 DeploymentTriggerPolicyBuilder (io.fabric8.openshift.api.model.DeploymentTriggerPolicyBuilder)1 Test (org.junit.Test)1