Search in sources :

Example 1 with BinaryBuildSource

use of io.fabric8.openshift.api.model.BinaryBuildSource 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 BinaryBuildSource

use of io.fabric8.openshift.api.model.BinaryBuildSource 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)

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 BuildConfigBuilder (io.fabric8.openshift.api.model.BuildConfigBuilder)1 BuildTriggerPolicy (io.fabric8.openshift.api.model.BuildTriggerPolicy)1 Test (org.junit.Test)1