Search in sources :

Example 21 with BuildImageConfiguration

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

the class BaseGeneratorTest method defaultAddFrom.

@Test
public void defaultAddFrom() {
    Properties props = new Properties();
    for (boolean isOpenShift : new Boolean[] { false, true }) {
        for (boolean isRedHat : new Boolean[] { false, true }) {
            for (TestFromSelector selector : new TestFromSelector[] { null, new TestFromSelector(ctx, isRedHat) }) {
                for (String from : new String[] { null, "openshift/testfrom" }) {
                    setupContext(props, isOpenShift, from, null);
                    BuildImageConfiguration.Builder builder = new BuildImageConfiguration.Builder();
                    BaseGenerator generator = createGenerator(selector);
                    generator.addFrom(builder);
                    BuildImageConfiguration config = builder.build();
                    if (isRedHat && isOpenShift && selector != null) {
                        if (from != null) {
                            assertEquals("testfrom:latest", config.getFrom());
                            assertFromExt(config.getFromExt(), "testfrom:latest", "openshift");
                        } else {
                            assertEquals("selectorIstagFromRedhat", config.getFrom());
                            assertFromExt(config.getFromExt(), selector.getIstagFrom(), "openshift");
                        }
                    } else {
                        if (from != null) {
                            assertEquals(config.getFrom(), from);
                            assertNull(config.getFromExt());
                        } else {
                            System.out.println(isRedHat + " " + isOpenShift);
                            assertNull(config.getFromExt());
                            assertEquals(config.getFrom(), selector != null ? (isOpenShift ? selector.getS2iBuildFrom() : selector.getDockerBuildFrom()) : null);
                        }
                    }
                }
            }
        }
    }
}
Also used : Properties(java.util.Properties) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) Test(org.junit.Test)

Example 22 with BuildImageConfiguration

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

the class BaseGeneratorTest method addLatestTagIfSnapshot.

@Test
public void addLatestTagIfSnapshot() {
    new Expectations() {

        {
            ctx.getProject();
            result = project;
            project.getVersion();
            result = "1.2-SNAPSHOT";
        }
    };
    BuildImageConfiguration.Builder builder = new BuildImageConfiguration.Builder();
    BaseGenerator generator = createGenerator(null);
    generator.addLatestTagIfSnapshot(builder);
    ;
    BuildImageConfiguration config = builder.build();
    List<String> tags = config.getTags();
    assertEquals(1, tags.size());
    assertTrue(tags.get(0).endsWith("latest"));
}
Also used : Expectations(mockit.Expectations) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) Test(org.junit.Test)

Example 23 with BuildImageConfiguration

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

the class BuildServiceTest method givenAnImageConfiguration.

private void givenAnImageConfiguration(Boolean cleanup) {
    BuildImageConfiguration buildConfig = new BuildImageConfiguration.Builder().cleanup(cleanup.toString()).build();
    imageConfig = new ImageConfiguration.Builder().name("build-image").alias("build-alias").buildConfig(buildConfig).build();
}
Also used : BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) ImageConfiguration(io.fabric8.maven.docker.config.ImageConfiguration) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration)

Example 24 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)

Example 25 with BuildImageConfiguration

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

the class DockerAssemblyManager method getAssemblyFiles.

/**
 * Extract all files with a tracking archiver. These can be used to track changes in the filesystem and triggering
 * a rebuild of the image if needed ('docker:watch')
 */
public AssemblyFiles getAssemblyFiles(String name, BuildImageConfiguration buildConfig, MojoParameters mojoParams, Logger log) throws InvalidAssemblerConfigurationException, ArchiveCreationException, AssemblyFormattingException, MojoExecutionException {
    BuildDirs buildDirs = createBuildDirs(name, mojoParams);
    AssemblyConfiguration assemblyConfig = buildConfig.getAssemblyConfiguration();
    String assemblyName = assemblyConfig.getName();
    DockerAssemblyConfigurationSource source = new DockerAssemblyConfigurationSource(mojoParams, buildDirs, assemblyConfig);
    Assembly assembly = getAssemblyConfig(assemblyConfig, source);
    synchronized (trackArchiver) {
        MappingTrackArchiver ta = (MappingTrackArchiver) trackArchiver;
        ta.init(log, assemblyName);
        assembly.setId("tracker");
        assemblyArchiver.createArchive(assembly, assemblyName, "track", source, false);
        return ta.getAssemblyFiles(mojoParams.getSession());
    }
}
Also used : AssemblyConfiguration(io.fabric8.maven.docker.config.AssemblyConfiguration) Assembly(org.apache.maven.plugin.assembly.model.Assembly)

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