Skip to content

virt.crun #

specs on https://github.com/opencontainers/runtime-spec

fn example_custom #

fn example_custom() !

fn example_heropods_compatible #

fn example_heropods_compatible() !

fn get #

fn get(configs map[string]&CrunConfig, args FactoryArgs) !&CrunConfig

fn new #

fn new(mut configs map[string]&CrunConfig, args FactoryArgs) !&CrunConfig

enum Capability #

enum Capability {
	cap_chown
	cap_dac_override
	cap_dac_read_search
	cap_fowner
	cap_fsetid
	cap_kill
	cap_setgid
	cap_setuid
	cap_setpcap
	cap_linux_immutable
	cap_net_bind_service
	cap_net_broadcast
	cap_net_admin
	cap_net_raw
	cap_ipc_lock
	cap_ipc_owner
	cap_sys_module
	cap_sys_rawio
	cap_sys_chroot
	cap_sys_ptrace
	cap_sys_pacct
	cap_sys_admin
	cap_sys_boot
	cap_sys_nice
	cap_sys_resource
	cap_sys_time
	cap_sys_tty_config
	cap_mknod
	cap_lease
	cap_audit_write
	cap_audit_control
	cap_setfcap
	cap_mac_override
	cap_mac_admin
	cap_syslog
	cap_wake_alarm
	cap_block_suspend
	cap_audit_read
}

fn (Capability) to_string #

fn (cap Capability) to_string() string

enum MountOption #

enum MountOption {
	rw
	ro
	noexec
	nosuid
	nodev
	rbind
	relatime
	strictatime
	mode
	size
}

fn (MountOption) to_string #

fn (option MountOption) to_string() string

enum MountType #

enum MountType {
	bind
	tmpfs
	proc
	sysfs
	devpts
	mqueue
	cgroup
	nfs
	overlay
}

Enums for type safety but convert to strings

fn (MountType) to_string #

fn (mount_type MountType) to_string() string

Convert enum values to their string representations

enum RlimitType #

enum RlimitType {
	rlimit_cpu
	rlimit_fsize
	rlimit_data
	rlimit_stack
	rlimit_core
	rlimit_rss
	rlimit_nproc
	rlimit_nofile
	rlimit_memlock
	rlimit_as
	rlimit_lock
	rlimit_sigpending
	rlimit_msgqueue
	rlimit_nice
	rlimit_rtprio
	rlimit_rttime
}

fn (RlimitType) to_string #

fn (rlimit RlimitType) to_string() string

struct BlockIO #

struct BlockIO {
pub mut:
	weight u16 @[omitempty]
}

struct CPU #

struct CPU {
pub mut:
	shares u64    @[omitempty]
	quota  i64    @[omitempty]
	period u64    @[omitempty]
	cpus   string @[omitempty]
	mems   string @[omitempty]
}

struct Capabilities #

struct Capabilities {
pub mut:
	bounding    []string
	effective   []string
	inheritable []string
	permitted   []string
	ambient     []string
}

struct CrunConfig #

struct CrunConfig {
pub mut:
	name string
	spec Spec
}

fn (CrunConfig) add_capability #

fn (mut config CrunConfig) add_capability(cap Capability) &CrunConfig

fn (CrunConfig) add_env #

fn (mut config CrunConfig) add_env(key string, value string) &CrunConfig

fn (CrunConfig) add_masked_path #

fn (mut config CrunConfig) add_masked_path(path string) &CrunConfig

fn (CrunConfig) add_mount #

fn (mut config CrunConfig) add_mount(destination string, source string, typ MountType, options []MountOption) &CrunConfig

fn (CrunConfig) add_readonly_path #

fn (mut config CrunConfig) add_readonly_path(path string) &CrunConfig

fn (CrunConfig) add_rlimit #

fn (mut config CrunConfig) add_rlimit(typ RlimitType, hard u64, soft u64) &CrunConfig

fn (CrunConfig) remove_capability #

fn (mut config CrunConfig) remove_capability(cap Capability) &CrunConfig

fn (CrunConfig) save_to_file #

fn (config CrunConfig) save_to_file(path string) !

Convenience method to save JSON to file

fn (CrunConfig) set_command #

fn (mut config CrunConfig) set_command(args []string) &CrunConfig

Configuration methods with builder pattern

fn (CrunConfig) set_cpu_limits #

fn (mut config CrunConfig) set_cpu_limits(period u64, quota i64, shares u64) &CrunConfig

fn (CrunConfig) set_hostname #

fn (mut config CrunConfig) set_hostname(hostname string) &CrunConfig

fn (CrunConfig) set_memory_limit #

fn (mut config CrunConfig) set_memory_limit(limit_bytes u64) &CrunConfig

fn (CrunConfig) set_no_new_privileges #

fn (mut config CrunConfig) set_no_new_privileges(value bool) &CrunConfig

fn (CrunConfig) set_pids_limit #

fn (mut config CrunConfig) set_pids_limit(limit i64) &CrunConfig

fn (CrunConfig) set_rootfs #

fn (mut config CrunConfig) set_rootfs(path string, readonly bool) &CrunConfig

fn (CrunConfig) set_terminal #

fn (mut config CrunConfig) set_terminal(value bool) &CrunConfig

fn (CrunConfig) set_user #

fn (mut config CrunConfig) set_user(uid u32, gid u32, additional_gids []u32) &CrunConfig

fn (CrunConfig) set_working_dir #

fn (mut config CrunConfig) set_working_dir(cwd string) &CrunConfig

fn (CrunConfig) to_json #

fn (config CrunConfig) to_json() !string

Simple JSON generation using V's built-in json module

fn (CrunConfig) validate #

fn (config CrunConfig) validate() !

Validate the configuration

struct FactoryArgs #

@[params]
struct FactoryArgs {
pub mut:
	name string = 'default'
}

struct Hook #

struct Hook {
pub mut:
	path string
	args []string
	env  []string
}

struct Hooks #

struct Hooks {
pub mut:
	prestart  []Hook
	poststart []Hook
	poststop  []Hook
}

struct Linux #

struct Linux {
pub mut:
	namespaces     []LinuxNamespace
	resources      LinuxResources
	devices        []LinuxDevice
	masked_paths   []string         @[json: 'maskedPaths']
	readonly_paths []string         @[json: 'readonlyPaths']
	uid_mappings   []LinuxIDMapping @[json: 'uidMappings']
	gid_mappings   []LinuxIDMapping @[json: 'gidMappings']
}

struct LinuxDevice #

struct LinuxDevice {
pub mut:
	path      string
	typ       string @[json: 'type']
	major     i64
	minor     i64
	file_mode u32 @[json: 'fileMode']
	uid       u32
	gid       u32
}

struct LinuxIDMapping #

struct LinuxIDMapping {
pub mut:
	container_id u32 @[json: 'containerID']
	host_id      u32 @[json: 'hostID']
	size         u32
}

struct LinuxNamespace #

struct LinuxNamespace {
pub mut:
	typ  string @[json: 'type']
	path string @[omitempty]
}

struct LinuxResources #

struct LinuxResources {
pub mut:
	memory Memory
	cpu    CPU
	pids   Pids
	blkio  BlockIO
}

struct Memory #

struct Memory {
pub mut:
	limit       u64 @[omitempty]
	reservation u64 @[omitempty]
	swap        u64 @[omitempty]
	kernel      u64 @[omitempty]
	swappiness  i64 @[omitempty]
}

struct Mount #

struct Mount {
pub mut:
	destination string
	typ         string @[json: 'type']
	source      string
	options     []string
}

struct Pids #

struct Pids {
pub mut:
	limit i64 @[omitempty]
}

struct Platform #

struct Platform {
pub mut:
	os   string = 'linux'
	arch string = 'amd64'
}

struct Process #

struct Process {
pub mut:
	terminal          bool = true
	user              User
	args              []string
	env               []string
	cwd               string = '/'
	capabilities      Capabilities
	rlimits           []Rlimit
	no_new_privileges bool @[json: 'noNewPrivileges']
}

struct Rlimit #

struct Rlimit {
pub mut:
	typ  string @[json: 'type']
	hard u64
	soft u64
}

struct Root #

struct Root {
pub mut:
	path     string
	readonly bool
}

struct Spec #

struct Spec {
pub mut:
	oci_version string @[json: 'ociVersion']
	platform    Platform
	process     Process
	root        Root
	hostname    string
	mounts      []Mount
	linux       Linux
	hooks       Hooks
}

OCI Runtime Spec structures that can be directly encoded to JSON

struct User #

struct User {
pub mut:
	uid             u32
	gid             u32
	additional_gids []u32 @[json: 'additionalGids']
}