use of io.fabric8.docker.client.Config in project fabric8-maven-plugin by fabric8io.
the class OpenshiftBuildService method build.
@Override
public void build(ImageConfiguration imageConfig) throws Fabric8ServiceException {
try {
ImageName imageName = new ImageName(imageConfig.getName());
File dockerTar = createBuildArchive(imageConfig);
KubernetesListBuilder builder = new KubernetesListBuilder();
// Check for buildconfig / imagestream and create them if necessary
String buildName = updateOrCreateBuildConfig(config, client, builder, imageConfig);
checkOrCreateImageStream(config, client, builder, getImageStreamName(imageName));
applyResourceObjects(config, client, builder);
// Start the actual build
Build build = startBuild(client, dockerTar, buildName);
// Wait until the build finishes
waitForOpenShiftBuildToComplete(client, build);
// Create a file with generated image streams
addImageStreamToFile(getImageStreamFile(config), imageName, client);
} catch (Fabric8ServiceException e) {
throw e;
} catch (Exception ex) {
throw new Fabric8ServiceException("Unable to build the image using the OpenShift build service", ex);
}
}
use of io.fabric8.docker.client.Config in project fabric8-maven-plugin by fabric8io.
the class ContainerHandlerTest method getVolumeMountWithoutMountTest.
@Test
public void getVolumeMountWithoutMountTest() {
ContainerHandler handler = new ContainerHandler(project, envVarHandler, probeHandler);
images.clear();
images.add(imageConfiguration1);
// volume config without mount
VolumeConfig volumeConfig1 = new VolumeConfig.Builder().name("first").build();
volumes1.add(volumeConfig1);
ResourceConfig config1 = new ResourceConfig.Builder().volumes(volumes1).build();
containers = handler.getContainers(config1, images);
assertTrue(containers.get(0).getVolumeMounts().isEmpty());
}
use of io.fabric8.docker.client.Config in project fabric8-maven-plugin by fabric8io.
the class ContainerHandlerTest method getContainerTestWithUser.
@Test
public void getContainerTestWithUser() {
project.setArtifactId("test-artifact");
project.setGroupId("test-group");
ports.add("8080");
ports.add("9090");
tags.add("latest");
tags.add("test");
// container name with user and image with tag
ContainerHandler handler = new ContainerHandler(project, envVarHandler, probeHandler);
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("user/test:latest").buildConfig(buildImageConfiguration).registry("docker.io").build();
images.clear();
images.add(imageConfiguration);
containers = handler.getContainers(config, images);
assertNotNull(containers);
assertEquals("user-test-artifact", containers.get(0).getName());
assertEquals("docker.io/user/test:latest", containers.get(0).getImage());
assertEquals("IfNotPresent", containers.get(0).getImagePullPolicy());
}
use of io.fabric8.docker.client.Config in project fabric8-maven-plugin by fabric8io.
the class ContainerHandlerTest method getVolumeMountWithMultipleMountTest.
@Test
public void getVolumeMountWithMultipleMountTest() {
ContainerHandler handler = new ContainerHandler(project, envVarHandler, probeHandler);
images.clear();
images.add(imageConfiguration1);
List<String> mounts = new ArrayList<>();
mounts.add("/path/etc");
// volume config with name and multiple mount
mounts.add("/path/system");
mounts.add("/path/sys");
VolumeConfig volumeConfig4 = new VolumeConfig.Builder().name("test").mounts(mounts).build();
volumes1.clear();
volumes1.add(volumeConfig4);
ResourceConfig config4 = new ResourceConfig.Builder().volumes(volumes1).build();
containers = handler.getContainers(config4, images);
assertEquals(3, containers.get(0).getVolumeMounts().size());
for (int i = 0; i <= 2; i++) assertEquals("test", containers.get(0).getVolumeMounts().get(i).getName());
}
use of io.fabric8.docker.client.Config in project fabric8-maven-plugin by fabric8io.
the class DaemonSetHandlerTest method daemonTemplateHandlerWithoutControllerTest.
@Test(expected = IllegalArgumentException.class)
public void daemonTemplateHandlerWithoutControllerTest() {
// without controller name
ContainerHandler containerHandler = new ContainerHandler(project, envVarHandler, probeHandler);
PodTemplateHandler podTemplateHandler = new PodTemplateHandler(containerHandler);
DaemonSetHandler daemonSetHandler = new DaemonSetHandler(podTemplateHandler);
// without controller name
ResourceConfig config = new ResourceConfig.Builder().imagePullPolicy("IfNotPresent").withServiceAccount("test-account").volumes(volumes1).build();
daemonSetHandler.getDaemonSet(config, images);
}
Aggregations