Package com.spotify.docker.client
Class CompressedDirectory
- java.lang.Object
-
- com.spotify.docker.client.CompressedDirectory
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
class CompressedDirectory extends java.lang.Object implements java.io.CloseableThis helper class is used during the docker build command to create a gzip tarball of a directory containing a Dockerfile.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classCompressedDirectory.DockerIgnorePathMatcherA decorator for thePathMatcherwith a type to determine if it is an exclusion pattern or an exclude to an aforementioned exclusion.private static classCompressedDirectory.Visitor
-
Field Summary
Fields Modifier and Type Field Description private static intDEFAULT_FILE_MODEDefault mode to be applied to tar file entries if detailed Posix-compliant mode cannot be obtained.private java.nio.file.Pathfileprivate static org.slf4j.Loggerlogprivate static java.lang.StringPOSIX_FILE_VIEWIdentifier used to indicate the OS supports a Posix compliant view of the file system.
-
Constructor Summary
Constructors Modifier Constructor Description privateCompressedDirectory(java.nio.file.Path file)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()static CompressedDirectorycreate(java.nio.file.Path directory)This method creates a gzip tarball of the specified directory.private static java.lang.StringcreatePattern(java.lang.String line)java.nio.file.Pathfile()The file for the created compressed directory archive.private static java.lang.StringgetNotSeparatorPattern(java.lang.String separator)(package private) static java.nio.file.PathMatchergoPathMatcher(java.nio.file.FileSystem fs, java.lang.String pattern)(package private) static com.google.common.collect.ImmutableList<CompressedDirectory.DockerIgnorePathMatcher>parseDockerIgnore(java.nio.file.Path dockerIgnorePath)
-
-
-
Field Detail
-
log
private static final org.slf4j.Logger log
-
DEFAULT_FILE_MODE
private static final int DEFAULT_FILE_MODE
Default mode to be applied to tar file entries if detailed Posix-compliant mode cannot be obtained.- See Also:
- Constant Field Values
-
POSIX_FILE_VIEW
private static final java.lang.String POSIX_FILE_VIEW
Identifier used to indicate the OS supports a Posix compliant view of the file system.- See Also:
PosixFileAttributeView.name(), Constant Field Values
-
file
private final java.nio.file.Path file
-
-
Method Detail
-
file
public java.nio.file.Path file()
The file for the created compressed directory archive.- Returns:
- a Path object representing the compressed directory
-
create
public static CompressedDirectory create(java.nio.file.Path directory) throws java.io.IOException
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:
java.io.IOException- if the compressed directory could not be created.
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
parseDockerIgnore
static com.google.common.collect.ImmutableList<CompressedDirectory.DockerIgnorePathMatcher> parseDockerIgnore(java.nio.file.Path dockerIgnorePath) throws java.io.IOException
- Throws:
java.io.IOException
-
createPattern
private static java.lang.String createPattern(java.lang.String line)
-
goPathMatcher
static java.nio.file.PathMatcher goPathMatcher(java.nio.file.FileSystem fs, java.lang.String pattern)
-
getNotSeparatorPattern
private static java.lang.String getNotSeparatorPattern(java.lang.String separator)
-
-