Documentation
¶
Overview ¶
Wrapper around os/exec to run podman commands.
Index ¶
- func InsideContainer() bool
- func PrintCommand(msg string, cmd *exec.Cmd)
- func PrintCommandR(msg string, cmd *exec.Cmd) *exec.Cmd
- func ReplaceEnvVars(s string) string
- type Attach
- type Podman
- func (e *Podman) Attach(args []string, attach Attach) *exec.Cmd
- func (e *Podman) Build(path string, tag string, attach Attach) *exec.Cmd
- func (e *Podman) Copy(args []string, attach Attach) *exec.Cmd
- func (e *Podman) Create(args []string, attach Attach) *exec.Cmd
- func (e *Podman) Exec(args []string, envVars map[string]string, sh bool, root bool, attach Attach) *exec.Cmd
- func (e *Podman) Exists(name string) bool
- func (e *Podman) IsDocker() bool
- func (e *Podman) IsRunning(name string) bool
- func (e *Podman) RawCommand(args []string, attach Attach) *exec.Cmd
- func (e *Podman) Remove(args []string, attach Attach) error
- func (e *Podman) Start(args []string, attach Attach) error
- func (e *Podman) Stop(args []string, attach Attach) error
- func (e *Podman) Version() ([]int64, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InsideContainer ¶
func InsideContainer() bool
Checks if we are inside a container
To do this we check the /run directory for .containerenv (podman) or .dockerenv (docker)
func PrintCommand ¶ added in v0.4.0
Prints the command to run in a more readable format where:
- Each argument is on a new line
- Flags are on the same line as their argument
- The args[1] is on the same line as the command
- The command is prefixed with a message
func PrintCommandR ¶ added in v0.4.0
Prints the command to run in a more readable format and returns the command to run
Format is the same as PrintCommand()
func ReplaceEnvVars ¶ added in v0.2.0
Replaces the following instances:
$USER -> os.Getenv("USER")
$HOME -> /home/$USER
$PWD -> os.Getwd()
Types ¶
type Attach ¶
type Attach struct { // If true, the container's Stdin will be attached to the current process. Stdin bool // If true, the container's Stdout will be attached to the current process. Stdout bool // If true, the container's Stderr will be attached to the current process. Stderr bool // If true, allocates a pseudo-TTY for the container. PseudoTTY bool }
type Podman ¶
type Podman struct {
// contains filtered or unexported fields
}
func (*Podman) Exec ¶
func (e *Podman) Exec(args []string, envVars map[string]string, sh bool, root bool, attach Attach) *exec.Cmd
Executes a command inside a running container and attaches (Stdin, Stdout) if "attach" is true.
func (*Podman) IsDocker ¶
Checks if the path contains the word "docker"
Mainly here so we can make this work on docker too.
func (*Podman) RawCommand ¶
Runs any podman subcommand (for example: ps)
func (*Podman) Remove ¶
Removes a container and returns an error in case of failure.
In arguments, the first argument has to be the container's name/id if no flag are added before of the name.
func (*Podman) Start ¶
Starts a container and returns an error in case of failure.
In arguments, the first argument should probably be the container's name/id.