utils

package
v4.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2022 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDetach = define.ErrDetach

ErrDetach is an error indicating that the user manually detached from the container.

Functions

func CopyDetachable

func CopyDetachable(dst io.Writer, src io.Reader, keys []byte) (written int64, err error)

CopyDetachable is similar to io.Copy but support a detach key sequence to break out.

func CreateSCPCommand

func CreateSCPCommand(cmd *exec.Cmd, command []string) *exec.Cmd

CreateSCPCommand takes an existing command, appends the given arguments and returns a configured podman command for image scp

func CreateTarFromSrc

func CreateTarFromSrc(source string, dest string) error

Creates a new tar file and wrties bytes from io.ReadCloser

func ExecCmd

func ExecCmd(name string, args ...string) (string, error)

ExecCmd executes a command with args and returns its output as a string along with an error, if any.

func ExecCmdWithStdStreams

func ExecCmdWithStdStreams(stdin io.Reader, stdout, stderr io.Writer, env []string, name string, args ...string) error

ExecCmdWithStdStreams execute a command with the specified standard streams.

func GetCgroupProcess

func GetCgroupProcess(pid int) (string, error)

GetCgroupProcess returns the cgroup for the specified process process.

func GetOwnCgroup

func GetOwnCgroup() (string, error)

GetOwnCgroup returns the cgroup for the current process.

func GetOwnCgroupDisallowRoot

func GetOwnCgroupDisallowRoot() (string, error)

func GetRandomPort

func GetRandomPort() (int, error)

Find a random, open port on the host.

func LoginUser

func LoginUser(user string) (*exec.Cmd, error)

LoginUser starts the user process on the host so that image scp can use systemd-run

func MovePauseProcessToScope

func MovePauseProcessToScope(pausePidPath string)

MovePauseProcessToScope moves the pause process used for rootless mode to keep the namespaces alive to a separate scope.

func MoveRootlessNetnsSlirpProcessToUserSlice

func MoveRootlessNetnsSlirpProcessToUserSlice(pid int) error

MoveRootlessNetnsSlirpProcessToUserSlice moves the slirp4netns process for the rootless netns into a different scope so that systemd does not kill it with a container.

func MoveUnderCgroupSubtree

func MoveUnderCgroupSubtree(subtree string) error

MoveUnderCgroupSubtree moves the PID under a cgroup subtree.

func RemoveScientificNotationFromFloat

func RemoveScientificNotationFromFloat(x float64) (float64, error)

RemoveScientificNotationFromFloat returns a float without any scientific notation if the number has any. golang does not handle conversion of float64s that have scientific notation in them and otherwise stinks. please replace this if you have a better implementation.

func RunUnderSystemdScope

func RunUnderSystemdScope(pid int, slice string, unitName string) error

RunUnderSystemdScope adds the specified pid to a systemd scope

func RunsOnSystemd

func RunsOnSystemd() bool

RunsOnSystemd returns whether the system is using systemd

func Tar

func Tar(source string) (io.ReadCloser, error)

Tar creates a tarball from source and returns a readcloser of it

func TarToFilesystem

func TarToFilesystem(source string, tarball *os.File) error

TarToFilesystem creates a tarball from source and writes to an os.file provided

func UntarToFileSystem

func UntarToFileSystem(dest string, tarball *os.File, options *archive.TarOptions) error

UntarToFileSystem untars an os.file of a tarball to a destination in the filesystem

Types

This section is empty.

Jump to

Keyboard shortcuts

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