Search in sources :

Example 1 with RunImageConfiguration

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

the class LogOutputSpecFactory method extractLogConfiguration.

private LogConfiguration extractLogConfiguration(ImageConfiguration imageConfiguration) {
    RunImageConfiguration runConfig = imageConfiguration.getRunConfiguration();
    LogConfiguration logConfig = null;
    if (runConfig != null) {
        logConfig = runConfig.getLogConfiguration();
    }
    if (logConfig == null) {
        logConfig = LogConfiguration.DEFAULT;
    }
    return logConfig;
}
Also used : LogConfiguration(io.fabric8.maven.docker.config.LogConfiguration) RunImageConfiguration(io.fabric8.maven.docker.config.RunImageConfiguration)

Example 2 with RunImageConfiguration

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

the class AbstractConfigHandlerTest method validateRunConfiguration.

protected void validateRunConfiguration(RunImageConfiguration runConfig) {
    assertEquals(a("/foo", "/tmp:/tmp"), runConfig.getVolumeConfiguration().getBind());
    assertEquals(a("CAP"), runConfig.getCapAdd());
    assertEquals(a("CAP"), runConfig.getCapDrop());
    assertEquals("command.sh", runConfig.getCmd().getShell());
    assertEquals(a("8.8.8.8"), runConfig.getDns());
    assertEquals(a("example.com"), runConfig.getDnsSearch());
    assertEquals("domain.com", runConfig.getDomainname());
    assertEquals("entrypoint.sh", runConfig.getEntrypoint().getShell());
    assertEquals(a("localhost:127.0.0.1"), runConfig.getExtraHosts());
    assertEquals("subdomain", runConfig.getHostname());
    assertEquals(a("redis"), runConfig.getLinks());
    assertEquals((Long) 1L, runConfig.getMemory());
    assertEquals((Long) 1L, runConfig.getMemorySwap());
    assertEquals(getRunNamingStrategy(), runConfig.getNamingStrategy());
    assertEquals(getEnvPropertyFile(), runConfig.getEnvPropertyFile());
    assertEquals("/tmp/props.txt", runConfig.getPortPropertyFile());
    assertEquals(a("8081:8080"), runConfig.getPorts());
    assertEquals(true, runConfig.getPrivileged());
    assertEquals("tomcat", runConfig.getUser());
    assertEquals(a("from"), runConfig.getVolumeConfiguration().getFrom());
    assertEquals("foo", runConfig.getWorkingDir());
    validateEnv(runConfig.getEnv());
    // not sure it's worth it to implement 'equals/hashcode' for these
    RestartPolicy policy = runConfig.getRestartPolicy();
    assertEquals("on-failure", policy.getName());
    assertEquals(1, policy.getRetry());
}
Also used : RestartPolicy(io.fabric8.maven.docker.config.RestartPolicy)

Example 3 with RunImageConfiguration

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

the class PropertyConfigHandlerTest method testPorts.

@Test
public void testPorts() {
    List<ImageConfiguration> configs = resolveImage(imageConfiguration, props("docker.name", "demo", "docker.ports.1", "jolokia.port:8080", "docker.ports.2", "9090", "docker.ports.3", "0.0.0.0:80:80", "docker.from", "busybox"));
    assertEquals(1, configs.size());
    RunImageConfiguration runConfig = configs.get(0).getRunConfiguration();
    List<String> portsAsList = runConfig.getPorts();
    String[] ports = new ArrayList<>(portsAsList).toArray(new String[portsAsList.size()]);
    assertArrayEquals(new String[] { "jolokia.port:8080", "9090", "0.0.0.0:80:80" }, ports);
    BuildImageConfiguration buildConfig = configs.get(0).getBuildConfiguration();
    ports = new ArrayList<>(buildConfig.getPorts()).toArray(new String[buildConfig.getPorts().size()]);
    assertArrayEquals(new String[] { "8080", "9090", "80" }, ports);
}
Also used : BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) AbstractConfigHandlerTest(io.fabric8.maven.docker.config.handler.AbstractConfigHandlerTest)

Example 4 with RunImageConfiguration

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

the class LogOutputSpecFactoryTest method createSpec.

private LogOutputSpec createSpec(String prefix) {
    LogOutputSpecFactory factory = new LogOutputSpecFactory(false, false, null);
    LogConfiguration logConfig = new LogConfiguration.Builder().prefix(prefix).build();
    RunImageConfiguration runConfig = new RunImageConfiguration.Builder().log(logConfig).build();
    ImageConfiguration imageConfiguration = new ImageConfiguration.Builder().alias(ALIAS).name(NAME).runConfig(runConfig).build();
    return factory.createSpec(CONTAINER_ID, imageConfiguration);
}
Also used : ImageConfiguration(io.fabric8.maven.docker.config.ImageConfiguration) RunImageConfiguration(io.fabric8.maven.docker.config.RunImageConfiguration) LogConfiguration(io.fabric8.maven.docker.config.LogConfiguration) RunImageConfiguration(io.fabric8.maven.docker.config.RunImageConfiguration)

Example 5 with RunImageConfiguration

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

the class PropertyConfigHandlerTest method testPortsFromConfigAndProperties.

@Test
public void testPortsFromConfigAndProperties() {
    imageConfiguration = new ImageConfiguration.Builder().externalConfig(new HashMap<String, String>()).buildConfig(new BuildImageConfiguration.Builder().ports(Arrays.asList("1234")).build()).runConfig(new RunImageConfiguration.Builder().ports(Arrays.asList("jolokia.port:1234")).build()).build();
    makeExternalConfigUse(PropertyMode.Override);
    List<ImageConfiguration> configs = resolveImage(imageConfiguration, props("docker.name", "demo", "docker.ports.1", "9090", "docker.ports.2", "0.0.0.0:80:80", "docker.from", "busybox"));
    assertEquals(1, configs.size());
    RunImageConfiguration runConfig = configs.get(0).getRunConfiguration();
    List<String> portsAsList = runConfig.getPorts();
    String[] ports = new ArrayList<>(portsAsList).toArray(new String[portsAsList.size()]);
    assertArrayEquals(new String[] { "9090", "0.0.0.0:80:80", "jolokia.port:1234" }, ports);
    BuildImageConfiguration buildConfig = configs.get(0).getBuildConfiguration();
    ports = new ArrayList<>(buildConfig.getPorts()).toArray(new String[buildConfig.getPorts().size()]);
    assertArrayEquals(new String[] { "9090", "80", "1234" }, ports);
}
Also used : BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) AbstractConfigHandlerTest(io.fabric8.maven.docker.config.handler.AbstractConfigHandlerTest)

Aggregations

BuildImageConfiguration (io.fabric8.maven.docker.config.BuildImageConfiguration)2 LogConfiguration (io.fabric8.maven.docker.config.LogConfiguration)2 RestartPolicy (io.fabric8.maven.docker.config.RestartPolicy)2 RunImageConfiguration (io.fabric8.maven.docker.config.RunImageConfiguration)2 AbstractConfigHandlerTest (io.fabric8.maven.docker.config.handler.AbstractConfigHandlerTest)2 DockerAccessException (io.fabric8.maven.docker.access.DockerAccessException)1 ExecException (io.fabric8.maven.docker.access.ExecException)1 PortMapping (io.fabric8.maven.docker.access.PortMapping)1 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)1 LogDispatcher (io.fabric8.maven.docker.log.LogDispatcher)1 IOException (java.io.IOException)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1