{"modulePath":"github.com/cloudfoundry/bosh-utils","version":"v0.0.679","isLatest":true,"isStandardLibrary":false,"goos":"linux","goarch":"amd64","docs":"# package system\n\n## Functions\n\n```go\nfunc CalculateNetworkAndBroadcast(ipAddress, netmask string) (string, string, int, error)\n```\n\n```go\nfunc NewExecProcess(cmd *exec.Cmd, keepAttached bool, quiet bool, logger boshlog.Logger) *execProcess\n```\n\n## Types\n\n```go\ntype CmdRunner interface {\n\t// RunComplexCommand returns error as nil:\n\t//  - command runs and exits with a zero exit status\n\t// RunComplexCommand returns error:\n\t//  - command runs and exits with a non-zero exit status\n\t//  - command does not run\n\tRunComplexCommand(cmd Command) (stdout, stderr string, exitStatus int, err error)\n\n\tRunComplexCommandAsync(cmd Command) (Process, error)\n\n\tRunCommand(cmdName string, args ...string) (stdout, stderr string, exitStatus int, err error)\n\n\tRunCommandQuietly(cmdName string, args ...string) (stdout, stderr string, exitStatus int, err error)\n\n\tRunCommandWithInput(input, cmdName string, args ...string) (stdout, stderr string, exitStatus int, err error)\n\n\tCommandExists(cmdName string) (exists bool)\n}\n```\n\n```go\nfunc NewExecCmdRunner(logger boshlog.Logger) CmdRunner\n```\n\n```go\ntype Command struct {\n\tName string\n\tArgs []string\n\tEnv  map[string]string\n\n\tWorkingDir string\n\n\t// On Linux when enabled inherits process group\n\tKeepAttached bool\n\n\t// Don't echo stdout/stderr\n\tQuiet bool\n\n\t// Run command with a lower scheduling priority than the parent process.\n\t// On Unix: nice value is parent + 5, clamped at 19.\n\t// On Windows: priority class is set to BelowNormal.\n\t// If the parent is already at the minimum priority, the child will run at the same level.\n\tSpawnWithLowerPriority bool\n\n\tStdin io.Reader\n\n\t// Full stdout and stderr will be captured to memory\n\t// and returned in the Result unless custom Stdout/Stderr are specified.\n\tStdout io.Writer\n\tStderr io.Writer\n}\n```\n\n```go\ntype ConvergeFileContentsOpts struct {\n\tDryRun bool\n}\n```\n\n```go\ntype ExecError struct {\n\tCommand string\n\tStdOut  string\n\tStdErr  string\n}\n```\n\n```go\nfunc NewExecError(cmd, stdout, stderr string) ExecError\n```\n\n```go\nfunc (e ExecError) Error() string\n```\n\n```go\nfunc (e ExecError) ShortError() string\n```\nShortError returns an error message that has stdout/stderr truncated.\n\n```go\ntype File interface {\n\tio.ReadWriteCloser\n\tReadAt([]byte, int64) (int, error)\n\tWriteAt([]byte, int64) (int, error)\n\tSeek(int64, int) (int64, error)\n\tStat() (os.FileInfo, error)\n\tName() string\n}\n```\nFile is a subset of os.File\n\n```go\ntype FileSystem interface {\n\tHomeDir(username string) (path string, err error)\n\tExpandPath(path string) (expandedPath string, err error)\n\n\t// MkdirAll will not change existing dir permissions\n\t// if dir exists and has different permissions\n\tMkdirAll(path string, perm os.FileMode) error\n\tRemoveAll(fileOrDir string) error\n\n\tChown(path, username string) error\n\tChmod(path string, perm os.FileMode) error\n\n\tOpenFile(path string, flag int, perm os.FileMode) (File, error)\n\n\tWriteFileString(path, content string) error\n\tWriteFile(path string, content []byte) error\n\tWriteFileQuietly(path string, content []byte) error\n\tConvergeFileContents(path string, content []byte, opts ...ConvergeFileContentsOpts) (written bool, err error)\n\n\tReadFileString(path string) (content string, err error)\n\tReadFile(path string) (content []byte, err error)\n\tReadFileWithOpts(path string, opts ReadOpts) (content []byte, err error)\n\n\tFileExists(path string) bool\n\tStat(path string) (os.FileInfo, error)\n\tStatWithOpts(path string, opts StatOpts) (os.FileInfo, error)\n\tLstat(path string) (os.FileInfo, error)\n\n\tRename(oldPath, newPath string) error\n\n\t// Symlink creates a symlink file at newPath pointing to file at oldPath,\n\t// and removes any file that might exist at newPath.\n\tSymlink(oldPath, newPath string) error\n\n\tReadAndFollowLink(symlinkPath string) (targetPath string, err error)\n\tReadlink(symlinkPath string) (targetPath string, err error)\n\n\tCopyFile(srcPath, dstPath string) error\n\tCopyDir(srcPath, dstPath string) error\n\n\t// TempFile returns a unique temporary file with a custom prefix\n\tTempFile(prefix string) (file File, err error)\n\tTempDir(prefix string) (path string, err error)\n\tChangeTempRoot(path string) error\n\n\tGlob(pattern string) (matches []string, err error)\n\tRecursiveGlob(pattern string) (matches []string, err error)\n\tWalk(root string, walkFunc filepath.WalkFunc) error\n}\n```\n\n```go\nfunc NewOsFileSystem(logger boshlog.Logger) FileSystem\n```\n\n```go\nfunc NewOsFileSystemWithStrictTempRoot(logger boshlog.Logger) FileSystem\n```\n\n```go\ntype Process interface {\n\t// Wait is the only way to get back process result information.\n\t// It must not be called multiple times.\n\tWait() \u003c-chan Result\n\n\t// TerminateNicely can be called multiple times.\n\t// It must only be called after Wait().\n\tTerminateNicely(killGracePeriod time.Duration) error\n}\n```\n\n```go\ntype ReadOpts struct {\n\t// Quiet suppresses both the \"Reading file\" trace and the \"Read content\" dump.\n\tQuiet bool\n\t// QuietContent suppresses only the full-content \"Read content\" dump while\n\t// keeping the \"Reading file\" trace. Use it for files that are read often or\n\t// may contain sensitive data (e.g. signed URLs), where dumping the whole\n\t// content at DEBUG is noisy or leaks secrets.\n\tQuietContent bool\n}\n```\n\n```go\ntype Result struct {\n\t// Full stdout and stderr are captured to memory\n\tStdout string\n\tStderr string\n\n\tExitStatus int\n\tError      error\n}\n```\n\n```go\ntype StatOpts struct {\n\tQuiet bool\n}\n```\n\n","path":"github.com/cloudfoundry/bosh-utils/system","name":"system","synopsis":"","isRedistributable":true}
