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");
}
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");
}
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());
}
}
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());
}
}
Aggregations