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 class
A decorator for thePathMatcher
with 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 int
Default mode to be applied to tar file entries if detailed Posix-compliant mode cannot be obtained.private final Path
private static final org.slf4j.Logger
private static final String
Identifier used to indicate the OS supports a Posix compliant view of the file system. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
static CompressedDirectory
This method creates a gzip tarball of the specified directory.private static String
createPattern
(String line) file()
The file for the created compressed directory archive.private static String
getNotSeparatorPattern
(String separator) (package private) static PathMatcher
goPathMatcher
(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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
parseDockerIgnore
static com.google.common.collect.ImmutableList<CompressedDirectory.DockerIgnorePathMatcher> parseDockerIgnore(Path dockerIgnorePath) throws IOException - Throws:
IOException
-
createPattern
-
goPathMatcher
-
getNotSeparatorPattern
-