Documentation ¶
Overview ¶
Start system process a any platform example host, proot/chroot, docker/podman, etc... and return standardized struct
Index ¶
- Variables
- func LocalBinExist(processConfig ProcExec) bool
- type DockerContainer
- func (docker *DockerContainer) AddPort(network string, local, remote uint16)
- func (docker *DockerContainer) AppendToStderr(w io.Writer) error
- func (docker *DockerContainer) AppendToStdin(r io.Reader) error
- func (docker *DockerContainer) AppendToStdout(w io.Writer) error
- func (docker *DockerContainer) Close() error
- func (docker DockerContainer) ContainerAddr() ([]netip.Addr, error)
- func (docker *DockerContainer) ExitCode() (int, error)
- func (docker *DockerContainer) Kill() error
- func (docker *DockerContainer) Signal(signal os.Signal) error
- func (docker *DockerContainer) Start(options ProcExec) error
- func (docker *DockerContainer) StderrFork() (io.ReadCloser, error)
- func (docker *DockerContainer) StdinFork() (io.WriteCloser, error)
- func (docker *DockerContainer) StdoutFork() (io.ReadCloser, error)
- func (docker *DockerContainer) Wait() error
- func (docker *DockerContainer) Write(p []byte) (int, error)
- type Env
- type Os
- func (cli *Os) AppendToStderr(w io.Writer) error
- func (cli *Os) AppendToStdin(r io.Reader) error
- func (cli *Os) AppendToStdout(w io.Writer) error
- func (w *Os) Close() error
- func (os *Os) ExitCode() (int, error)
- func (w *Os) Kill() error
- func (w *Os) Signal(sig os.Signal) error
- func (w *Os) Start(options ProcExec) error
- func (cli *Os) StderrFork() (io.ReadCloser, error)
- func (cli *Os) StdinFork() (io.WriteCloser, error)
- func (cli *Os) StdoutFork() (io.ReadCloser, error)
- func (os *Os) Wait() error
- func (os *Os) Write(w []byte) (int, error)
- type Proc
- type ProcExec
- type Proot
- type Writers
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrRunning error = errors.New("process running") // Process started ErrNoRunning error = errors.New("process is not running") // Process not started or not running )
View Source
var (
ErrNoExtractUbuntu error = errors.New("cannot extract Ubuntu base image")
)
Functions ¶
Types ¶
type DockerContainer ¶
type DockerContainer struct { DockerClient *client.Client ContainerName string Image string Platform string // Docker platform to run image Ports []nat.Port Volumes []string // contains filtered or unexported fields }
func NewDockerDefault ¶
func NewDockerDefault() (*DockerContainer, error)
Create Docker client connection and return new DockerContainer with "debian:latest" image
func (*DockerContainer) AddPort ¶
func (docker *DockerContainer) AddPort(network string, local, remote uint16)
Append port on start conteiner
func (*DockerContainer) AppendToStderr ¶
func (docker *DockerContainer) AppendToStderr(w io.Writer) error
func (*DockerContainer) AppendToStdin ¶
func (docker *DockerContainer) AppendToStdin(r io.Reader) error
func (*DockerContainer) AppendToStdout ¶
func (docker *DockerContainer) AppendToStdout(w io.Writer) error
func (*DockerContainer) Close ¶
func (docker *DockerContainer) Close() error
func (DockerContainer) ContainerAddr ¶
func (docker DockerContainer) ContainerAddr() ([]netip.Addr, error)
Get container addresses
func (*DockerContainer) ExitCode ¶
func (docker *DockerContainer) ExitCode() (int, error)
func (*DockerContainer) Kill ¶
func (docker *DockerContainer) Kill() error
func (*DockerContainer) Start ¶
func (docker *DockerContainer) Start(options ProcExec) error
func (*DockerContainer) StderrFork ¶
func (docker *DockerContainer) StderrFork() (io.ReadCloser, error)
func (*DockerContainer) StdinFork ¶
func (docker *DockerContainer) StdinFork() (io.WriteCloser, error)
func (*DockerContainer) StdoutFork ¶
func (docker *DockerContainer) StdoutFork() (io.ReadCloser, error)
func (*DockerContainer) Wait ¶
func (docker *DockerContainer) Wait() error
type Os ¶
type Os struct {
// contains filtered or unexported fields
}
func (*Os) StderrFork ¶
func (cli *Os) StderrFork() (io.ReadCloser, error)
func (*Os) StdoutFork ¶
func (cli *Os) StdoutFork() (io.ReadCloser, error)
type Proc ¶
type Proc interface { Start(options ProcExec) error // Start process in background Kill() error // Kill process with SIGKILL Close() error // Send ctrl + c (SIGINT) and wait process end Wait() error // Wait process Signal(s os.Signal) error // Send signal to process ExitCode() (int, error) // return process exit code, if running wait to get exit code Write(p []byte) (int, error) // Write to stdin AppendToStdin(r io.Reader) error // Add reader to stdin AppendToStdout(w io.Writer) error // Append writer to stdout AppendToStderr(w io.Writer) error // Append writer to stderr StdinFork() (io.WriteCloser, error) // Create fork stream from Stdin StdoutFork() (io.ReadCloser, error) // Create fork stream from Stdout StderrFork() (io.ReadCloser, error) // Create fork stream from Stderr }
Universal process struct
type ProcExec ¶
type ProcExec struct { Arguments []string // command and arguments Cwd string // Workdir path Environment Env // Envs to add to process }
Generic struct to start Process
type Proot ¶
type Proot struct { Rootfs string // Rootfs to mount to run proot Qemu string // Execute guest programs through QEMU, exp: "qemu-x86_64" or "qemu-x86_64-static" GID, UID uint // User and Group ID, default is root Binds map[string][]string // Bind mount directories, example: "/dev": {"/dev", "/root/dev"} => /dev -> /root/dev and /dev Os // Extends from Os struct }
Mount rootfs and run command insider in proot
if network not resolve names add nameserver to /etc/resolv.conf (`(echo 'nameserver 1.1.1.1'; echo 'nameserver 8.8.8.8') > /etc/resolv.conf`)
func (Proot) AddNameservers ¶
Append dns server to /etc/resolv.conf
Example: Proot.Proot(netip.MustParseAddr("8.8.8.8"), netip.MustParseAddr("1.1.1.1"))
func (Proot) DownloadUbuntuRootfs ¶
Download ubuntu base to host arch if avaible
example: Proot.DownloadUbuntuRootfs("", "") // Latest version to current arch example: Proot.DownloadUbuntuRootfs("24.10", "amd64") example: Proot.DownloadUbuntuRootfs("24.10", "arm64") example: Proot.DownloadUbuntuRootfs("24.10", "riscv64")
type Writers ¶
Write to many streamings and if closed remove from list
func (*Writers) AddNewWriter ¶
Click to show internal directories.
Click to hide internal directories.