Search in sources :

Example 11 with KitLogger

use of org.eclipse.jkube.kit.common.KitLogger 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

KitLogger (org.eclipse.jkube.kit.common.KitLogger)11 JKubeConfiguration (org.eclipse.jkube.kit.common.JKubeConfiguration)4 File (java.io.File)3 ImageConfiguration (org.eclipse.jkube.kit.config.image.ImageConfiguration)3 BuildServiceConfig (org.eclipse.jkube.kit.config.service.BuildServiceConfig)3 JKubeServiceHub (org.eclipse.jkube.kit.config.service.JKubeServiceHub)3 Before (org.junit.Before)3 SerializationFeature (com.fasterxml.jackson.databind.SerializationFeature)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 KubernetesList (io.fabric8.kubernetes.api.model.KubernetesList)1 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)1 Pod (io.fabric8.kubernetes.api.model.Pod)1 Quantity (io.fabric8.kubernetes.api.model.Quantity)1 WatchEvent (io.fabric8.kubernetes.api.model.WatchEvent)1 Serialization (io.fabric8.kubernetes.client.utils.Serialization)1 Build (io.fabric8.openshift.api.model.Build)1 BuildBuilder (io.fabric8.openshift.api.model.BuildBuilder)1 BuildConfig (io.fabric8.openshift.api.model.BuildConfig)1 BuildConfigBuilder (io.fabric8.openshift.api.model.BuildConfigBuilder)1 BuildStrategyBuilder (io.fabric8.openshift.api.model.BuildStrategyBuilder)1