use of io.fabric8.maven.docker.config.BuildImageConfiguration in project fabric8-maven-plugin by fabric8io.
the class ContainerHandlerTest method getContainersWithAliasTest.
@Test
public void getContainersWithAliasTest() {
project.setArtifactId("test-artifact");
project.setGroupId("test-group");
ports.add("8080");
ports.add("9090");
tags.add("latest");
tags.add("test");
ContainerHandler handler = new ContainerHandler(project, envVarHandler, probeHandler);
// container name with alias
BuildImageConfiguration buildImageConfiguration = new BuildImageConfiguration.Builder().ports(ports).from("fabric8/maven:latest").cleanup("try").tags(tags).compression("gzip").build();
ImageConfiguration imageConfiguration = new ImageConfiguration.Builder().name("test").alias("test-app").buildConfig(buildImageConfiguration).registry("docker.io").build();
images.clear();
images.add(imageConfiguration);
containers = handler.getContainers(config, images);
assertNotNull(containers);
assertEquals("test-app", containers.get(0).getName());
assertEquals("docker.io/test", containers.get(0).getImage());
assertEquals("IfNotPresent", containers.get(0).getImagePullPolicy());
}
use of io.fabric8.maven.docker.config.BuildImageConfiguration in project fabric8-maven-plugin by fabric8io.
the class DeploymentHandlerTest method before.
@Before
public void before() {
// volume config with name and multiple mount
mounts.add("/path/system");
mounts.add("/path/sys");
ports.add("8080");
ports.add("9090");
tags.add("latest");
tags.add("test");
VolumeConfig volumeConfig1 = new VolumeConfig.Builder().name("test").mounts(mounts).type("hostPath").path("/test/path").build();
volumes1.add(volumeConfig1);
// container name with alias
BuildImageConfiguration buildImageConfiguration = new BuildImageConfiguration.Builder().ports(ports).from("fabric8/maven:latest").cleanup("try").tags(tags).compression("gzip").build();
ImageConfiguration imageConfiguration = new ImageConfiguration.Builder().name("test").alias("test-app").buildConfig(buildImageConfiguration).registry("docker.io").build();
images.add(imageConfiguration);
}
use of io.fabric8.maven.docker.config.BuildImageConfiguration in project fabric8-maven-plugin by fabric8io.
the class ContainerHandler method getContainerPorts.
private List<ContainerPort> getContainerPorts(ImageConfiguration imageConfig) {
BuildImageConfiguration buildConfig = imageConfig.getBuildConfiguration();
List<String> ports = buildConfig.getPorts();
if (!ports.isEmpty()) {
List<ContainerPort> ret = new ArrayList<>();
PortMapping portMapping = new PortMapping(ports, project.getProperties());
JSONArray portSpecs = portMapping.toJson();
for (int i = 0; i < portSpecs.length(); i++) {
JSONObject portSpec = portSpecs.getJSONObject(i);
ret.add(extractContainerPort(portSpec));
}
return ret;
} else {
return null;
}
}
use of io.fabric8.maven.docker.config.BuildImageConfiguration in project fabric8-maven-plugin by fabric8io.
the class PrometheusEnricherTest method testDetectPrometheusPort.
@Test
public void testDetectPrometheusPort() throws Exception {
final ProcessorConfig config = new ProcessorConfig(null, null, Collections.singletonMap(PrometheusEnricher.ENRICHER_NAME, new TreeMap()));
final BuildImageConfiguration imageConfig = new BuildImageConfiguration.Builder().ports(Arrays.asList(PrometheusEnricher.PROMETHEUS_PORT)).build();
// Setup mock behaviour
new Expectations() {
{
context.getConfig();
result = config;
imageConfiguration.getBuildConfiguration();
result = imageConfig;
context.getImages();
result = Arrays.asList(imageConfiguration);
}
};
PrometheusEnricher enricher = new PrometheusEnricher(context);
Map<String, String> annotations = enricher.getAnnotations(Kind.SERVICE);
assertEquals(2, annotations.size());
assertEquals("9779", annotations.get(Annotations.Management.PROMETHEUS_PORT));
assertEquals("true", annotations.get(Annotations.Management.PROMETHEUS_SCRAPE));
}
use of io.fabric8.maven.docker.config.BuildImageConfiguration in project docker-maven-plugin by fabric8io.
the class DockerAssemblyManagerTest method testArchiveCreationDockerfileWithArchiveAssembly.
@Test
public void testArchiveCreationDockerfileWithArchiveAssembly(@Injectable final TarArchiver tarArchiver, @Injectable final Logger logger) throws MojoExecutionException, NoSuchArchiverException {
MojoParameters mojoParams = mockMojoParams(mockMavenProject());
BuildImageConfiguration buildImageConfiguration = new BuildImageConfiguration.Builder().dockerFile(DockerAssemblyManagerTest.class.getResource("/docker/Dockerfile.test").getPath()).assembly(new AssemblyConfiguration.Builder().mode(AssemblyMode.tar.name()).assemblyDef(new Assembly()).build()).build();
buildImageConfiguration.initAndValidate(logger);
File tarArchive = assemblyManager.createDockerTarArchive("test_image", mojoParams, buildImageConfiguration, logger, null);
assertNotNull(tarArchive);
new Verifications() {
{
archiverManager.getArchiver("tar");
times = 1;
List<FileSet> fileSets = new ArrayList<>();
tarArchiver.addFileSet(withCapture(fileSets));
assertEquals(1, fileSets.size());
assertArrayEquals(new String[] { "target/**", "Dockerfile.test" }, fileSets.get(0).getExcludes());
assertNull(fileSets.get(0).getIncludes());
tarArchiver.addFile(new File("target/test_image/build/Dockerfile.test"), "Dockerfile.test");
List<ArchivedFileSet> archivedFileSets = new ArrayList<>();
tarArchiver.addArchivedFileSet(withCapture(archivedFileSets));
assertEquals(1, archivedFileSets.size());
assertEquals(new File("target/test_image/build/maven.tar"), archivedFileSets.get(0).getArchive());
assertEquals("maven/", archivedFileSets.get(0).getPrefix());
}
};
}
Aggregations