statemachine

package
v0.0.0-...-9b4757f Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2025 License: GPL-3.0 Imports: 49 Imported by: 0

Documentation

Overview

Package statemachine provides the functions and structs to set up and execute a state machine based ubuntu-image build

Index

Constants

This section is empty.

Variables

View Source
var (
	Mke2fsConfigEnv  = "MKE2FS_CONFIG"
	Mke2fsConfigFile = "mke2fs.conf"
	Mke2fsBasepath   = "/etc/ubuntu-image/mkfs"
)

Functions

func WriteSnapManifest

func WriteSnapManifest(snapsDir string, outputPath string) error

WriteSnapManifest generates a snap manifest based on the contents of the selected snapsDir

Types

type ClassicStateMachine

type ClassicStateMachine struct {
	StateMachine
	ImageDef imagedefinition.ImageDefinition
	Args     commands.ClassicArgs
}

ClassicStateMachine embeds StateMachine and adds the command line flags specific to classic images

func (*ClassicStateMachine) Architecture

func (classicStateMachine *ClassicStateMachine) Architecture() (string, error)

func (*ClassicStateMachine) SetSeries

func (classicStateMachine *ClassicStateMachine) SetSeries() error

func (*ClassicStateMachine) Setup

func (classicStateMachine *ClassicStateMachine) Setup() error

Setup assigns variables and calls other functions that must be executed before Run()

type SmInterface

type SmInterface interface {
	Setup() error
	Run() error
	Teardown() error
	SetCommonOpts(commonOpts *commands.CommonOpts, stateMachineOpts *commands.StateMachineOpts)
	SetSeries() error
	Architecture() (string, error)
}

SmInterface allows different image types to implement their own setup/run/teardown functions

type SnapStateMachine

type SnapStateMachine struct {
	StateMachine
	Opts commands.SnapOpts
	Args commands.SnapArgs
}

SnapStateMachine embeds StateMachine and adds the command line flags specific to snap images

func (*SnapStateMachine) Architecture

func (snapStateMachine *SnapStateMachine) Architecture() (string, error)

func (*SnapStateMachine) SetSeries

func (snapStateMachine *SnapStateMachine) SetSeries() error

func (*SnapStateMachine) Setup

func (snapStateMachine *SnapStateMachine) Setup() error

Setup assigns variables and calls other functions that must be executed before Run().

type StateMachine

type StateMachine struct {
	CurrentStep      string        // tracks the current progress of the state machine
	StepsTaken       int           // counts the number of steps taken
	ConfDefPath      string        // directory holding the model assertion / image definition file
	YamlFilePath     string        // the location for the gadget yaml file
	IsSeeded         bool          // core 20 images are seeded
	RootfsVolName    string        // volume on which the rootfs is located
	RootfsPartNum    int           // rootfs partition number
	BootPartNum      int           // boot partition number
	HasBIOSPartition bool          // whether the image is holding partitions for BIOS
	SectorSize       quantity.Size // parsed (converted) sector size
	RootfsSize       quantity.Size

	// imported from snapd, the info parsed from gadget.yaml
	GadgetInfo *gadget.Info

	// Initially filled with the parsing of --image-size flags
	// Will then track the required size
	ImageSizes  map[string]quantity.Size
	VolumeOrder []string

	// names of images for each volume
	VolumeNames map[string]string

	// name of the "main volume"
	MainVolumeName string

	Packages []string
	Snaps    []string
	// contains filtered or unexported fields
}

StateMachine will hold the command line data, track the current state, and handle all function calls

func (*StateMachine) Run

func (stateMachine *StateMachine) Run() error

Run iterates through the state functions, stopping when appropriate based on --until and --thru

func (*StateMachine) SetCommonOpts

func (stateMachine *StateMachine) SetCommonOpts(commonOpts *commands.CommonOpts,
	stateMachineOpts *commands.StateMachineOpts)

SetCommonOpts stores the common options for all image types in the struct

func (*StateMachine) Teardown

func (stateMachine *StateMachine) Teardown() error

Teardown handles anything else that needs to happen after the states have finished running

Jump to

Keyboard shortcuts

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