Search in sources :

Example 51 with ImageConfiguration

use of io.fabric8.maven.docker.config.ImageConfiguration in project fabric8-maven-plugin by fabric8io.

the class SpringBootWatcher method watch.

@Override
public void watch(List<ImageConfiguration> configs, Set<HasMetadata> resources, PlatformMode mode) throws Exception {
    KubernetesClient kubernetes = getContext().getKubernetesClient();
    PodLogService.PodLogServiceContext logContext = new PodLogService.PodLogServiceContext.Builder().log(log).newPodLog(getContext().getNewPodLogger()).oldPodLog(getContext().getOldPodLogger()).build();
    new PodLogService(logContext).tailAppPodsLogs(kubernetes, getContext().getNamespace(), resources, false, null, true, null, false);
    String url = getServiceExposeUrl(kubernetes, resources);
    if (url == null) {
        url = getPortForwardUrl(resources);
    }
    if (url != null) {
        runRemoteSpringApplication(url);
    } else {
        throw new IllegalStateException("Unable to open a channel to the remote pod.");
    }
}
Also used : KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) PodLogService(io.fabric8.maven.core.service.PodLogService)

Example 52 with ImageConfiguration

use of io.fabric8.maven.docker.config.ImageConfiguration in project docker-maven-plugin by fabric8io.

the class PropertyConfigHandlerTest method testDockerFile.

@Test
public void testDockerFile() {
    String[] testData = new String[] { k(ConfigKey.NAME), "image", k(ConfigKey.DOCKER_FILE), "file" };
    ImageConfiguration config = resolveExternalImageConfig(testData);
    assertNotNull(config.getBuildConfiguration());
}
Also used : BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) AbstractConfigHandlerTest(io.fabric8.maven.docker.config.handler.AbstractConfigHandlerTest)

Example 53 with ImageConfiguration

use of io.fabric8.maven.docker.config.ImageConfiguration in project docker-maven-plugin by fabric8io.

the class PropertyConfigHandlerTest method testDockerArchive.

@Test
public void testDockerArchive() {
    String[] testData = new String[] { k(ConfigKey.NAME), "image", k(ConfigKey.DOCKER_ARCHIVE), "dockerLoad.tar", k(ConfigKey.FROM), "busybox" };
    ImageConfiguration config = resolveExternalImageConfig(testData);
    config.initAndValidate(ConfigHelper.NameFormatter.IDENTITY, null);
    assertFalse(config.getBuildConfiguration().isDockerFileMode());
    assertEquals(new File("dockerLoad.tar"), config.getBuildConfiguration().getDockerArchive());
}
Also used : BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) File(java.io.File) AbstractConfigHandlerTest(io.fabric8.maven.docker.config.handler.AbstractConfigHandlerTest)

Example 54 with ImageConfiguration

use of io.fabric8.maven.docker.config.ImageConfiguration in project docker-maven-plugin by fabric8io.

the class PropertyConfigHandlerTest method testNamingScheme.

@Test
public void testNamingScheme() throws Exception {
    String[] testData = new String[] { k(ConfigKey.NAME), "image", k(ConfigKey.NAMING_STRATEGY), RunImageConfiguration.NamingStrategy.alias.toString() };
    ImageConfiguration config = resolveExternalImageConfig(testData);
    assertEquals(RunImageConfiguration.NamingStrategy.alias, config.getRunConfiguration().getNamingStrategy());
}
Also used : BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) AbstractConfigHandlerTest(io.fabric8.maven.docker.config.handler.AbstractConfigHandlerTest)

Example 55 with ImageConfiguration

use of io.fabric8.maven.docker.config.ImageConfiguration in project docker-maven-plugin by fabric8io.

the class PropertyConfigHandlerTest method testMergedEnv.

@Test
public void testMergedEnv() throws Exception {
    List<ImageConfiguration> configs = resolveImage(imageConfiguration, props("docker.from", "baase", "docker.name", "demo", "docker.env.HOME", "/tmp", "docker.envBuild.HOME", "/var/tmp", "docker.envRun.root.dir", "/bla"));
    assertEquals(1, configs.size());
    ImageConfiguration calcConfig = configs.get(0);
    Map<String, String> env;
    env = calcConfig.getBuildConfiguration().getEnv();
    assertEquals(1, env.size());
    assertEquals("/var/tmp", env.get("HOME"));
    env = calcConfig.getRunConfiguration().getEnv();
    assertEquals(2, env.size());
    assertEquals("/tmp", env.get("HOME"));
    assertEquals("/bla", env.get("root.dir"));
}
Also used : BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) AbstractConfigHandlerTest(io.fabric8.maven.docker.config.handler.AbstractConfigHandlerTest)

Aggregations

BuildImageConfiguration (io.fabric8.maven.docker.config.BuildImageConfiguration)50 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)38 AbstractConfigHandlerTest (io.fabric8.maven.docker.config.handler.AbstractConfigHandlerTest)24 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)14 Test (org.junit.Test)13 ProcessorConfig (io.fabric8.maven.core.config.ProcessorConfig)10 File (java.io.File)9 IOException (java.io.IOException)9 DockerAccessException (io.fabric8.maven.docker.access.DockerAccessException)8 ArrayList (java.util.ArrayList)8 GeneratorContext (io.fabric8.maven.generator.api.GeneratorContext)7 MojoFailureException (org.apache.maven.plugin.MojoFailureException)7 Before (org.junit.Before)7 VolumeConfig (io.fabric8.maven.core.config.VolumeConfig)6 Fabric8ServiceException (io.fabric8.maven.core.service.Fabric8ServiceException)6 RunImageConfiguration (io.fabric8.maven.docker.config.RunImageConfiguration)5 Expectations (mockit.Expectations)5 KubernetesClientException (io.fabric8.kubernetes.client.KubernetesClientException)4 ExecException (io.fabric8.maven.docker.access.ExecException)4 WatchImageConfiguration (io.fabric8.maven.docker.config.WatchImageConfiguration)4