Search in sources :

Example 71 with BuildImageConfiguration

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

the class BuildServiceTest method testBuildImageWithCacheFrom_ShouldPullImage.

@Test
public void testBuildImageWithCacheFrom_ShouldPullImage() throws Exception {
    BuildImageConfiguration buildConfig = new BuildImageConfiguration.Builder().cleanup("false").cacheFrom("fabric8/s1i-java").dockerFile(DockerFileUtilTest.class.getResource("Dockerfile_from_simple").getPath()).filter("false").build();
    buildConfig.initAndValidate(logger);
    imageConfig = new ImageConfiguration.Builder().name("build-image").alias("build-alias").buildConfig(buildConfig).build();
    final ImagePullManager pullManager = new ImagePullManager(null, null, null);
    final BuildService.BuildContext buildContext = new BuildService.BuildContext.Builder().mojoParameters(mojoParameters).build();
    new Expectations(mojoParameters) {

        {
            mojoParameters.getProject();
            result = mavenProject;
            mavenProject.getProperties();
            result = new Properties();
        }
    };
    File buildArchive = buildService.buildArchive(imageConfig, buildContext, "");
    buildService.buildImage(imageConfig, pullManager, buildContext, buildArchive);
    // verify that tries to pull both images
    new Verifications() {

        {
            registryService.pullImageWithPolicy("fabric8/s2i-java", pullManager, buildContext.getRegistryConfig(), buildConfig);
            registryService.pullImageWithPolicy("fabric8/s1i-java", pullManager, buildContext.getRegistryConfig(), buildConfig);
        }
    };
}
Also used : Expectations(mockit.Expectations) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) ImageConfiguration(io.fabric8.maven.docker.config.ImageConfiguration) Properties(java.util.Properties) FullVerifications(mockit.FullVerifications) Verifications(mockit.Verifications) File(java.io.File) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) DockerFileUtilTest(io.fabric8.maven.docker.util.DockerFileUtilTest) Test(org.junit.Test)

Example 72 with BuildImageConfiguration

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

the class PropertyConfigHandlerTest method validateBuildConfiguration.

private void validateBuildConfiguration(BuildImageConfiguration buildConfig) {
    assertEquals(CleanupMode.TRY_TO_REMOVE, buildConfig.cleanupMode());
    assertEquals("command.sh", buildConfig.getCmd().getShell());
    assertEquals("image", buildConfig.getFrom());
    assertEquals("image-ext", buildConfig.getFromExt().get("name"));
    assertEquals(a("8080"), buildConfig.getPorts());
    assertEquals("registry", buildConfig.getRegistry());
    assertEquals(a("/foo"), buildConfig.getVolumes());
    assertEquals("fabric8io@redhat.com", buildConfig.getMaintainer());
    assertEquals(false, buildConfig.noCache());
    assertEquals("Always", buildConfig.getImagePullPolicy());
    validateEnv(buildConfig.getEnv());
    validateLabels(buildConfig.getLabels());
    validateArgs(buildConfig.getArgs());
    validateBuildOptions(buildConfig.getBuildOptions());
    /*
         * validate only the descriptor is required and defaults are all used, 'testAssembly' validates
         * all options can be set
         */
    List<AssemblyConfiguration> assemblyConfigurations = buildConfig.getAssemblyConfigurations();
    assertEquals(1, assemblyConfigurations.size());
    AssemblyConfiguration assemblyConfig = assemblyConfigurations.get(0);
    assertEquals("/maven", assemblyConfig.getTargetDir());
    assertEquals("assembly.xml", assemblyConfig.getDescriptor());
    assertNull(assemblyConfig.getUser());
    assertNull(assemblyConfig.exportTargetDir());
    assertFalse(assemblyConfig.isIgnorePermissions());
}
Also used : AssemblyConfiguration(io.fabric8.maven.docker.config.AssemblyConfiguration)

Example 73 with BuildImageConfiguration

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

the class PropertyConfigHandlerTest method testEntrypointExecFromConfig.

@Test
public void testEntrypointExecFromConfig() {
    imageConfiguration = new ImageConfiguration.Builder().externalConfig(externalConfigMode(PropertyMode.Fallback)).buildConfig(new BuildImageConfiguration.Builder().entryPoint(new Arguments(Arrays.asList("/entrypoint.sh", "--from-property"))).cacheFrom((Arrays.asList("foo/bar:latest"))).build()).build();
    List<ImageConfiguration> configs = resolveImage(imageConfiguration, props("docker.from", "base", "docker.name", "demo"));
    assertEquals(1, configs.size());
    BuildImageConfiguration buildConfig = configs.get(0).getBuildConfiguration();
    assertArrayEquals(new String[] { "/entrypoint.sh", "--from-property" }, buildConfig.getEntryPoint().asStrings().toArray());
}
Also used : BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) ImageConfiguration(io.fabric8.maven.docker.config.ImageConfiguration) RunImageConfiguration(io.fabric8.maven.docker.config.RunImageConfiguration) Arguments(io.fabric8.maven.docker.config.Arguments) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) AbstractConfigHandlerTest(io.fabric8.maven.docker.config.handler.AbstractConfigHandlerTest) Test(org.junit.Test)

Example 74 with BuildImageConfiguration

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

the class PropertyConfigHandlerTest method testRunCommands.

@Test
public void testRunCommands() {
    List<ImageConfiguration> configs = resolveImage(imageConfiguration, props("docker.from", "base", "docker.name", "demo", "docker.run.1", "foo", "docker.run.2", "bar", "docker.run.3", "wibble"));
    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[] { "foo", "bar", "wibble" }, runCommands);
}
Also used : BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) ImageConfiguration(io.fabric8.maven.docker.config.ImageConfiguration) RunImageConfiguration(io.fabric8.maven.docker.config.RunImageConfiguration) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) AbstractConfigHandlerTest(io.fabric8.maven.docker.config.handler.AbstractConfigHandlerTest) Test(org.junit.Test)

Example 75 with BuildImageConfiguration

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

the class LoadImageTest method givenAnImageConfiguration.

private void givenAnImageConfiguration() {
    BuildImageConfiguration buildConfig = new BuildImageConfiguration.Builder().dockerArchive("test.tar").build();
    imageConfig = new ImageConfiguration.Builder().name("build-image").alias("build-alias").buildConfig(buildConfig).build();
    imageConfig.initAndValidate(ConfigHelper.NameFormatter.IDENTITY, log);
}
Also used : BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) ImageConfiguration(io.fabric8.maven.docker.config.ImageConfiguration) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration)

Aggregations

BuildImageConfiguration (io.fabric8.maven.docker.config.BuildImageConfiguration)68 Test (org.junit.Test)40 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)34 File (java.io.File)19 Verifications (mockit.Verifications)15 RunImageConfiguration (io.fabric8.maven.docker.config.RunImageConfiguration)12 ArrayList (java.util.ArrayList)11 AssemblyConfiguration (io.fabric8.maven.docker.config.AssemblyConfiguration)10 AbstractConfigHandlerTest (io.fabric8.maven.docker.config.handler.AbstractConfigHandlerTest)10 Expectations (mockit.Expectations)9 MojoParameters (io.fabric8.maven.docker.util.MojoParameters)8 Properties (java.util.Properties)7 Before (org.junit.Before)7 VolumeConfig (io.fabric8.maven.core.config.VolumeConfig)6 ArchivedFileSet (org.codehaus.plexus.archiver.ArchivedFileSet)6 Assembly (org.apache.maven.plugins.assembly.model.Assembly)5 Arguments (io.fabric8.maven.docker.config.Arguments)4 CleanupMode (io.fabric8.maven.docker.config.CleanupMode)4 FileSet (org.codehaus.plexus.archiver.FileSet)4 ProcessorConfig (io.fabric8.maven.core.config.ProcessorConfig)3