Пример #1
0
            /**
             * Adds an entry to the layer. If the source file is a directory, the directory and its contents
             * will be added recursively.
             *
             * @param sourceFile the source file to add to the layer recursively
             * @param pathInContainer the path in the container file system corresponding to the {@code
             *     sourceFile}
             * @param filePermissionProvider a provider that takes a source path and destination path on the
             *     container and returns the file permissions that should be set for that path
             * @param lastModifiedTimeProvider a provider that takes a source path and destination path on
             *     the container and returns the file modification time that should be set for that path
             * @return this
             * @throws IOException if an exception occurred when recursively listing the directory
             */
            public Builder AddEntryRecursive(
                SystemPath sourceFile,
                AbsoluteUnixPath pathInContainer,
                Func <SystemPath, AbsoluteUnixPath, FilePermissions> filePermissionProvider,
                Func <SystemPath, AbsoluteUnixPath, Instant> lastModifiedTimeProvider)
            {
                FilePermissions permissions  = filePermissionProvider?.Invoke(sourceFile, pathInContainer);
                Instant         modifiedTime = lastModifiedTimeProvider(sourceFile, pathInContainer);

                AddEntry(sourceFile, pathInContainer, permissions, modifiedTime);
                if (!Files.IsDirectory(sourceFile))
                {
                    return(this);
                }
                IEnumerable <SystemPath> files = Files.List(sourceFile);

                {
                    foreach (SystemPath file in files.ToList())
                    {
                        AddEntryRecursive(
                            file,
                            pathInContainer.Resolve(file.GetFileName()),
                            filePermissionProvider,
                            lastModifiedTimeProvider);
                    }
                }
                return(this);
            }
Пример #2
0
 /**
  * Adds an entry to the layer. Only adds the single source file to the exact path in the
  * container file system.
  *
  * <p>For example, {@code addEntry(Paths.get("myfile"),
  * AbsoluteUnixPath.get("/path/in/container"))} adds a file {@code myfile} to the container file
  * system at {@code /path/in/container}.
  *
  * <p>For example, {@code addEntry(Paths.get("mydirectory"),
  * AbsoluteUnixPath.get("/path/in/container"))} adds a directory {@code mydirectory/} to the
  * container file system at {@code /path/in/container/}. This does <b>not</b> add the contents
  * of {@code mydirectory}.
  *
  * @param sourceFile the source file to add to the layer
  * @param pathInContainer the path in the container file system corresponding to the {@code
  *     sourceFile}
  * @return this
  */
 public Builder AddEntry(SystemPath sourceFile, AbsoluteUnixPath pathInContainer)
 {
     return(AddEntry(
                sourceFile,
                pathInContainer,
                DefaultFilePermissionsProvider(sourceFile, pathInContainer)));
 }
Пример #3
0
 /**
  * Adds an entry to the layer. If the source file is a directory, the directory and its contents
  * will be added recursively.
  *
  * @param sourceFile the source file to add to the layer recursively
  * @param pathInContainer the path in the container file system corresponding to the {@code
  *     sourceFile}
  * @param filePermissionProvider a provider that takes a source path and destination path on the
  *     container and returns the file permissions that should be set for that path
  * @return this
  * @throws IOException if an exception occurred when recursively listing the directory
  */
 public Builder AddEntryRecursive(
     SystemPath sourceFile,
     AbsoluteUnixPath pathInContainer,
     Func <SystemPath, AbsoluteUnixPath, FilePermissions> filePermissionProvider)
 {
     return(AddEntryRecursive(
                sourceFile, pathInContainer, filePermissionProvider, DefaultModifiedTimeProvider));
 }
Пример #4
0
 /**
  * Adds an entry to the layer with the given permissions. Only adds the single source file to
  * the exact path in the container file system. See {@link Builder#addEntry(Path,
  * AbsoluteUnixPath)} for more information.
  *
  * @param sourceFile the source file to add to the layer
  * @param pathInContainer the path in the container file system corresponding to the {@code
  *     sourceFile}
  * @param permissions the file permissions on the container
  * @param lastModifiedTime the file modification timestamp
  * @return this
  * @see Builder#addEntry(Path, AbsoluteUnixPath)
  * @see FilePermissions#DEFAULT_FILE_PERMISSIONS
  * @see FilePermissions#DEFAULT_FOLDER_PERMISSIONS
  */
 public Builder AddEntry(
     SystemPath sourceFile,
     AbsoluteUnixPath pathInContainer,
     FilePermissions permissions,
     Instant lastModifiedTime)
 {
     return(AddEntry(new LayerEntry(sourceFile, pathInContainer, permissions, lastModifiedTime)));
 }
Пример #5
0
 /**
  * Adds an entry to the layer with the given permissions. Only adds the single source file to
  * the exact path in the container file system. See {@link Builder#addEntry(Path,
  * AbsoluteUnixPath)} for more information.
  *
  * @param sourceFile the source file to add to the layer
  * @param pathInContainer the path in the container file system corresponding to the {@code
  *     sourceFile}
  * @param permissions the file permissions on the container
  * @return this
  * @see Builder#addEntry(Path, AbsoluteUnixPath)
  * @see FilePermissions#DEFAULT_FILE_PERMISSIONS
  * @see FilePermissions#DEFAULT_FOLDER_PERMISSIONS
  */
 public Builder AddEntry(
     SystemPath sourceFile, AbsoluteUnixPath pathInContainer, FilePermissions permissions)
 {
     return(AddEntry(
                sourceFile,
                pathInContainer,
                permissions,
                DefaultModifiedTimeProvider(sourceFile, pathInContainer)));
 }
Пример #6
0
 public LayerEntry(
     SystemPath sourceFile,
     AbsoluteUnixPath extractionPath,
     FilePermissions permissions = null,
     Instant?lastModifiedTime    = null)
 {
     SourceFile       = sourceFile;
     ExtractionPath   = extractionPath;
     Permissions      = permissions ?? LayerConfiguration.DefaultFilePermissionsProvider(SourceFile, ExtractionPath);
     LastModifiedTime =
         lastModifiedTime ?? LayerConfiguration.DefaultModifiedTimeProvider(SourceFile, ExtractionPath);
 }
Пример #7
0
        /**
         * Adds a new layer to the container with {@code files} as the source files and {@code
         * pathInContainer} as the path to copy the source files to in the container file system.
         *
         * <p>Source files that are directories will be recursively copied. For example, if the source
         * files are:
         *
         * <ul>
         *   <li>{@code fileA}
         *   <li>{@code fileB}
         *   <li>{@code directory/}
         * </ul>
         *
         * and the destination to copy to is {@code /path/in/container}, then the new layer will have the
         * following entries for the container file system:
         *
         * <ul>
         *   <li>{@code /path/in/container/fileA}
         *   <li>{@code /path/in/container/fileB}
         *   <li>{@code /path/in/container/directory/}
         *   <li>{@code /path/in/container/directory/...} (all contents of {@code directory/})
         * </ul>
         *
         * @param files the source files to copy to a new layer in the container
         * @param pathInContainer the path in the container file system corresponding to the {@code
         *     sourceFile}
         * @return this
         * @throws IOException if an exception occurred when recursively listing any directories
         */
        public FibContainerBuilder AddLayer(IList <SystemPath> files, AbsoluteUnixPath pathInContainer)
        {
            pathInContainer = pathInContainer ?? throw new ArgumentNullException(nameof(pathInContainer));
            files           = files ?? throw new ArgumentNullException(nameof(files));

            LayerConfiguration.Builder layerConfigurationBuilder = LayerConfiguration.CreateBuilder();

            foreach (SystemPath file in files)

            {
                layerConfigurationBuilder.AddEntryRecursive(
                    file, pathInContainer.Resolve(file.GetFileName()));
            }

            return(AddLayer(layerConfigurationBuilder.Build()));
        }
Пример #8
0
 /**
  * Sets the working directory in the container.
  *
  * @param workingDirectory the working directory
  * @return this
  */
 public FibContainerBuilder SetWorkingDirectory(AbsoluteUnixPath workingDirectory)
 {
     containerConfigurationBuilder.SetWorkingDirectory(workingDirectory);
     return(this);
 }
Пример #9
0
 /**
  * Adds a directory that may hold an externally mounted volume.
  *
  * @param volume a directory path on the container filesystem to represent a volume
  * @return this
  * @see #setVolumes(ISet)
  */
 public FibContainerBuilder AddVolume(AbsoluteUnixPath volume)
 {
     containerConfigurationBuilder.AddVolume(volume);
     return(this);
 }
Пример #10
0
 /**
  * Adds a new layer to the container with {@code files} as the source files and {@code
  * pathInContainer} as the path to copy the source files to in the container file system.
  *
  * @param files the source files to copy to a new layer in the container
  * @param pathInContainer the path in the container file system corresponding to the {@code
  *     sourceFile}
  * @return this
  * @throws IOException if an exception occurred when recursively listing any directories
  * @throws IllegalArgumentException if {@code pathInContainer} is not an absolute Unix-style path
  * @see #addLayer(List, AbsoluteUnixPath)
  */
 public FibContainerBuilder AddLayer(IList <SystemPath> files, string pathInContainer)
 {
     return(AddLayer(files, AbsoluteUnixPath.Get(pathInContainer)));
 }
Пример #11
0
 /**
  * Adds an entry to the layer. Only adds the single source file to the exact path in the
  * container file system.
  *
  * <p>For example, {@code addEntry(Paths.get("myfile"),
  * AbsoluteUnixPath.get("/path/in/container"))} adds a file {@code myfile} to the container file
  * system at {@code /path/in/container}.
  *
  * <p>For example, {@code addEntry(Paths.get("mydirectory"),
  * AbsoluteUnixPath.get("/path/in/container"))} adds a directory {@code mydirectory/} to the
  * container file system at {@code /path/in/container/}. This does <b>not</b> add the contents
  * of {@code mydirectory}.
  *
  * @param sourceFile the source file to add to the layer
  * @param pathInContainer the path in the container file system corresponding to the {@code
  *     sourceFile}
  * @return this
  */
 public Builder AddEntry(string sourceFile, AbsoluteUnixPath pathInContainer)
 {
     return(AddEntry(new SystemPath(sourceFile), pathInContainer));
 }