env

package
v0.18.1 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2025 License: Apache-2.0 Imports: 6 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.

func IsContainerRuntimeAvailable added in v0.18.0

func IsContainerRuntimeAvailable() bool

IsContainerRuntimeAvailable returns true if a container runtime (docker or podman) is available.

Types

type ContainerEnv added in v0.15.0

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

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

func NewContainerEnv added in v0.15.0

func NewContainerEnv(image, baseDir, dirMount string) *ContainerEnv

NewContainerEnv creates a new Docker or Podman-based execution environment.

func (*ContainerEnv) AddDirectory added in v0.15.0

func (de *ContainerEnv) AddDirectory(path string)

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

func (*ContainerEnv) FixPermissions added in v0.15.0

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

FixPermissions implements ExecEnv. For container environments, we use chmod to make files accessible rather than chown, because chown doesn't work correctly with rootless containers due to user namespace UID mapping. Using chmod 666 works for both rootful and rootless containers.

func (*ContainerEnv) HasBinary added in v0.15.0

func (de *ContainerEnv) HasBinary(string) bool

HasBinary implements ExecEnv.

func (*ContainerEnv) IsAvailable added in v0.15.0

func (de *ContainerEnv) IsAvailable() bool

IsAvailable implements ExecEnv.

func (*ContainerEnv) PathFromEnv added in v0.15.0

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

PathFromEnv implements ExecEnv.

func (*ContainerEnv) PathToEnv added in v0.15.0

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

PathToEnv implements ExecEnv.

func (*ContainerEnv) String added in v0.15.0

func (de *ContainerEnv) String() string

String returns a string representation of the execution environment.

func (*ContainerEnv) WrapCommand added in v0.15.0

func (de *ContainerEnv) 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