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

de.gesellix.gradle.docker.tasks.DockerVolumeCreateTask Maven / Gradle / Ivy

package de.gesellix.gradle.docker.tasks;

import de.gesellix.docker.client.EngineResponseContent;
import de.gesellix.docker.remote.api.Volume;
import org.gradle.api.model.ObjectFactory;
import org.gradle.api.provider.MapProperty;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.Optional;
import org.gradle.api.tasks.TaskAction;

import javax.inject.Inject;
import java.util.HashMap;

public class DockerVolumeCreateTask extends GenericDockerTask {

  private final MapProperty volumeConfig;

  @Input
  @Optional
  public MapProperty getVolumeConfig() {
    return volumeConfig;
  }

  private EngineResponseContent response;

  @Internal
  public EngineResponseContent getResponse() {
    return response;
  }

  @Inject
  public DockerVolumeCreateTask(ObjectFactory objectFactory) {
    super(objectFactory);
    setDescription("Create a volume");

    volumeConfig = objectFactory.mapProperty(String.class, Object.class);
  }

  @TaskAction
  public EngineResponseContent createVolume() {
    getLogger().info("docker volume create");

    response = getDockerClient().createVolume(new HashMap<>(getVolumeConfig().get()));
    return response;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy