use of org.eclipse.jkube.kit.common.JKubeConfiguration in project jkube by eclipse.
the class JKubeServiceHubBuildServiceTest method getBuildService.
@Test
public void getBuildService() {
// Given
final BuildServiceConfig config = BuildServiceConfig.builder().jKubeBuildStrategy(buildStrategy).build();
final JKubeServiceHub jKubeServiceHub = new JKubeServiceHub(null, runtimeMode, new KitLogger.StdoutLogger(), mock(DockerServiceHub.class, RETURNS_DEEP_STUBS), new JKubeConfiguration(), config, new LazyBuilder<>(() -> null), true);
// When
final BuildService result = jKubeServiceHub.getBuildService();
// Then
assertThat(result).isNotNull().isInstanceOf(buildServiceClass);
}
use of org.eclipse.jkube.kit.common.JKubeConfiguration 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.common.JKubeConfiguration 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