podman

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package podman is a wrapper around os/exec to run podman commands.

Index

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

func PrintCommand(msg string, cmd *exec.Cmd)

PrintCommand prints the command to run in a more readable format

func PrintCommandR added in v0.4.0

func PrintCommandR(msg string, cmd *exec.Cmd) *exec.Cmd

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

func ReplaceEnvVars(s string) string

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 New

func New(path string) Podman

New creates a new Podman struct with the path to the podman executable.

func (*Podman) Attach added in v0.2.0

func (e *Podman) Attach(args []string, attach Attach) *exec.Cmd

Attach attaches to the podman container

func (*Podman) Build added in v0.1.0

func (e *Podman) Build(path string, tag string, attach Attach) *exec.Cmd

Build builds a new image using Podman

func (*Podman) Commit added in v0.5.0

func (e *Podman) Commit(args []string, attach Attach) *exec.Cmd

Commit commits the container to an image

func (*Podman) Copy

func (e *Podman) Copy(args []string, attach Attach) *exec.Cmd

Copy copies files into the container

func (*Podman) Create

func (e *Podman) Create(args []string, attach Attach) *exec.Cmd

Create creates a container using the arguments provided.

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) Exists

func (e *Podman) Exists(name string) bool

Exists returns a boolean that indicates if the container was found.

func (*Podman) IsDocker

func (e *Podman) IsDocker() bool

IsDocker checks if the podman path contains the word "docker". Mainly here so we can make this work on docker too.

func (*Podman) IsRunning added in v0.4.0

func (e *Podman) IsRunning(name string) bool

IsRunning checks if the container is running

func (*Podman) RawCommand

func (e *Podman) RawCommand(args []string, attach Attach) *exec.Cmd

RawCommand runs any podman subcommand (for example: ps)

func (*Podman) Remove

func (e *Podman) Remove(args []string, attach Attach) error

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

func (e *Podman) Start(args []string, attach Attach) error

Start starts a container and returns an error in case of failure. The first argument has to be the container's name/id.

func (*Podman) Stop

func (e *Podman) Stop(args []string, attach Attach) error

Stop stops 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) Version

func (e *Podman) Version() (major, minor, patch int64, err error)

Version gets the current podman version

Jump to

Keyboard shortcuts

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