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);
}
}
}
}
}
}
}
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"));
}
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();
}
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);
}
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());
}
}
Aggregations