use of io.fabric8.maven.docker.config.BuildImageConfiguration in project fabric8-maven-plugin by fabric8io.
the class ContainerHandlerTest method containerPortsWithoutPortTest.
@Test
public void containerPortsWithoutPortTest() {
ContainerHandler handler = new ContainerHandler(project, envVarHandler, probeHandler);
// without Ports
BuildImageConfiguration buildImageConfiguration2 = new BuildImageConfiguration.Builder().from("fabric8/maven:latest").cleanup("try").compression("gzip").build();
ImageConfiguration imageConfiguration2 = new ImageConfiguration.Builder().name("test").alias("test-app").buildConfig(buildImageConfiguration2).registry("docker.io").build();
images.clear();
images.add(imageConfiguration2);
containers = handler.getContainers(config, images);
assertTrue(containers.get(0).getPorts().isEmpty());
}
use of io.fabric8.maven.docker.config.BuildImageConfiguration in project fabric8-maven-plugin by fabric8io.
the class ContainerHandlerTest method getContainerWithGroupArtifactTest.
@Test
public void getContainerWithGroupArtifactTest() {
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 group id and aritact id without alias and user
BuildImageConfiguration buildImageConfiguration = new BuildImageConfiguration.Builder().ports(ports).from("fabric8/").cleanup("try").tags(tags).compression("gzip").dockerFile("testFile").dockerFileDir("/demo").build();
ImageConfiguration imageConfiguration = new ImageConfiguration.Builder().name("test").buildConfig(buildImageConfiguration).registry("docker.io").build();
images.clear();
images.add(imageConfiguration);
containers = handler.getContainers(config, images);
assertNotNull(containers);
assertEquals("test-group-test-artifact", 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 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;
}
}
Aggregations