Documentation ¶
Overview ¶
Package command invokes external commands.
Index ¶
Constants ¶
const ( EnvKeyNerdctlTOML = "NERDCTL_TOML" EnvKeyBuildkitHost = "BUILDKIT_HOST" )
EnvKeyNerdctlTOML is the name of the environment variable used to configure the path that nerdctl uses to load it's config file. EnvKeyBuildkitHost is the path to the socket which nerdctl will use for buildkit commands. These are exported to facilitate unit testing, since it uses a different package (command_test).
const ( EnvKeyPath = "PATH" EnvKeyPathJoiner = ":" )
EnvKeyPath is the name of the PATH environment variable. EnvKeyPathJoiner is the "joiner" between directories in a PATH string. These are exported to facilitate unit testing, since it uses a different package (command_test).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Command ¶
type Command interface { SetEnv([]string) SetStdin(io.Reader) SetStdout(io.Writer) SetStderr(io.Writer) StdinPipe() (io.WriteCloser, error) Run() error Start() error Wait() error Output() ([]byte, error) CombinedOutput() ([]byte, error) }
Command contains 2 sets of methods. The first set contains the methods to configure the command to be run (e.g., SetEnv). The second set contains the methods to run the command (e.g., Output). The semantics of the methods conform to that of the counterpart of exec.Cmd.
type Creator ¶
Creator creates a Command. The semantics of the parameters are the same as those of exec.Command.
type ExecCmdCreator ¶
type ExecCmdCreator struct{}
ExecCmdCreator implements CommandCreator by invoking functions offered by os/exec.
func NewExecCmdCreator ¶
func NewExecCmdCreator() *ExecCmdCreator
NewExecCmdCreator creates a new ExecCmdCreator.
type NerdctlCmdCreator ¶ added in v1.3.0
type NerdctlCmdCreator interface { // Create creates a new Lima command and connects the stdio of it to the stdio of the current process. Create(args ...string) Command // CreateWithoutStdio creates a new Lima command without connecting the stdio of it to the stdio of the current process. // It is usually used when either Output() or CombinedOutput() instead of Run() needs to be invoked on the returned command. CreateWithoutStdio(args ...string) Command // RunWithReplacingStdout runs a new Lima command, // connects the stdio of it to the stdio of the current process, // and replaces all the strings in stdout according to rs. // // The replacements are executed sequentially. // For example, after executing the first replacement, the resultant stdout will be executed against the second replacement, and so on. // // The reason of directly buffering the string to replace instead of having a customized replacing io.Writer is // that the io.Writer without buffering may fail replacing because one source string can be split to multiple writes. // Implementing an io.Writer with buffering will be more complicated than the current implementation. RunWithReplacingStdout(rs []Replacement, args ...string) error }
NerdctlCmdCreator creates a nerdctl command.
func NewNerdctlCmdCreator ¶ added in v1.3.0
func NewNerdctlCmdCreator( cmdCreator Creator, logger flog.Logger, nerdctlConfigPath string, buildkitSocketPath string, binPath string, systemDeps NerdctlCmdCreatorSystemDeps, ) NerdctlCmdCreator
NewNerdctlCmdCreator returns a NerdctlCmdCreator that creates nerdctl commands. In "remote" mode, it uses limactl commands, configured to use binaries at lima-related paths and then executes nerdctl. In "native" mode, it directly executes nerdctl from the user's PATH.
type NerdctlCmdCreatorSystemDeps ¶ added in v1.3.0
type NerdctlCmdCreatorSystemDeps interface { system.EnvironGetter system.StdinGetter system.StdoutGetter system.StderrGetter system.EnvGetter }
NerdctlCmdCreatorSystemDeps contains the system dependencies for NewNerdctlCmdCreator.
type Replacement ¶
type Replacement struct {
Source, Target string
}
Replacement contains source string to be replaced by target string.