statemachine

package
v0.0.0-...-4842e19 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: GPL-3.0 Imports: 47 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 (
	MKE2FS_CONFIG_ENV  = "MKE2FS_CONFIG"
	MKE2FS_CONFIG_FILE = "mke2fs.conf"
	MKE2FS_BASE_PATH   = "/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) 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 PackStateMachine

type PackStateMachine struct {
	StateMachine
	Opts commands.PackOpts
}

PackStateMachine embeds StateMachine and adds the command line flags specific to pack images

func (*PackStateMachine) SetSeries

func (packStateMachine *PackStateMachine) SetSeries() error

Placeholder method to satisfy the interface. This is not used when packing.

func (*PackStateMachine) Setup

func (packStateMachine *PackStateMachine) 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
}

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) 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
	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