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

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

package de.gesellix.gradle.docker.tasks;

import de.gesellix.docker.client.EngineResponseContent;
import org.gradle.api.model.ObjectFactory;
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.TaskAction;

import javax.inject.Inject;
import java.io.InputStream;

public class DockerCopyFromContainerTask extends GenericDockerTask {

  private final Property container;

  @Input
  public Property getContainer() {
    return container;
  }

  private final Property sourcePath;

  @Input
  public Property getSourcePath() {
    return sourcePath;
  }

  private EngineResponseContent content;

  @Internal
  public EngineResponseContent getContent() {
    return content;
  }

  @Inject
  public DockerCopyFromContainerTask(ObjectFactory objectFactory) {
    super(objectFactory);
    setDescription("Copy files/folders from a container to your host.");

    container = objectFactory.property(String.class);
    sourcePath = objectFactory.property(String.class);
  }

  @TaskAction
  public EngineResponseContent copyFromContainer() {
    getLogger().info("docker cp from container");
    return content = getDockerClient().getArchive(getContainer().get(), getSourcePath().get());
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy