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