All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.fabric8.maven.docker.VolumeRemoveMojo Maven / Gradle / Ivy

There is a newer version: 0.45.0
Show newest version
package io.fabric8.maven.docker;


import io.fabric8.maven.docker.access.DockerAccessException;
import io.fabric8.maven.docker.config.VolumeConfiguration;
import io.fabric8.maven.docker.service.ServiceHub;
import io.fabric8.maven.docker.service.VolumeService;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;

/**
 *  Mojo to remove volumes created with {@link VolumeCreateMojo}
 *
 *  @author Tom Burton
 */
@Mojo(name = "volume-remove", defaultPhase = LifecyclePhase.POST_INTEGRATION_TEST)
public class VolumeRemoveMojo extends AbstractDockerMojo {

   @Override
   protected void executeInternal(ServiceHub serviceHub)
         throws DockerAccessException, MojoExecutionException  {
       if(getVolumes() == null){
           log.info("No volume configuration found.");
           return;
       }
       VolumeService volService = serviceHub.getVolumeService();

       for ( VolumeConfiguration volume : getVolumes()) {
           log.info("Removing volume %s", volume.getName());
           volService.removeVolume(volume.getName());
       }
   }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy