use of io.fabric8.maven.docker.config.ImageConfiguration in project docker-maven-plugin by fabric8io.
the class ContainerTrackerTest method registerAtTracker.
private List<ContainerTracker.ContainerShutdownDescriptor> registerAtTracker(String[][] data) {
List<ContainerTracker.ContainerShutdownDescriptor> descriptors = new ArrayList<>();
for (String[] d : data) {
ImageConfiguration imageConfig = getImageConfiguration(d[1], d[2], parseInt(d[3]), parseInt(d[4]), d[5], Boolean.parseBoolean(d[7]));
tracker.registerContainer(d[0], imageConfig, getPomLabel(d[6]));
descriptors.add(new ContainerTracker.ContainerShutdownDescriptor(imageConfig, d[0]));
}
return descriptors;
}
use of io.fabric8.maven.docker.config.ImageConfiguration in project docker-maven-plugin by fabric8io.
the class BuildMojo method executeInternal.
@Override
protected void executeInternal(ServiceHub hub) throws DockerAccessException, MojoExecutionException {
if (skipBuild) {
return;
}
List<ImageConfiguration> resolvedImages = getResolvedImages();
if (resolvedImages.isEmpty()) {
// No Configuration found, so build one up dynamically.
if (imageName == null) {
/*
* Image name defaults to:
* `${project.groupId}/${project.artifactId}:${project.version}`
*/
imageName = project.getGroupId() + "/" + project.getArtifactId() + ":" + project.getVersion();
}
ImageConfiguration aDefaultImageConfig = ImageConfiguration.getDefaultImageConfiguration(imageName, project.getBasedir().getAbsolutePath());
processImageConfig(hub, aDefaultImageConfig);
return;
} else {
// Iterate over all the ImageConfigurations and process one by one
for (ImageConfiguration imageConfig : resolvedImages) {
processImageConfig(hub, imageConfig);
}
}
}
use of io.fabric8.maven.docker.config.ImageConfiguration in project docker-maven-plugin by fabric8io.
the class StopMojo method getNetworksToRemove.
private Set<Network> getNetworksToRemove(QueryService queryService, PomLabel pomLabel) throws DockerAccessException {
if (!autoCreateCustomNetworks) {
return Collections.emptySet();
}
Set<Network> customNetworks = new HashSet<>();
Set<Network> networks = queryService.getNetworks();
for (ImageConfiguration image : getResolvedImages()) {
final NetworkConfig config = image.getRunConfiguration().getNetworkingConfig();
if (config.isCustomNetwork()) {
Network network = getNetworkByName(networks, config.getCustomNetwork());
if (network != null) {
customNetworks.add(network);
for (Container container : getContainersToStop(queryService, image)) {
if (!shouldStopContainer(container, pomLabel, image)) {
// it's sill in use don't collect it
customNetworks.remove(network);
}
}
}
}
}
return customNetworks;
}
use of io.fabric8.maven.docker.config.ImageConfiguration in project docker-maven-plugin by fabric8io.
the class PropertyConfigHandlerTest method testNoCleanup.
@Test
public void testNoCleanup() throws Exception {
String[] testData = new String[] { k(ConfigKey.NAME), "image", k(ConfigKey.CLEANUP), "none", k(ConfigKey.FROM), "base" };
ImageConfiguration config = resolveExternalImageConfig(testData);
assertEquals(CleanupMode.NONE, config.getBuildConfiguration().cleanupMode());
}
use of io.fabric8.maven.docker.config.ImageConfiguration in project docker-maven-plugin by fabric8io.
the class PropertyConfigHandlerTest method testRunCommandsFromConfigAndProperties.
@Test
public void testRunCommandsFromConfigAndProperties() {
imageConfiguration = new ImageConfiguration.Builder().externalConfig(new HashMap<String, String>()).buildConfig(new BuildImageConfiguration.Builder().runCmds(Arrays.asList("some", "configured", "value")).build()).build();
makeExternalConfigUse(PropertyMode.Fallback);
List<ImageConfiguration> configs = resolveImage(imageConfiguration, props("docker.from", "base", "docker.name", "demo", "docker.run.1", "this", "docker.run.2", "is", "docker.run.3", "ignored"));
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[] { "some", "configured", "value" }, runCommands);
}
Aggregations