Search in sources :

Example 6 with BuildImageConfiguration

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

the class DockerAssemblyManagerTest method assemblyFiles.

@Test
public void assemblyFiles(@Injectable final MojoParameters mojoParams, @Injectable final MavenProject project, @Injectable final Assembly assembly) throws AssemblyFormattingException, ArchiveCreationException, InvalidAssemblerConfigurationException, MojoExecutionException, AssemblyReadException, IllegalAccessException {
    ReflectionUtils.setVariableValueInObject(assemblyManager, "trackArchiver", trackArchiver);
    new Expectations() {

        {
            mojoParams.getOutputDirectory();
            result = "target/";
            times = 3;
            mojoParams.getProject();
            project.getBasedir();
            result = ".";
            assemblyReader.readAssemblies((AssemblerConfigurationSource) any);
            result = Arrays.asList(assembly);
        }
    };
    BuildImageConfiguration buildConfig = createBuildConfig();
    assemblyManager.getAssemblyFiles("testImage", buildConfig, mojoParams, new AnsiLogger(new SystemStreamLog(), true, true));
}
Also used : Expectations(mockit.Expectations) SystemStreamLog(org.apache.maven.plugin.logging.SystemStreamLog) AnsiLogger(io.fabric8.maven.docker.util.AnsiLogger) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) Test(org.junit.Test)

Example 7 with BuildImageConfiguration

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

the class DockerAssemblyManagerTest method testCopyChownValidVerifyGivenDockerfile.

@Test
public void testCopyChownValidVerifyGivenDockerfile(@Injectable final Logger logger) throws IOException {
    BuildImageConfiguration buildConfig = createBuildConfig();
    assemblyManager.verifyGivenDockerfile(new File(getClass().getResource("/docker/Dockerfile_assembly_verify_copy_chown_valid.test").getPath()), buildConfig, createInterpolator(buildConfig), logger);
    new Verifications() {

        {
            logger.warn(anyString, (Object[]) any);
            times = 0;
        }
    };
}
Also used : Verifications(mockit.Verifications) File(java.io.File) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) Test(org.junit.Test)

Example 8 with BuildImageConfiguration

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

the class PropertyConfigHandlerTest method testRunCommandsFromPropertiesAndConfig.

@Test
public void testRunCommandsFromPropertiesAndConfig() {
    imageConfiguration = new ImageConfiguration.Builder().externalConfig(new HashMap<String, String>()).buildConfig(new BuildImageConfiguration.Builder().runCmds(Arrays.asList("some", "ignored", "value")).build()).build();
    makeExternalConfigUse(PropertyMode.Override);
    List<ImageConfiguration> configs = resolveImage(imageConfiguration, props("docker.from", "base", "docker.name", "demo", "docker.run.1", "propconf", "docker.run.2", "withrun", "docker.run.3", "used"));
    assertEquals(1, configs.size());
    BuildImageConfiguration buildConfig = configs.get(0).getBuildConfiguration();
    String[] runCommands = new ArrayList<>(buildConfig.getRunCmds()).toArray(new String[buildConfig.getRunCmds().size()]);
    assertArrayEquals(new String[] { "propconf", "withrun", "used" }, runCommands);
}
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 9 with BuildImageConfiguration

use of io.fabric8.maven.docker.config.BuildImageConfiguration 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 10 with BuildImageConfiguration

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

the class PropertyConfigHandlerTest method testRunCommandsFromConfigAndProperties.

@Test
public void testRunCommandsFromConfigAndProperties() {
    imageConfiguration = new ImageConfiguration.Builder().externalConfig(new HashMap<String, String>()).buildConfig(new BuildImageConfiguration.Builder().runCmds(Arrays.asList("some", "configured", "value")).build()).build();
    makeExternalConfigUse(PropertyMode.Fallback);
    List<ImageConfiguration> configs = resolveImage(imageConfiguration, props("docker.from", "base", "docker.name", "demo", "docker.run.1", "this", "docker.run.2", "is", "docker.run.3", "ignored"));
    assertEquals(1, configs.size());
    BuildImageConfiguration buildConfig = configs.get(0).getBuildConfiguration();
    String[] runCommands = new ArrayList<>(buildConfig.getRunCmds()).toArray(new String[buildConfig.getRunCmds().size()]);
    assertArrayEquals(new String[] { "some", "configured", "value" }, runCommands);
}
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)36 Test (org.junit.Test)16 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)15 Before (org.junit.Before)7 VolumeConfig (io.fabric8.maven.core.config.VolumeConfig)6 File (java.io.File)6 AssemblyConfiguration (io.fabric8.maven.docker.config.AssemblyConfiguration)5 AbstractConfigHandlerTest (io.fabric8.maven.docker.config.handler.AbstractConfigHandlerTest)5 Expectations (mockit.Expectations)5 Properties (java.util.Properties)4 ProcessorConfig (io.fabric8.maven.core.config.ProcessorConfig)3 ArrayList (java.util.ArrayList)3 TreeMap (java.util.TreeMap)3 Verifications (mockit.Verifications)3 ContainerPort (io.fabric8.kubernetes.api.model.ContainerPort)1 KubernetesList (io.fabric8.kubernetes.api.model.KubernetesList)1 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)1 AuthConfig (io.fabric8.maven.docker.access.AuthConfig)1 BuildOptions (io.fabric8.maven.docker.access.BuildOptions)1 DockerAccessException (io.fabric8.maven.docker.access.DockerAccessException)1