host

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2026 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ContainerEnvVar is used to set container name.
	ContainerEnvVar = "CLOUDLESS_CONTAINER"
)

Variables

View Source
var (
	// ErrPowerOff means that host should be powered off.
	ErrPowerOff = errors.New("power off requested")

	// ErrReboot means that host should be rebooted.
	ErrReboot = errors.New("reboot requested")

	// ErrNotThisHost is an indicator that spec is for different host.
	ErrNotThisHost = errors.New("not this host")

	// ErrHostFound is an indicator that this is the host matching the spec.
	ErrHostFound = errors.New("host found")
)
View Source
var DashboardBoxes grafanatypes.Dashboard

DashboardBoxes is the dashboard providing basic information about running boxes.

Functions

func ConfigureKernelModules

func ConfigureKernelModules(kernelModules []kernel.Module) error

ConfigureKernelModules loads kernel modules.

func IsContainer

func IsContainer() bool

IsContainer checks if we are inside container.

func Run

func Run(ctx context.Context, configurators ...Configurator) error

Run runs host.

Types

type Configuration

type Configuration struct {
	// contains filtered or unexported fields
}

Configuration allows service to configure the required host settings.

func NewSubconfiguration

func NewSubconfiguration(c *Configuration) (*Configuration, func())

NewSubconfiguration creates subconfiguration.

func (*Configuration) AddBridges

func (c *Configuration) AddBridges(bridges ...InterfaceConfig)

AddBridges configures bridges.

func (*Configuration) AddContainerMirrors

func (c *Configuration) AddContainerMirrors(mirrors ...string)

AddContainerMirrors adds container image mirrors.

func (*Configuration) AddDNSes

func (c *Configuration) AddDNSes(dnses ...net.IP)

AddDNSes adds DNS servers.

func (*Configuration) AddFirewallRules

func (c *Configuration) AddFirewallRules(sources ...firewall.RuleSource)

AddFirewallRules add firewall rules.

func (*Configuration) AddHugePages

func (c *Configuration) AddHugePages(hugePages uint64)

AddHugePages adds number of hugepages to be allocated.

func (*Configuration) AddMount

func (c *Configuration) AddMount(source, target string, writable bool)

AddMount adds mount.

func (*Configuration) AddNetworks

func (c *Configuration) AddNetworks(networks ...InterfaceConfig)

AddNetworks configures networks.

func (*Configuration) AddRoutes

func (c *Configuration) AddRoutes(routes ...Route)

AddRoutes adds static routes.

func (*Configuration) AddVLANs

func (c *Configuration) AddVLANs(vlans ...VLANConfig)

AddVLANs configures vlans.

func (*Configuration) AddYumMirrors

func (c *Configuration) AddYumMirrors(mirrors ...string)

AddYumMirrors adds package repository mirrors.

func (*Configuration) ContainerImages

func (c *Configuration) ContainerImages() []string

ContainerImages returns the list of container images required by any host.

func (*Configuration) ContainerMirrors

func (c *Configuration) ContainerMirrors() []string

ContainerMirrors returns list of container image mirrors.

func (*Configuration) ContainerOnly

func (c *Configuration) ContainerOnly()

ContainerOnly requires image to be run inside container.

func (*Configuration) HostOnly

func (c *Configuration) HostOnly()

HostOnly requires image to be run on host.

func (*Configuration) Hostname

func (c *Configuration) Hostname() string

Hostname returns hostname.

func (*Configuration) IsContainer

func (c *Configuration) IsContainer() bool

IsContainer informs if configurator is executed in the context of container.

func (*Configuration) MetricSets added in v0.2.0

func (c *Configuration) MetricSets() []*metrics.Set

MetricSets returns metric sets.

func (*Configuration) Packages

func (c *Configuration) Packages() []string

Packages returns the list of packages configured for any host.

func (*Configuration) Prepare

func (c *Configuration) Prepare(prepares ...PrepareFn)

Prepare adds prepare function to be called.

func (*Configuration) Prune

func (c *Configuration) Prune(prunes ...PruneFn)

Prune adds prune function to be called.

func (*Configuration) RegisterMetrics

func (c *Configuration) RegisterMetrics(sets ...*metrics.Set)

RegisterMetrics registers metric sets.

func (*Configuration) RemoteLogging

func (c *Configuration) RemoteLogging(lokiURL string)

RemoteLogging configures remote logging.

func (*Configuration) RequireContainers

func (c *Configuration) RequireContainers(images ...string)

RequireContainers is called to download container images.

func (*Configuration) RequireIPForwarding

func (c *Configuration) RequireIPForwarding()

RequireIPForwarding is called if host requires IP forwarding to be enabled.

func (*Configuration) RequireInitramfs

func (c *Configuration) RequireInitramfs()

RequireInitramfs is called if host requires initramfs to be generated.

func (*Configuration) RequireKernelModules

func (c *Configuration) RequireKernelModules(kernelModules ...kernel.Module)

RequireKernelModules is called to load kernel modules.

func (*Configuration) RequirePackages

func (c *Configuration) RequirePackages(packages ...string)

RequirePackages is called to install packages.

func (*Configuration) RequireVirt

func (c *Configuration) RequireVirt()

RequireVirt is called if host requires virtualization services.

func (*Configuration) Sealed

func (c *Configuration) Sealed() SealedConfiguration

Sealed gives access to information collected by configurators.

func (*Configuration) SetGateway

func (c *Configuration) SetGateway(gateway net.IP)

SetGateway sets gateway.

func (*Configuration) SetHostname

func (c *Configuration) SetHostname(hostname string)

SetHostname sets hostname.

func (*Configuration) StartServices

func (c *Configuration) StartServices(services ...ServiceConfig)

StartServices configures services to be started on host.

type Configurator

type Configurator func(c *Configuration) error

Configurator is the function called to collect host configuration.

type InterfaceConfig

type InterfaceConfig struct {
	Name       string
	MasterName string
	MAC        net.HardwareAddr
	IPs        []net.IPNet
}

InterfaceConfig contains network interface configuration.

type PrepareFn

type PrepareFn func(ctx context.Context) error

PrepareFn is the function type used to register functions preparing host.

type PruneFn

type PruneFn func() (bool, error)

PruneFn is the function type used to register functions saying if root directory should be pruned.

type Route

type Route struct {
	Destination net.IPNet
	Gateway     net.IP
}

Route defines static route.

type SealedConfiguration

type SealedConfiguration interface {
	MetricSets() []*metrics.Set
	Packages() []string
	ContainerImages() []string
	Hostname() string
	ContainerMirrors() []string
}

SealedConfiguration exposes information collected by the configurators.

type ServiceConfig

type ServiceConfig struct {
	Name   string
	OnExit parallel.OnExit
	TaskFn parallel.Task
}

ServiceConfig contains service configuration.

type VLANConfig

type VLANConfig struct {
	Name       string
	ParentName string
	VLANID     int
	IPs        []net.IPNet
}

VLANConfig contains vlan interface configuration.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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