Documentation
¶
Overview ¶
Package env provides NodeExecutionEnv, the host-OS filesystem and shell implementation of the harness execution environment.
Index ¶
- type NodeExecutionEnv
- func (env *NodeExecutionEnv) AbsolutePath(_ context.Context, path string) (string, error)
- func (env *NodeExecutionEnv) AppendFile(ctx context.Context, path string, content []byte) error
- func (env *NodeExecutionEnv) CanonicalPath(ctx context.Context, path string) (string, error)
- func (env *NodeExecutionEnv) Cleanup(context.Context)
- func (env *NodeExecutionEnv) CreateDir(ctx context.Context, path string, options *harness.CreateDirOptions) error
- func (env *NodeExecutionEnv) CreateTempDir(ctx context.Context, prefix *string) (string, error)
- func (env *NodeExecutionEnv) CreateTempFile(ctx context.Context, options *harness.CreateTempFileOptions) (string, error)
- func (env *NodeExecutionEnv) Cwd() string
- func (env *NodeExecutionEnv) Exec(ctx context.Context, command string, options *harness.ShellExecOptions) (harness.ShellExecResult, error)
- func (env *NodeExecutionEnv) Exists(ctx context.Context, path string) (bool, error)
- func (env *NodeExecutionEnv) FileInfo(ctx context.Context, path string) (harness.FileInfo, error)
- func (env *NodeExecutionEnv) JoinPath(_ context.Context, parts []string) (string, error)
- func (env *NodeExecutionEnv) ListDir(ctx context.Context, path string) ([]harness.FileInfo, error)
- func (env *NodeExecutionEnv) OpenTextLineReader(ctx context.Context, path string) (harness.TextLineReader, error)
- func (env *NodeExecutionEnv) ReadBinaryFile(ctx context.Context, path string) ([]byte, error)
- func (env *NodeExecutionEnv) ReadTextFile(ctx context.Context, path string) (string, error)
- func (env *NodeExecutionEnv) ReadTextLines(ctx context.Context, path string, options *harness.ReadTextLinesOptions) ([]string, error)
- func (env *NodeExecutionEnv) Remove(ctx context.Context, path string, options *harness.RemoveOptions) error
- func (env *NodeExecutionEnv) RenameFile(ctx context.Context, sourcePath, destinationPath string) error
- func (env *NodeExecutionEnv) WriteFile(ctx context.Context, path string, content []byte) error
- type NodeExecutionEnvOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NodeExecutionEnv ¶
type NodeExecutionEnv struct {
// contains filtered or unexported fields
}
NodeExecutionEnv is the host-OS execution environment: filesystem access and bash command execution for the harness. Its name mirrors the upstream Node.js implementation.
func NewNodeExecutionEnv ¶
func NewNodeExecutionEnv(options NodeExecutionEnvOptions) *NodeExecutionEnv
NewNodeExecutionEnv constructs an environment rooted at options.Cwd.
func (*NodeExecutionEnv) AbsolutePath ¶
AbsolutePath resolves path without requiring it to exist.
func (*NodeExecutionEnv) AppendFile ¶
AppendFile creates or appends to path, creating parent directories.
func (*NodeExecutionEnv) CanonicalPath ¶
CanonicalPath resolves every symlink in an existing path.
func (*NodeExecutionEnv) Cleanup ¶
func (env *NodeExecutionEnv) Cleanup(context.Context)
Cleanup terminates every active command's process tree.
func (*NodeExecutionEnv) CreateDir ¶
func (env *NodeExecutionEnv) CreateDir(ctx context.Context, path string, options *harness.CreateDirOptions) error
CreateDir creates a directory; Recursive defaults to true.
func (*NodeExecutionEnv) CreateTempDir ¶
CreateTempDir creates a directory named prefix plus six random characters under the OS temp directory; prefix defaults to "tmp-".
func (*NodeExecutionEnv) CreateTempFile ¶
func (env *NodeExecutionEnv) CreateTempFile(ctx context.Context, options *harness.CreateTempFileOptions) (string, error)
CreateTempFile creates an empty file named prefix + UUID + suffix inside a fresh temporary directory.
func (*NodeExecutionEnv) Cwd ¶
func (env *NodeExecutionEnv) Cwd() string
Cwd is the directory relative paths resolve against.
func (*NodeExecutionEnv) Exec ¶
func (env *NodeExecutionEnv) Exec(ctx context.Context, command string, options *harness.ShellExecOptions) (harness.ShellExecResult, error)
Exec runs command through bash in the environment cwd (or options.Cwd). The combined stdout/stderr view is bounded and published through options.OnUpdate; a non-zero exit is a successful result. Cancellation of ctx, the timeout, a failing OnUpdate, and a failed requested spill each kill the process tree and fail the call.
func (*NodeExecutionEnv) Exists ¶
Exists reports false for missing paths and other failures as errors.
func (*NodeExecutionEnv) JoinPath ¶
JoinPath joins and normalizes path segments like Node's path.join.
func (*NodeExecutionEnv) ListDir ¶
ListDir lists direct children in directory order without following symlinks; unsupported file types are omitted.
func (*NodeExecutionEnv) OpenTextLineReader ¶
func (env *NodeExecutionEnv) OpenTextLineReader(ctx context.Context, path string) (harness.TextLineReader, error)
OpenTextLineReader opens path for pull-based line reading.
func (*NodeExecutionEnv) ReadBinaryFile ¶
ReadBinaryFile reads path.
func (*NodeExecutionEnv) ReadTextFile ¶
ReadTextFile reads path as UTF-8, replacing invalid sequences.
func (*NodeExecutionEnv) ReadTextLines ¶
func (env *NodeExecutionEnv) ReadTextLines(ctx context.Context, path string, options *harness.ReadTextLinesOptions) ([]string, error)
ReadTextLines reads up to options.MaxLines lines; a non-positive limit returns no lines.
func (*NodeExecutionEnv) Remove ¶
func (env *NodeExecutionEnv) Remove(ctx context.Context, path string, options *harness.RemoveOptions) error
Remove deletes a file or directory; a directory requires Recursive and a missing path requires Force.
func (*NodeExecutionEnv) RenameFile ¶
func (env *NodeExecutionEnv) RenameFile(ctx context.Context, sourcePath, destinationPath string) error
RenameFile atomically renames sourcePath over destinationPath.
type NodeExecutionEnvOptions ¶
type NodeExecutionEnvOptions struct {
Cwd string
// ShellPath is an explicit bash executable; empty selects the platform
// default.
ShellPath string
// ShellEnv is layered over the inherited process environment for every
// command.
ShellEnv map[string]string
}
NodeExecutionEnvOptions configure a NodeExecutionEnv.