utils

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package utils contains generic helpers, utilities and structs.

Index

Constants

This section is empty.

Variables

View Source
var LilipodBinPath = filepath.Join(GetLilipodHome(), "bin")

LilipodBinPath is the bin path internally used by lilipod.

Functions

func EnsureUNIXDependencies

func EnsureUNIXDependencies(ptyAgent []byte) error

EnsureUNIXDependencies will link the missing utility to internally managed busybox binary. If the binary does not exist, download it first. Hard dependencies include:

  • getsubuids
  • newuidmap
  • newgudmap

These are needed to correctly spawn user-mapped user namespaces. These cannot be downloaded as they either need to be setuid binaries or setcap binaries.

Other less crucial dependencies include:

  • tar
  • unshare
  • nsenter

These will be downloaded as statically compiled busybox binaries if absent.

Additionally the ptyAgent will be saved into lilipod's bin directory, ready to be injected in the containers.

func GetDefaultTable

func GetDefaultTable() table.Style

GetDefaultTable returns the default table style we use to print out tables.

func GetLilipodHome

func GetLilipodHome() string

GetLilipodHome will return where the program will save data. This function will search the environment or:

LILIPOD_HOME XDG_DATA_HOME HOME

These variable are searched in this order.

func SaveConfig

func SaveConfig(config Config, path string) error

SaveConfig saves current config from memory to json file.

Types

type Config

type Config struct {
	Env        []string `json:"env"`
	Cgroup     string   `json:"cgroup"`
	Created    string   `json:"created"`
	Gidmap     string   `json:"gidmap"`
	Hostname   string   `json:"hostname"`
	ID         string   `json:"id"`
	Image      string   `json:"image"`
	Ipc        string   `json:"ipc"`
	Names      string   `json:"names"`
	Network    string   `json:"network"`
	Pid        string   `json:"pid"`
	Privileged bool     `json:"privileged"`
	Size       string   `json:"size"`
	Status     string   `json:"status"`
	Time       string   `json:"time"`
	Uidmap     string   `json:"uidmap"`
	User       string   `json:"user"`
	Userns     string   `json:"userns"`
	Workdir    string   `json:"workdir"`
	Stopsignal string   `json:"stopsignal"`
	Mounts     []string `json:"mounts"`
	Labels     []string `json:"labels"`
	// entry point related
	Entrypoint []string `json:"entrypoint"`
}

Config is a struct that holds the information of the container we want to create.

Note that this is NOT OCI COMPLIANT, lilipod is oci-registry and images compliant, but doesn't need to create oci-compliant containers.

func GetDefaultConfig

func GetDefaultConfig() Config

GetDefaultConfig returns a plain container Config used to reset to defaults.

func InitConfig

func InitConfig(input []byte) (Config, error)

InitConfig returns an unmarshalled config from a byte array.

func LoadConfig

func LoadConfig(path string) (Config, error)

LoadConfig loads a config from file to config struct.

Jump to

Keyboard shortcuts

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