config

package
v2.10.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 31 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DefaultWebUIListenAddress = ":8080"
	FilePrefix                = "file://"
)
View Source
const (
	KiB
	MiB
	GiB
	TiB
)
View Source
const DefaultHeader = "#cloud-config"

Variables

This section is empty.

Functions

func AddHeader

func AddHeader(header, data string) string

func BootedFrom

func BootedFrom(runner v1.Runner, label string) bool

BootedFrom will check if we are booting from the given label

func DetectPreConfiguredDevice added in v2.8.10

func DetectPreConfiguredDevice(logger sdkTypes.KairosLogger) (string, error)

DetectPreConfiguredDevice returns a disk that has partitions labeled with Kairos labels. It can be used to detect a pre-configured device.

func FilterKeys

func FilterKeys(d []byte) ([]byte, error)

FilterKeys is used to pass to any other pkg which might want to see which part of the config matches the Kairos config.

func FromString

func FromString(s string, o interface{}) error

func GetSourceSize

func GetSourceSize(config *Config, source *v1.ImageSource) (int64, error)

GetSourceSize will try to gather the actual size of the source Useful to create the exact size of images and by side effect the partition size This helps adjust the size to be juuuuust right. It can still be manually override from the cloud config by setting all values manually But by default it should adjust the sizes properly

func HasHeader

func HasHeader(userdata, head string) (bool, string)

func MergeYAML

func MergeYAML(objs ...interface{}) ([]byte, error)

func NewInstallElementalPartitions

func NewInstallElementalPartitions(log sdkTypes.KairosLogger, spec *v1.InstallSpec) v1.ElementalPartitions

func NewInstallSpec

func NewInstallSpec(cfg *Config) (*v1.InstallSpec, error)

NewInstallSpec returns an InstallSpec struct all based on defaults and basic host checks (e.g. EFI vs BIOS)

func NewResetSpec

func NewResetSpec(cfg *Config) (*v1.ResetSpec, error)

NewResetSpec returns a ResetSpec struct all based on defaults and current host state

func NewUkiInstallSpec

func NewUkiInstallSpec(cfg *Config) (*v1.InstallUkiSpec, error)

func NewUkiResetSpec added in v2.7.8

func NewUkiResetSpec(cfg *Config) (spec *v1.ResetUkiSpec, err error)

func NewUkiUpgradeSpec

func NewUkiUpgradeSpec(cfg *Config) (*v1.UpgradeUkiSpec, error)

func NewUpgradeSpec

func NewUpgradeSpec(cfg *Config) (*v1.UpgradeSpec, error)

NewUpgradeSpec returns an UpgradeSpec struct all based on defaults and current host state

func ReadInstallSpecFromConfig

func ReadInstallSpecFromConfig(c *Config) (*v1.InstallSpec, error)

ReadInstallSpecFromConfig will return a proper v1.InstallSpec based on an agent Config

func ReadResetSpecFromConfig

func ReadResetSpecFromConfig(c *Config) (*v1.ResetSpec, error)

ReadResetSpecFromConfig will return a proper v1.ResetSpec based on an agent Config

func ReadSpecFromCloudConfig

func ReadSpecFromCloudConfig(r *Config, spec string) (v1.Spec, error)

ReadSpecFromCloudConfig returns a v1.Spec for the given spec

func ReadUkiInstallSpecFromConfig

func ReadUkiInstallSpecFromConfig(c *Config) (*v1.InstallUkiSpec, error)

ReadUkiInstallSpecFromConfig will return a proper v1.InstallUkiSpec based on an agent Config

func ReadUkiResetSpecFromConfig

func ReadUkiResetSpecFromConfig(c *Config) (*v1.ResetUkiSpec, error)

ReadUkiResetSpecFromConfig will return a proper v1.ResetUkiSpec based on an agent Config

func ReadUkiUpgradeSpecFromConfig added in v2.7.13

func ReadUkiUpgradeSpecFromConfig(c *Config) (*v1.UpgradeUkiSpec, error)

ReadUkiUpgradeSpecFromConfig will return a proper v1.UpgradeUkiSpec based on an agent Config

func ReadUpgradeSpecFromConfig

func ReadUpgradeSpecFromConfig(c *Config) (*v1.UpgradeSpec, error)

ReadUpgradeSpecFromConfig will return a proper v1.UpgradeSpec based on an agent Config

func SaveCloudConfig

func SaveCloudConfig(name Stage, yc yip.YipConfig) error

func UnmarshalerHook

func UnmarshalerHook() mapstructure.DecodeHookFunc

func WithClient

func WithClient(client v1.HTTPClient) func(r *Config)

func WithCloudInitRunner

func WithCloudInitRunner(ci v1.CloudInitRunner) func(r *Config)

func WithFs

func WithFs(fs v1.FS) func(r *Config)

func WithImageExtractor

func WithImageExtractor(extractor v1.ImageExtractor) func(r *Config)

func WithLogger

func WithLogger(logger sdkTypes.KairosLogger) func(r *Config)

func WithMounter

func WithMounter(mounter mount.Interface) func(r *Config)

func WithPlatform

func WithPlatform(platform string) func(r *Config)

func WithRunner

func WithRunner(runner v1.Runner) func(r *Config)

func WithSyscall

func WithSyscall(syscall v1.SyscallInterface) func(r *Config)

Types

type Bundle

type Bundle struct {
	Repository string   `yaml:"repository,omitempty"`
	Rootfs     string   `yaml:"rootfs_path,omitempty"`
	DB         string   `yaml:"db_path,omitempty"`
	LocalFile  bool     `yaml:"local_file,omitempty"`
	Targets    []string `yaml:"targets,omitempty"`
}

type Bundles

type Bundles []Bundle

func (Bundles) Options

func (b Bundles) Options() (res [][]bundles.BundleOption)

type Config

type Config struct {
	Install                   *Install `yaml:"install,omitempty"`
	collector.Config          `yaml:"-"`
	ConfigURL                 string                `yaml:"config_url,omitempty"`
	Options                   map[string]string     `yaml:"options,omitempty"`
	FailOnBundleErrors        bool                  `yaml:"fail_on_bundles_errors,omitempty"`
	Bundles                   Bundles               `yaml:"bundles,omitempty"`
	GrubOptions               map[string]string     `yaml:"grub_options,omitempty"`
	Env                       []string              `yaml:"env,omitempty"`
	Debug                     bool                  `yaml:"debug,omitempty" mapstructure:"debug"`
	Strict                    bool                  `yaml:"strict,omitempty" mapstructure:"strict"`
	CloudInitPaths            []string              `yaml:"cloud-init-paths,omitempty" mapstructure:"cloud-init-paths"`
	EjectCD                   bool                  `yaml:"eject-cd,omitempty" mapstructure:"eject-cd"`
	Logger                    sdkTypes.KairosLogger `yaml:"-"`
	Fs                        v1.FS                 `yaml:"-"`
	Mounter                   mount.Interface       `yaml:"-"`
	Runner                    v1.Runner             `yaml:"-"`
	Syscall                   v1.SyscallInterface   `yaml:"-"`
	CloudInitRunner           v1.CloudInitRunner    `yaml:"-"`
	ImageExtractor            v1.ImageExtractor     `yaml:"-"`
	Client                    v1.HTTPClient         `yaml:"-"`
	Platform                  *v1.Platform          `yaml:"-"`
	Cosign                    bool                  `yaml:"cosign,omitempty" mapstructure:"cosign"`
	Verify                    bool                  `yaml:"verify,omitempty" mapstructure:"verify"`
	CosignPubKey              string                `yaml:"cosign-key,omitempty" mapstructure:"cosign-key"`
	Arch                      string                `yaml:"arch,omitempty" mapstructure:"arch"`
	SquashFsCompressionConfig []string              `yaml:"squash-compression,omitempty" mapstructure:"squash-compression"`
	SquashFsNoCompression     bool                  `yaml:"squash-no-compression,omitempty" mapstructure:"squash-no-compression"`
	UkiMaxEntries             int                   `yaml:"uki-max-entries,omitempty" mapstructure:"uki-max-entries"`
}

func NewConfig

func NewConfig(opts ...GenericOptions) *Config

func Scan

func Scan(opts ...collector.Option) (c *Config, err error)

Scan is a wrapper around collector.Scan that sets the logger to the default Kairos logger

func ScanNoLogs added in v2.8.6

func ScanNoLogs(opts ...collector.Option) (c *Config, err error)

ScanNoLogs is a wrapper around Scan that sets the logger to null

func (Config) HasConfigURL

func (c Config) HasConfigURL() bool

HasConfigURL returns true if ConfigURL has been set and false if it's empty.

func (Config) LoadInstallState

func (c Config) LoadInstallState() (*v1.InstallState, error)

LoadInstallState loads the state.yaml file and unmarshals it to an InstallState object

func (*Config) Sanitize

func (c *Config) Sanitize() error

Sanitize checks the consistency of the struct, returns error if unsolvable inconsistencies are found

func (Config) WriteInstallState

func (c Config) WriteInstallState(i *v1.InstallState, statePath, recoveryPath string) error

WriteInstallState writes the state.yaml file to the given state and recovery paths

type GenericOptions

type GenericOptions func(a *Config)

type Install

type Install struct {
	Auto                   bool              `yaml:"auto,omitempty"`
	Reboot                 bool              `yaml:"reboot,omitempty"`
	NoFormat               bool              `yaml:"no-format,omitempty"`
	Device                 string            `yaml:"device,omitempty"`
	Poweroff               bool              `yaml:"poweroff,omitempty"`
	GrubOptions            map[string]string `yaml:"grub_options,omitempty"`
	Bundles                Bundles           `yaml:"bundles,omitempty"`
	Encrypt                []string          `yaml:"encrypted_partitions,omitempty"`
	SkipEncryptCopyPlugins bool              `yaml:"skip_copy_kcrypt_plugin,omitempty"`
	Env                    []string          `yaml:"env,omitempty"`
	Source                 string            `yaml:"source,omitempty"`
	EphemeralMounts        []string          `yaml:"ephemeral_mounts,omitempty"`
	BindMounts             []string          `yaml:"bind_mounts,omitempty"`
}

type Stage

type Stage string
const (
	NetworkStage   Stage = "network"
	InitramfsStage Stage = "initramfs"
)

func (Stage) String

func (n Stage) String() string

type Unmarshaler

type Unmarshaler interface {
	CustomUnmarshal(interface{}) (bool, error)
}

Jump to

Keyboard shortcuts

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