Documentation
¶
Overview ¶
Package podman is a wrapper around os/exec to run podman commands.
Package podman is a 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() (major, minor, patch int64, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InsideContainer ¶
func InsideContainer() bool
InsideContainer 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
PrintCommand prints the command to run in a more readable format
func PrintCommandR ¶ added in v0.4.0
PrintCommandR 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
ReplaceEnvVars replaces some key environment variables with their values
Types ¶
type Attach ¶
type Attach struct { // Stdin sets if stdin should be attached to the current process. Stdin bool // Stdout sets if stdout will be attached to the current process. Stdout bool // Stderr sets if stderr will be attached to the current process. Stderr bool // PseudoTTY sets if podman should allocate a pseudo-TTY for the container. PseudoTTY bool }
Attach is config struct that sets the Stdin, Stdout and Stderr
type Podman ¶
type Podman struct {
// contains filtered or unexported fields
}
Podman is a struct that saves the path to the podman executable.
func (*Podman) Exec ¶
func (e *Podman) Exec(args []string, envVars map[string]string, sh bool, root bool, attach Attach) *exec.Cmd
Exec executes a command inside a running container and attaches (Stdin, Stdout) if "attach" is true.
func (*Podman) IsDocker ¶
IsDocker checks if the podman path contains the word "docker". Mainly here so we can make this work on docker too.
func (*Podman) RawCommand ¶
RawCommand runs any podman subcommand (for example: ps)
func (*Podman) Remove ¶
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 ¶
Start starts a container and returns an error in case of failure. The first argument has to be the container's name/id.