Documentation
¶
Index ¶
- func GetBasedir() (string, error)
- func IsContainerRuntimeAvailable() bool
- type ContainerEnv
- func (de *ContainerEnv) AddDirectory(path string)
- func (de *ContainerEnv) FixPermissions(path string) error
- func (de *ContainerEnv) HasBinary(string) bool
- func (de *ContainerEnv) IsAvailable() bool
- func (de *ContainerEnv) PathFromEnv(path string) (string, error)
- func (de *ContainerEnv) PathToEnv(path string) (string, error)
- func (de *ContainerEnv) String() string
- func (de *ContainerEnv) WrapCommand(cmd *exec.Cmd) error
- type ExecEnv
- type NativeEnv
- func (ne *NativeEnv) FixPermissions(string) error
- func (ne *NativeEnv) HasBinary(name string) bool
- func (ne *NativeEnv) IsAvailable() bool
- func (ne *NativeEnv) PathFromEnv(path string) (string, error)
- func (ne *NativeEnv) PathToEnv(path string) (string, error)
- func (ne *NativeEnv) String() string
- func (ne *NativeEnv) WrapCommand(*exec.Cmd) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetBasedir ¶
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 ¶
FixPermissions implements ExecEnv.
func (*NativeEnv) IsAvailable ¶
IsAvailable implements ExecEnv.
func (*NativeEnv) PathFromEnv ¶
PathFromEnv implements ExecEnv.