launch

package
v0.18.5 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: Apache-2.0 Imports: 16 Imported by: 9

Documentation

Index

Constants

View Source
const (
	CNBDir = `/cnb`
)

Variables

View Source
var (
	LifecycleDir = filepath.Join(CNBDir, "lifecycle")
	ProcessDir   = filepath.Join(CNBDir, "process")
	LauncherPath = filepath.Join(LifecycleDir, "launcher"+exe)
)
View Source
var (
	OSExecFunc   = syscall.Exec
	DefaultShell = &BashShell{Exec: OSExecFunc}
)

Functions

func EscapeID

func EscapeID(id string) string

func GetMetadataFilePath

func GetMetadataFilePath(layersDir string) string

func ProcessPath added in v0.9.0

func ProcessPath(pType string) string

ProcessPath returns the absolute path to the symlink for a given process type

Types

type BashShell added in v0.9.0

type BashShell struct {
	Exec ExecFunc
}

func (*BashShell) Launch added in v0.9.0

func (b *BashShell) Launch(proc ShellProcess) error

Launch launches the given ShellProcess with Bash

It shall execute a Bash command that sources profile scripts and then executes the process in a nested Bash command When ShellProcess.Script is true nested Bash script shall be proc.Command with proc.Args provided as argument to Bash When ShellProcess.Script is false a Bash command shall be contructed from proc.Command and proc.Args

type Buildpack

type Buildpack struct {
	API string `toml:"api"`
	ID  string `toml:"id"`
}

type CmdShell added in v0.9.0

type CmdShell struct {
	Exec ExecFunc
}

func (*CmdShell) Launch added in v0.9.0

func (c *CmdShell) Launch(proc ShellProcess) error

Launch launches the given ShellProcess with cmd

type Env

type Env interface {
	AddEnvDir(envDir string, defaultAction env.ActionType) error
	AddRootDir(baseDir string) error
	Get(string) string
	List() []string
	Set(name, k string)
}

type ExecD added in v0.10.0

type ExecD interface {
	ExecD(path string, env Env) error
}

type ExecDRunner added in v0.10.0

type ExecDRunner struct {
	Out, Err io.Writer // Out and Err can be used to configure Stdout and Stderr processes run by ExecDRunner.
}

ExecDRunner is responsible for running ExecD binaries.

func NewExecDRunner added in v0.10.0

func NewExecDRunner() *ExecDRunner

NewExecDRunner creates an ExecDRunner with Out and Err set to stdout and stderr

func (*ExecDRunner) ExecD added in v0.10.0

func (e *ExecDRunner) ExecD(path string, env Env) error

ExecD executes the executable file at path and sets the returned variables in env. The executable at path should implement the ExecD interface in the buildpack specification https://github.com/buildpacks/spec/blob/main/buildpack.md#execd

type ExecFunc added in v0.9.0

type ExecFunc func(argv0 string, argv []string, envv []string) error

type Launcher

type Launcher struct {
	AppDir             string
	Buildpacks         []Buildpack
	DefaultProcessType string
	Env                Env
	Exec               ExecFunc
	ExecD              ExecD
	Shell              Shell
	LayersDir          string
	PlatformAPI        *api.Version
	Processes          []Process
	Setenv             func(string, string) error
}

func (*Launcher) Launch

func (l *Launcher) Launch(self string, cmd []string) error

Launch uses cmd to select a process and launches that process. For direct=false processes, self is used to set argv0 during profile script execution

func (*Launcher) LaunchProcess added in v0.9.0

func (l *Launcher) LaunchProcess(self string, proc Process) error

LaunchProcess launches the provided process. For direct=false processes, self is used to set argv0 during profile script execution

func (*Launcher) ProcessFor added in v0.9.0

func (l *Launcher) ProcessFor(cmd []string) (Process, error)

ProcessFor creates a process from container cmd

If the Platform API if 0.4 or greater and DefaultProcess is set:
  * The default process is returned with `cmd` appended to the process args
If the Platform API is less than 0.4
  * If there is exactly one argument and it matches a process type, it returns that process.
  * If cmd is empty, it returns the default process
Else
  * it constructs a new process from cmd
  * If the first element in cmd is `cmd` the process shall be direct

type Metadata

type Metadata struct {
	Processes  []Process   `toml:"processes" json:"processes"`
	Buildpacks []Buildpack `toml:"buildpacks" json:"buildpacks"`
}

func (Metadata) FindProcessType added in v0.9.0

func (m Metadata) FindProcessType(pType string) (Process, bool)

func (Metadata) Matches added in v0.15.0

func (m Metadata) Matches(x interface{}) bool

Matches is used by goMock to compare two Metadata objects in tests when matching expected calls to methods containing Metadata objects

func (Metadata) String added in v0.15.0

func (m Metadata) String() string

type Process

type Process struct {
	Type             string       `toml:"type" json:"type"`
	Command          RawCommand   `toml:"command" json:"command"`
	Args             []string     `toml:"args" json:"args"`
	Direct           bool         `toml:"direct" json:"direct"`
	Default          bool         `toml:"default,omitempty" json:"default,omitempty"`
	BuildpackID      string       `toml:"buildpack-id" json:"buildpackID"`
	WorkingDirectory string       `toml:"working-dir,omitempty" json:"working-dir,omitempty"`
	PlatformAPI      *api.Version `toml:"-" json:"-"`
}

Process represents a process to launch at runtime.

func (Process) NoDefault added in v0.11.0

func (p Process) NoDefault() Process

func (Process) WithPlatformAPI added in v0.15.0

func (p Process) WithPlatformAPI(platformAPI *api.Version) Process

type RawCommand added in v0.15.1

type RawCommand struct {
	Entries     []string
	PlatformAPI *api.Version
}

func NewRawCommand added in v0.15.1

func NewRawCommand(entries []string) RawCommand

func (RawCommand) MarshalJSON added in v0.15.1

func (c RawCommand) MarshalJSON() ([]byte, error)

func (RawCommand) MarshalTOML added in v0.15.1

func (c RawCommand) MarshalTOML() ([]byte, error)

func (*RawCommand) UnmarshalJSON added in v0.15.1

func (c *RawCommand) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler and is provided to help library consumers who need to read the build metadata label this method will attempt to parse the command in either string or array format

func (*RawCommand) UnmarshalTOML added in v0.15.1

func (c *RawCommand) UnmarshalTOML(data interface{}) error

UnmarshalTOML implements toml.Unmarshaler and is needed because we read metadata.toml this method will attempt to parse the command in either string or array format

func (RawCommand) WithPlatformAPI added in v0.15.1

func (c RawCommand) WithPlatformAPI(api *api.Version) RawCommand

type Shell added in v0.9.0

type Shell interface {
	Launch(ShellProcess) error
}

type ShellProcess added in v0.9.0

type ShellProcess struct {
	Script           bool // Script indicates whether Command is a script or should be a token in a generated script
	Args             []string
	Command          string
	Caller           string // Caller used to set argv0 for Bash profile scripts and is ignored in Cmd
	Profiles         []string
	Env              []string
	WorkingDirectory string
}

Directories

Path Synopsis
Package testmock is a generated GoMock package.
Package testmock is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL