env

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBasedir

func GetBasedir() (string, error)

GetBasedir finds the Git repository root directory and use that as base. If one cannot be found, uses the current working directory.

Types

type DockerEnv

type DockerEnv struct {
	// contains filtered or unexported fields
}

DockerEnv is a Docker-based execution environment that executes all commands inside a Docker container using the configured image.

func NewDockerEnv

func NewDockerEnv(image, baseDir, dirMount string) *DockerEnv

NewDockerEnv creates a new Docker-based execution environment.

func (*DockerEnv) AddDirectory

func (de *DockerEnv) AddDirectory(path string)

AddDirectory exposes a host directory to the container under the same path.

func (*DockerEnv) FixPermissions

func (de *DockerEnv) FixPermissions(path string) error

FixPermissions implements ExecEnv.

func (*DockerEnv) HasBinary

func (de *DockerEnv) HasBinary(string) bool

HasBinary implements ExecEnv.

func (*DockerEnv) IsAvailable

func (de *DockerEnv) IsAvailable() bool

IsAvailable implements ExecEnv.

func (*DockerEnv) PathFromEnv

func (de *DockerEnv) PathFromEnv(path string) (string, error)

PathFromEnv implements ExecEnv.

func (*DockerEnv) PathToEnv

func (de *DockerEnv) PathToEnv(path string) (string, error)

PathToEnv implements ExecEnv.

func (*DockerEnv) String

func (de *DockerEnv) String() string

String returns a string representation of the execution environment.

func (*DockerEnv) WrapCommand

func (de *DockerEnv) WrapCommand(cmd *exec.Cmd) error

WrapCommand implements ExecEnv.

type ExecEnv

type ExecEnv interface {
	// WrapCommand modifies an existing `exec.Cmd` such that it runs in this environment.
	WrapCommand(cmd *exec.Cmd) error

	// PathFromEnv converts the given path from inside the environment into a path outside the
	// environment.
	PathFromEnv(path string) (string, error)

	// PathToEnv converts the given path from outside the environment into a path inside the
	// environment.
	PathToEnv(path string) (string, error)

	// FixPermissions ensures that the user executing this process owns the file at the given path
	// outside the environment.
	FixPermissions(path string) error

	// HasBinary returns true iff the given binary name is available in this environment.
	HasBinary(name string) bool

	// IsAvailable returns true iff the given execution environment is available.
	IsAvailable() bool
}

ExecEnv is an execution environment.

type NativeEnv

type NativeEnv struct{}

NativeEnv is the native execution environment that executes all commands directly.

func NewNativeEnv

func NewNativeEnv() *NativeEnv

NewNativeEnv creates a new native execution environment.

func (*NativeEnv) FixPermissions

func (ne *NativeEnv) FixPermissions(string) error

FixPermissions implements ExecEnv.

func (*NativeEnv) HasBinary

func (ne *NativeEnv) HasBinary(name string) bool

HasBinary implements ExecEnv.

func (*NativeEnv) IsAvailable

func (ne *NativeEnv) IsAvailable() bool

IsAvailable implements ExecEnv.

func (*NativeEnv) PathFromEnv

func (ne *NativeEnv) PathFromEnv(path string) (string, error)

PathFromEnv implements ExecEnv.

func (*NativeEnv) PathToEnv

func (ne *NativeEnv) PathToEnv(path string) (string, error)

PathToEnv implements ExecEnv.

func (*NativeEnv) String

func (ne *NativeEnv) String() string

String returns a string representation of the execution environment.

func (*NativeEnv) WrapCommand

func (ne *NativeEnv) WrapCommand(*exec.Cmd) error

WrapCommand implements ExecEnv.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳