Class 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.
    • 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)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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
    • Constructor Detail

      • CompressedDirectory

        private CompressedDirectory​(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 the Files.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 interface java.lang.AutoCloseable
        Specified by:
        close in interface java.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)