system

package
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2024 License: Apache-2.0 Imports: 8 Imported by: 301

Documentation

Index

Constants

View Source
const DefaultPathEnvUnix = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

DefaultPathEnvUnix is unix style list of directories to search for executables. Each directory is separated from the next by a colon ':' character .

View Source
const DefaultPathEnvWindows = "c:\\Windows\\System32;c:\\Windows"

DefaultPathEnvWindows is windows style list of directories to search for executables. Each directory is separated from the next by a colon ';' character .

Variables

This section is empty.

Functions

func Atime added in v0.11.0

func Atime(st iofs.FileInfo) (time.Time, error)

func CheckSystemDriveAndRemoveDriveLetter

func CheckSystemDriveAndRemoveDriveLetter(path string, inputOS string) (string, error)

CheckSystemDriveAndRemoveDriveLetter verifies and manipulates a Windows path. For linux, this is a no-op.

This is used, for example, when validating a user provided path in docker cp. If a drive letter is supplied, it must be the system drive. The drive letter is always removed. It also converts any backslash to forward slash. The conversion to OS specific separator should happen as late as possible (ie: before passing the value to the function that will actually use it). Paths are parsed and code paths are triggered starting with the client and all the way down to calling into the runtime environment. The client may run on a foreign OS from the one the build will be triggered (Windows clients connecting to Linux or vice versa). Keeping the file separator consistent until the last moment is desirable.

We need the Windows path without the drive letter so that it can ultimately be concatenated with a Windows long-path which doesn't support drive-letters. Examples: C: --> Fail C:somepath --> somepath // This is a relative path to the CWD set for that drive letter C:\ --> \ a --> a /a --> \a d:\ --> Fail

UNC paths can refer to multiple types of paths. From local filesystem paths, to remote filesystems like SMB or named pipes. There is no sane way to support this without adding a lot of complexity which I am not sure is worth it. \\.\C$\a --> Fail

func DefaultPathEnv

func DefaultPathEnv(os string) string

func FromSlash added in v0.12.0

func FromSlash(inputPath, inputOS string) string

func IsAbs added in v0.12.0

func IsAbs(pth, inputOS string) bool

IsAbs returns a boolean value indicating whether or not the path is absolute. On Linux, this is just a wrapper for filepath.IsAbs(). On Windows, we strip away the drive letter (if any), clean the path, and check whether or not the path starts with a filepath.Separator. This function is meant to check if a path is absolute, in the context of a COPY, ADD or WORKDIR, which have their root set in the mount point of the writable layer we are mutating. The filepath.IsAbs() function on Windows will not work in these scenatios, as it will return true for paths that:

  • Begin with drive letter (DOS style paths)
  • Are volume paths \\?\Volume{UUID}
  • Are UNC paths

func NormalizePath added in v0.12.0

func NormalizePath(parent, newPath, inputOS string, keepSlash bool) (string, error)

NormalizePath cleans the path based on the operating system the path is meant for. It takes into account a potential parent path, and will join the path to the parent if the path is relative. Additionally, it will apply the following rules:

  • always return an absolute path
  • always strip drive letters for Windows paths
  • optionally keep the trailing slashes on paths
  • paths are returned using forward slashes

func NormalizeWorkdir added in v0.12.0

func NormalizeWorkdir(current, wd string, inputOS string) (string, error)

NormalizeWorkdir will return a normalized version of the new workdir, given the currently configured workdir and the desired new workdir. When setting a new relative workdir, it will be joined to the previous workdir or default to the root folder. On Windows we remove the drive letter and convert the path delimiter to "\". Paths that begin with os.PathSeparator are considered absolute even on Windows.

func ToSlash added in v0.12.0

func ToSlash(inputPath, inputOS string) string

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL