Search in sources :

Example 1 with ContainerDescriptor

use of io.fabric8.maven.docker.service.RunService.ContainerDescriptor in project docker-maven-plugin by fabric8io.

the class RunService method getContainers.

/**
 * Get all started containers.
 * The containers are returned in order of their registration.
 * If no pom label is given, then all containers are returned.
 *
 * @param gavLabel the label for which to get the containers or <code>null</code> for all containers
 * @return the containers for the given label or an empty collection
 */
public List<ContainerDescriptor> getContainers(GavLabel gavLabel) {
    Collection<ContainerShutdownDescriptor> shutdownDescriptors = tracker.getShutdownDescriptors(gavLabel);
    List<ContainerDescriptor> containers = new ArrayList<>(shutdownDescriptors.size());
    for (ContainerShutdownDescriptor descriptor : shutdownDescriptors) {
        containers.add(new ContainerDescriptor(descriptor.getContainerId(), descriptor.getImageConfiguration()));
    }
    return containers;
}
Also used : ContainerShutdownDescriptor(io.fabric8.maven.docker.service.ContainerTracker.ContainerShutdownDescriptor) ArrayList(java.util.ArrayList)

Example 2 with ContainerDescriptor

use of io.fabric8.maven.docker.service.RunService.ContainerDescriptor in project docker-maven-plugin by fabric8io.

the class CopyMojo method copyFromStartedContainers.

private void copyFromStartedContainers(DockerAccess dockerAccess, RunService runService, ArchiveService archiveService, GavLabel gavLabel) throws IOException, MojoExecutionException {
    List<ContainerDescriptor> containerDescriptors = runService.getContainers(gavLabel);
    for (ContainerDescriptor containerDescriptor : containerDescriptors) {
        ImageConfiguration imageConfiguration = containerDescriptor.getImageConfig();
        CopyConfiguration copyConfiguration = imageConfiguration.getCopyConfiguration();
        String imageName = imageConfiguration.getName();
        if (isEmpty(copyConfiguration)) {
            log.debug("Copy configuration is not defined for %s image, skipping coping", imageName);
            continue;
        }
        String containerId = containerDescriptor.getContainerId();
        log.debug("Found %s container of %s image started by start mojo", containerId, imageName);
        copy(dockerAccess, archiveService, containerId, imageName, copyConfiguration);
    }
}
Also used : ImageConfiguration(io.fabric8.maven.docker.config.ImageConfiguration) CopyConfiguration(io.fabric8.maven.docker.config.CopyConfiguration) ContainerDescriptor(io.fabric8.maven.docker.service.RunService.ContainerDescriptor)

Aggregations

CopyConfiguration (io.fabric8.maven.docker.config.CopyConfiguration)1 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)1 ContainerShutdownDescriptor (io.fabric8.maven.docker.service.ContainerTracker.ContainerShutdownDescriptor)1 ContainerDescriptor (io.fabric8.maven.docker.service.RunService.ContainerDescriptor)1 ArrayList (java.util.ArrayList)1