Package com.spotify.docker.client
Class CompressedDirectory
java.lang.Object
com.spotify.docker.client.CompressedDirectory
- All Implemented Interfaces:
Closeable,AutoCloseable
This helper class is used during the docker build command to create a gzip tarball of a directory
containing a Dockerfile.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classA decorator for thePathMatcherwith a type to determine if it is an exclusion pattern or an exclude to an aforementioned exclusion.private static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intDefault mode to be applied to tar file entries if detailed Posix-compliant mode cannot be obtained.private final Pathprivate static final org.slf4j.Loggerprivate static final StringIdentifier used to indicate the OS supports a Posix compliant view of the file system. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()static CompressedDirectoryThis method creates a gzip tarball of the specified directory.private static StringcreatePattern(String line) file()The file for the created compressed directory archive.private static StringgetNotSeparatorPattern(String separator) (package private) static PathMatchergoPathMatcher(FileSystem fs, String pattern) (package private) static com.google.common.collect.ImmutableList<CompressedDirectory.DockerIgnorePathMatcher> parseDockerIgnore(Path dockerIgnorePath)
-
Field Details
-
log
private static final org.slf4j.Logger log -
DEFAULT_FILE_MODE
private static final int DEFAULT_FILE_MODEDefault mode to be applied to tar file entries if detailed Posix-compliant mode cannot be obtained.- See Also:
-
POSIX_FILE_VIEW
Identifier used to indicate the OS supports a Posix compliant view of the file system.- See Also:
-
file
-
-
Constructor Details
-
CompressedDirectory
-
-
Method Details
-
file
The file for the created compressed directory archive.- Returns:
- a Path object representing the compressed directory
-
create
This method creates a gzip tarball of the specified directory. File permissions will be retained. The file will be created in a temporary directory using theFiles.createTempFile(String, String, java.nio.file.attribute.FileAttribute[])method. The returned object is auto-closeable, and upon closing it, the archive file will be deleted.- Parameters:
directory- the directory to compress- Returns:
- a Path object representing the compressed directory
- Throws:
IOException- if the compressed directory could not be created.
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
parseDockerIgnore
static com.google.common.collect.ImmutableList<CompressedDirectory.DockerIgnorePathMatcher> parseDockerIgnore(Path dockerIgnorePath) throws IOException - Throws:
IOException
-
createPattern
-
goPathMatcher
-
getNotSeparatorPattern
-