Skip to content

virt.heropods #

fn list_available_docker_images #

fn list_available_docker_images() []string

List available docker images that can be downloaded

fn new #

fn new(args FactoryInitArgs) !ContainerFactory

enum ContainerImageType #

enum ContainerImageType {
	alpine_3_20
	ubuntu_24_04
	ubuntu_25_04
	custom // For custom images downloaded via podman
}

Updated enum to be more flexible

enum ContainerStatus #

enum ContainerStatus {
	running
	stopped
	paused
	unknown
}

struct Container #

@[heap]
struct Container {
pub mut:
	name        string
	node        ?&builder.Node
	tmux_pane   ?&tmux.Pane
	crun_config ?&crun.CrunConfig
	factory     &ContainerFactory
}

fn (Container) start #

fn (mut self Container) start() !

fn (Container) stop #

fn (mut self Container) stop() !

fn (Container) delete #

fn (mut self Container) delete() !

fn (Container) exec #

fn (mut self Container) exec(cmd_ osal.Command) !string

Execute command inside the container

fn (Container) status #

fn (self Container) status() !ContainerStatus

fn (Container) cpu_usage #

fn (self Container) cpu_usage() !f64

Get CPU usage in percentage

fn (Container) mem_usage #

fn (self Container) mem_usage() !f64

Get memory usage in MB

fn (Container) tmux_pane #

fn (mut self Container) tmux_pane(args TmuxPaneArgs) !&tmux.Pane

fn (Container) node #

fn (mut self Container) node() !&builder.Node

fn (Container) config #

fn (self Container) config() !&crun.CrunConfig

Get the crun configuration for this container

fn (Container) set_memory_limit #

fn (mut self Container) set_memory_limit(limit_mb u64) !&Container

Container configuration customization methods

fn (Container) set_cpu_limits #

fn (mut self Container) set_cpu_limits(period u64, quota i64, shares u64) !&Container

fn (Container) add_mount #

fn (mut self Container) add_mount(source string, destination string, mount_type crun.MountType, options []crun.MountOption) !&Container

fn (Container) add_capability #

fn (mut self Container) add_capability(cap crun.Capability) !&Container

fn (Container) remove_capability #

fn (mut self Container) remove_capability(cap crun.Capability) !&Container

fn (Container) add_env #

fn (mut self Container) add_env(key string, value string) !&Container

fn (Container) set_working_dir #

fn (mut self Container) set_working_dir(dir string) !&Container

fn (Container) save_config #

fn (self Container) save_config() !

Save the current configuration to disk

struct ContainerFactory #

@[heap]
struct ContainerFactory {
pub mut:
	tmux_session string
	containers   map[string]&Container
	images       map[string]&ContainerImage
	crun_configs map[string]&crun.CrunConfig
	base_dir     string
}

fn (ContainerFactory) get #

fn (mut self ContainerFactory) get(args ContainerNewArgs) !&Container

fn (ContainerFactory) image_get #

fn (mut self ContainerFactory) image_get(name string) !&ContainerImage

Get image by name

fn (ContainerFactory) image_import #

fn (mut self ContainerFactory) image_import(args ImageImportArgs) !&ContainerImage

Import image from .tgz file

fn (ContainerFactory) image_new #

fn (mut self ContainerFactory) image_new(args ContainerImageArgs) !&ContainerImage

Create new image or get existing

fn (ContainerFactory) images_list #

fn (mut self ContainerFactory) images_list() ![]&ContainerImage

List all available images

fn (ContainerFactory) list #

fn (self ContainerFactory) list() ![]Container

List all containers currently managed by crun

fn (ContainerFactory) new #

fn (mut self ContainerFactory) new(args ContainerNewArgs) !&Container

struct ContainerImage #

@[heap]
struct ContainerImage {
pub mut:
	image_name  string @[required] // image is located in ${self.factory.base_dir}/images//rootfs
	docker_url  string // optional docker image URL
	rootfs_path string // path to the extracted rootfs
	size_mb     f64    // size in MB
	created_at  string // creation timestamp
	factory     &ContainerFactory @[skip; str: skip]
}

fn (ContainerImage) export #

fn (mut self ContainerImage) export(args ImageExportArgs) !

Export image to .tgz file

fn (ContainerImage) delete #

fn (mut self ContainerImage) delete() !

Delete image

fn (ContainerImage) info #

fn (self ContainerImage) info() map[string]string

Get image info as map

struct ContainerImageArgs #

@[params]
struct ContainerImageArgs {
pub mut:
	image_name string @[required] // image is located in ${self.factory.base_dir}/images//rootfs
	docker_url string // docker image URL like "alpine:3.20" or "ubuntu:24.04"
	reset      bool
}

struct ContainerNewArgs #

@[params]
struct ContainerNewArgs {
pub:
	name              string @[required]
	image             ContainerImageType = .alpine_3_20
	custom_image_name string // Used when image = .custom
	docker_url        string // Docker image URL for new images
	reset             bool
}

struct FactoryInitArgs #

@[params]
struct FactoryInitArgs {
pub:
	reset      bool
	use_podman bool = true
}

struct ImageExportArgs #

@[params]
struct ImageExportArgs {
pub mut:
	dest_path      string @[required] // destination .tgz file path
	compress_level int = 6 // compression level 1-9
}

struct ImageImportArgs #

@[params]
struct ImageImportArgs {
pub mut:
	source_path string @[required] // source .tgz file path
	reset       bool // overwrite if exists
}

struct TmuxPaneArgs #

struct TmuxPaneArgs {
pub mut:
	window_name string
	pane_nr     int
	pane_name   string            // optional
	cmd         string            // optional, will execute this cmd
	reset       bool              // if true will reset everything and restart a cmd
	env         map[string]string // optional, will set these env vars in the pane
}