Search in sources :

Example 21 with BuildServiceConfig

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

the class OpenshiftBuildServiceIntegrationTest method build_withAssembly_shouldSucceed.

@Test
public void build_withAssembly_shouldSucceed() throws Exception {
    // Given
    final BuildServiceConfig config = withBuildServiceConfig(defaultConfig.build());
    final WebServerEventCollector collector = prepareMockServer(config, true, false, false);
    image.setBuild(BuildConfiguration.builder().from(projectName).assembly(AssemblyConfiguration.builder().layer(Assembly.builder().id("one").build()).build()).build());
    // When
    new OpenshiftBuildService(jKubeServiceHub).build(image);
    // Then
    collector.assertEventsRecordedInOrder("build-config-check", "new-build-config", "pushed");
}
Also used : BuildServiceConfig(org.eclipse.jkube.kit.config.service.BuildServiceConfig) Test(org.junit.Test)

Example 22 with BuildServiceConfig

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

the class TaskUtilTest method buildServiceConfigBuilder_shouldInitializeBuildServiceConfigWithConfiguredValues.

@Test
public void buildServiceConfigBuilder_shouldInitializeBuildServiceConfigWithConfiguredValues() {
    // Given
    extension.buildRecreate = "true";
    extension.isForcePull = true;
    extension.buildStrategy = JKubeBuildStrategy.jib;
    when(extension.javaProject.getBuildDirectory().getAbsolutePath()).thenReturn("/tmp/foo");
    // When
    BuildServiceConfig buildServiceConfig = TaskUtil.buildServiceConfigBuilder(extension).build();
    // Then
    assertThat(buildServiceConfig).hasFieldOrPropertyWithValue("buildRecreateMode", BuildRecreateMode.all).hasFieldOrPropertyWithValue("jKubeBuildStrategy", JKubeBuildStrategy.jib).hasFieldOrPropertyWithValue("forcePull", true).hasFieldOrPropertyWithValue("buildDirectory", "/tmp/foo");
}
Also used : BuildServiceConfig(org.eclipse.jkube.kit.config.service.BuildServiceConfig) Test(org.junit.Test)

Example 23 with BuildServiceConfig

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

the class Main method main.

public static void main(String[] args) {
    final KitLogger kitLogger = new KitLogger.StdoutLogger();
    kitLogger.info("Initiating default JKube configuration and required services...");
    kitLogger.info(" - Creating Docker Build Service Configuration");
    final BuildServiceConfig dockerBuildServiceConfig = BuildServiceConfig.builder().build();
    kitLogger.info(" - Creating configuration for JKube");
    kitLogger.info(" - Current working directory is: %s", getProjectDir().toFile().toString());
    final JKubeConfiguration configuration = JKubeConfiguration.builder().project(JavaProject.builder().baseDirectory(getProjectDir().toFile()).build()).outputDirectory("target").build();
    kitLogger.info("Creating configuration for example Docker Image");
    final ImageConfiguration imageConfiguration = ImageConfiguration.builder().name("jkube-example").run(RunImageConfiguration.builder().user("1000").build()).build(BuildConfiguration.builder().putEnv("MY_VAR", "value").putEnv("MY_OTHER_VAR", "true").label("maintainer", "JKube Devs").port("80/tcp").maintainer("JKube Devs").from("busybox").assembly(AssemblyConfiguration.builder().targetDir("/").layer(Assembly.builder().fileSet(AssemblyFileSet.builder().directory(new File("static")).build()).build()).build()).cmd(Arguments.builder().shell("/bin/sh").build()).build()).build();
    try (JKubeServiceHub jKubeServiceHub = JKubeServiceHub.builder().log(kitLogger).configuration(configuration).platformMode(RuntimeMode.KUBERNETES).dockerServiceHub(DockerServiceHub.newInstance(kitLogger)).buildServiceConfig(dockerBuildServiceConfig).build()) {
        jKubeServiceHub.getBuildService().build(imageConfiguration);
        final String imageId = jKubeServiceHub.getDockerServiceHub().getDockerAccess().getImageId("jkube-example");
        kitLogger.info("Docker image built successfully (%s)!", imageId);
        System.exit(0);
    } catch (Exception ex) {
        kitLogger.error("Error occurred: '%s'", ex.getMessage());
    }
}
Also used : BuildServiceConfig(org.eclipse.jkube.kit.config.service.BuildServiceConfig) KitLogger(org.eclipse.jkube.kit.common.KitLogger) JKubeConfiguration(org.eclipse.jkube.kit.common.JKubeConfiguration) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) RunImageConfiguration(org.eclipse.jkube.kit.config.image.RunImageConfiguration) File(java.io.File) JKubeServiceHub(org.eclipse.jkube.kit.config.service.JKubeServiceHub)

Example 24 with BuildServiceConfig

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

the class Main method main.

public static void main(String[] args) {
    final KitLogger kitLogger = new KitLogger.StdoutLogger();
    kitLogger.info("Initiating default JKube configuration and required services...");
    kitLogger.info(" - Creating Docker Service Hub");
    final DockerServiceHub dockerServiceHub = DockerServiceHub.newInstance(kitLogger);
    kitLogger.info(" - Creating Docker Build Service Configuration");
    final BuildServiceConfig dockerBuildServiceConfig = BuildServiceConfig.builder().build();
    kitLogger.info(" - Creating configuration for JKube");
    kitLogger.info(" - Current working directory is: %s", getProjectDir().toFile().toString());
    final JKubeConfiguration configuration = JKubeConfiguration.builder().project(JavaProject.builder().baseDirectory(getProjectDir().toFile()).build()).outputDirectory("target").sourceDirectory(getProjectDir().toFile().getAbsolutePath()).build();
    JKubeServiceHub.JKubeServiceHubBuilder buildBuilder = JKubeServiceHub.builder().log(kitLogger).configuration(configuration).platformMode(RuntimeMode.KUBERNETES).dockerServiceHub(dockerServiceHub).buildServiceConfig(dockerBuildServiceConfig);
    try (JKubeServiceHub jKubeServiceHub = buildBuilder.build()) {
        jKubeServiceHub.getBuildService().build(new DynamicDockerfileGenerator(kitLogger, getProjectDir(), IMAGE_NAME).generateImageConfiguration());
        final String imageId = jKubeServiceHub.getDockerServiceHub().getDockerAccess().getImageId(IMAGE_NAME);
        kitLogger.info("Docker image built successfully (%s)!", imageId);
        System.exit(0);
    } catch (Exception ex) {
        ex.printStackTrace();
        kitLogger.error("Error occurred: '%s'", ex.getMessage());
    }
}
Also used : BuildServiceConfig(org.eclipse.jkube.kit.config.service.BuildServiceConfig) KitLogger(org.eclipse.jkube.kit.common.KitLogger) JKubeConfiguration(org.eclipse.jkube.kit.common.JKubeConfiguration) DockerServiceHub(org.eclipse.jkube.kit.build.service.docker.DockerServiceHub) JKubeServiceHub(org.eclipse.jkube.kit.config.service.JKubeServiceHub)

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