Search in sources :

Example 1 with BuildServiceConfig

use of org.eclipse.jkube.kit.config.service.BuildServiceConfig in project jkube by eclipse.

the class TaskUtilTest method buildServiceConfigBuilder_shouldInitializeBuildServiceConfigWithDefaults.

@Test
public void buildServiceConfigBuilder_shouldInitializeBuildServiceConfigWithDefaults() {
    // When
    BuildServiceConfig buildServiceConfig = TaskUtil.buildServiceConfigBuilder(extension).build();
    // Then
    assertThat(buildServiceConfig).hasFieldOrPropertyWithValue("buildRecreateMode", BuildRecreateMode.none).hasFieldOrPropertyWithValue("jKubeBuildStrategy", JKubeBuildStrategy.docker).hasFieldOrPropertyWithValue("forcePull", false).hasFieldOrPropertyWithValue("buildDirectory", null);
}
Also used : BuildServiceConfig(org.eclipse.jkube.kit.config.service.BuildServiceConfig) Test(org.junit.Test)

Example 2 with BuildServiceConfig

use of org.eclipse.jkube.kit.config.service.BuildServiceConfig in project jkube by eclipse.

the class OpenShiftBuildServiceUtilsTest method computeS2IBuildName_withImageNameAndBuildServiceWithCustomSuffix_shouldReturnNameWithCustomSuffix.

@Test
public void computeS2IBuildName_withImageNameAndBuildServiceWithCustomSuffix_shouldReturnNameWithCustomSuffix() {
    // Given
    final BuildServiceConfig buildServiceConfig = BuildServiceConfig.builder().jKubeBuildStrategy(JKubeBuildStrategy.s2i).s2iBuildNameSuffix("-custom").buildDirectory(temporaryFolder.getRoot().getAbsolutePath()).build();
    final ImageName imageName = new ImageName("registry/name:tag");
    // When
    final String result = computeS2IBuildName(buildServiceConfig, imageName);
    // Then
    assertThat(result).isEqualTo("name-custom");
}
Also used : BuildServiceConfig(org.eclipse.jkube.kit.config.service.BuildServiceConfig) ImageName(org.eclipse.jkube.kit.config.image.ImageName) Test(org.junit.Test)

Example 3 with BuildServiceConfig

use of org.eclipse.jkube.kit.config.service.BuildServiceConfig in project jkube by eclipse.

the class OpenShiftBuildServiceUtilsTest method createBuildOutput_withOutputKindDockerAndPushSecret_shouldReturnDocker.

@Test
public void createBuildOutput_withOutputKindDockerAndPushSecret_shouldReturnDocker() {
    // Given
    final BuildServiceConfig buildServiceConfig = BuildServiceConfig.builder().buildOutputKind("DockerImage").openshiftPushSecret("my-push-secret").buildDirectory(temporaryFolder.getRoot().getAbsolutePath()).build();
    // When
    final BuildOutput result = createBuildOutput(buildServiceConfig, new ImageName("my-app-image"));
    // Then
    assertThat(result).hasFieldOrPropertyWithValue("pushSecret.name", "my-push-secret").extracting(BuildOutput::getTo).hasFieldOrPropertyWithValue("kind", "DockerImage").hasFieldOrPropertyWithValue("name", "my-app-image:latest");
}
Also used : BuildServiceConfig(org.eclipse.jkube.kit.config.service.BuildServiceConfig) ImageName(org.eclipse.jkube.kit.config.image.ImageName) BuildOutput(io.fabric8.openshift.api.model.BuildOutput) OpenShiftBuildServiceUtils.createBuildOutput(org.eclipse.jkube.kit.config.service.openshift.OpenShiftBuildServiceUtils.createBuildOutput) Test(org.junit.Test)

Example 4 with BuildServiceConfig

use of org.eclipse.jkube.kit.config.service.BuildServiceConfig in project jkube by eclipse.

the class OpenShiftBuildServiceUtilsTest method createBuildOutput_withDefaults_shouldReturnImageStreamTag.

@Test
public void createBuildOutput_withDefaults_shouldReturnImageStreamTag() {
    // When
    final BuildOutput result = createBuildOutput(new BuildServiceConfig(), new ImageName("my-app-image"));
    // Then
    assertThat(result).extracting(BuildOutput::getTo).hasFieldOrPropertyWithValue("kind", "ImageStreamTag").hasFieldOrPropertyWithValue("name", "my-app-image:latest");
}
Also used : BuildServiceConfig(org.eclipse.jkube.kit.config.service.BuildServiceConfig) ImageName(org.eclipse.jkube.kit.config.image.ImageName) BuildOutput(io.fabric8.openshift.api.model.BuildOutput) OpenShiftBuildServiceUtils.createBuildOutput(org.eclipse.jkube.kit.config.service.openshift.OpenShiftBuildServiceUtils.createBuildOutput) Test(org.junit.Test)

Example 5 with BuildServiceConfig

use of org.eclipse.jkube.kit.config.service.BuildServiceConfig in project jkube by eclipse.

the class OpenshiftBuildServiceIntegrationTest method testDockerBuildFromExt.

@Test
public void testDockerBuildFromExt() throws Exception {
    final BuildServiceConfig dockerConfig = withBuildServiceConfig(BuildServiceConfig.builder().buildDirectory(baseDir).buildRecreateMode(BuildRecreateMode.none).s2iBuildNameSuffix("-docker").jKubeBuildStrategy(JKubeBuildStrategy.docker).resourceConfig(mockedResourceConfig).build());
    final WebServerEventCollector collector = prepareMockServer(dockerConfig, true, false, false);
    OpenshiftBuildService service = new OpenshiftBuildService(jKubeServiceHub);
    Map<String, String> fromExt = ImmutableMap.of("name", "app:1.2-1", "kind", "ImageStreamTag", "namespace", "my-project");
    ImageConfiguration fromExtImage = ImageConfiguration.builder().name(projectName).build(BuildConfiguration.builder().fromExt(fromExt).nocache(Boolean.TRUE).build()).build();
    service.build(fromExtImage);
    assertTrue(mockServer.getOpenShiftMockServer().getRequestCount() > 8);
    collector.assertEventsRecordedInOrder("build-config-check", "new-build-config", "pushed");
    assertEquals("{\"apiVersion\":\"build.openshift.io/v1\",\"kind\":\"BuildConfig\",\"metadata\":{\"name\":\"myapp-docker\"},\"spec\":{\"output\":{\"to\":{\"kind\":\"ImageStreamTag\",\"name\":\"myapp:latest\"}},\"source\":{\"type\":\"Binary\"},\"strategy\":{\"dockerStrategy\":{\"from\":{\"kind\":\"ImageStreamTag\",\"name\":\"app:1.2-1\",\"namespace\":\"my-project\"},\"noCache\":true},\"type\":\"Docker\"}}}", collector.getBodies().get(1));
    collector.assertEventsNotRecorded("patch-build-config");
}
Also used : BuildServiceConfig(org.eclipse.jkube.kit.config.service.BuildServiceConfig) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) Test(org.junit.Test)

Aggregations

BuildServiceConfig (org.eclipse.jkube.kit.config.service.BuildServiceConfig)24 Test (org.junit.Test)20 ImageName (org.eclipse.jkube.kit.config.image.ImageName)6 BuildOutput (io.fabric8.openshift.api.model.BuildOutput)3 File (java.io.File)3 ImageConfiguration (org.eclipse.jkube.kit.config.image.ImageConfiguration)3 JKubeServiceHub (org.eclipse.jkube.kit.config.service.JKubeServiceHub)3 LocalObjectReferenceBuilder (io.fabric8.kubernetes.api.model.LocalObjectReferenceBuilder)2 BuildStrategy (io.fabric8.openshift.api.model.BuildStrategy)2 BuildStrategyBuilder (io.fabric8.openshift.api.model.BuildStrategyBuilder)2 JKubeConfiguration (org.eclipse.jkube.kit.common.JKubeConfiguration)2 KitLogger (org.eclipse.jkube.kit.common.KitLogger)2 BuildConfiguration (org.eclipse.jkube.kit.config.image.build.BuildConfiguration)2 JKubeBuildStrategy (org.eclipse.jkube.kit.config.image.build.JKubeBuildStrategy)2 OpenShiftBuildServiceUtils.createBuildOutput (org.eclipse.jkube.kit.config.service.openshift.OpenShiftBuildServiceUtils.createBuildOutput)2 EnvVar (io.fabric8.kubernetes.api.model.EnvVar)1 BuildConfig (io.fabric8.openshift.api.model.BuildConfig)1 BuildConfigSpec (io.fabric8.openshift.api.model.BuildConfigSpec)1 BuildOutputBuilder (io.fabric8.openshift.api.model.BuildOutputBuilder)1 FileWriter (java.io.FileWriter)1