podman

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

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 ReplaceEnvVars added in v0.2.0

func ReplaceEnvVars(s string) string

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 New

func New(path string) Podman

func (*Podman) Attach added in v0.2.0

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

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

Builds a new image using Podman

func (*Podman) Copy

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

Copies files into the container

func (*Podman) Create

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

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

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

Returns a boolean that indicates if the container was found.

func (*Podman) IsDocker

func (e *Podman) IsDocker() bool

Checks if the path contains the word "docker"

Mainly here so we can make this work on docker too.

func (*Podman) RawCommand

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

Runs any podman subcommand (for example: ps)

func (*Podman) Remove

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

Removes a container and returns an error in case of failure.

In arguments, the first argument can should 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

Starts a container and returns an error in case of failure.

In arguments, the first argument should probably be the container's name/id.

func (*Podman) Stop

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

Stops a container and returns an error in case of failure.

In arguments, the first argument can should the container's name/id if no flag are added before of the name.

func (*Podman) Version

func (e *Podman) Version() ([]int64, error)

Gets the current podman version

It parses the version out of the version string, returns a list in the following format:

[]int64{major, minor, patch}

Jump to

Keyboard shortcuts

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