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.Closeable
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 Classes Modifier and Type Class Description private static class
CompressedDirectory.DockerIgnorePathMatcher
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
CompressedDirectory.Visitor
-
Field Summary
Fields Modifier and Type Field Description private static int
DEFAULT_FILE_MODE
Default mode to be applied to tar file entries if detailed Posix-compliant mode cannot be obtained.private java.nio.file.Path
file
private static org.slf4j.Logger
log
private static java.lang.String
POSIX_FILE_VIEW
Identifier used to indicate the OS supports a Posix compliant view of the file system.
-
Constructor Summary
Constructors Modifier Constructor Description private
CompressedDirectory(java.nio.file.Path file)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
static CompressedDirectory
create(java.nio.file.Path directory)
This method creates a gzip tarball of the specified directory.private static java.lang.String
createPattern(java.lang.String line)
java.nio.file.Path
file()
The file for the created compressed directory archive.private static java.lang.String
getNotSeparatorPattern(java.lang.String separator)
(package private) static java.nio.file.PathMatcher
goPathMatcher(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:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in 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)
-
-