bootstrap

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2025 License: Apache-2.0 Imports: 11 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clear added in v0.5.0

func Clear[T any](ctx *Context, k InfoKey[T])

func Configure

func Configure(opts ...Option)

func Get

func Get[T any](ctx *Context, k InfoKey[T]) (T, bool)

func HasGUI added in v0.7.0

func HasGUI(ctx *Context) bool

func IsInContainer added in v0.7.0

func IsInContainer(ctx *Context) bool

func RunPlan added in v0.5.0

func RunPlan(ctx context.Context, plan *Plan) error

func Save

func Save[T any](ctx *Context, k InfoKey[T], v T)

func Set added in v0.3.0

func Set[T any](ctx *Context, k InfoKey[T], v T)

func SetNeedsReboot added in v0.5.0

func SetNeedsReboot(ctx *Context)

func SimPlan added in v0.5.0

func SimPlan(ctx context.Context, plan *Plan) error

func WithDefaultStepFactory added in v0.5.0

func WithDefaultStepFactory(name string, f func() *Step)

WithDefaultStepFactory registers a function that will be called to create a default step with the given name. This is used to register steps that are referenced in existing step dependencies but not already added to the plan.

These steps essentially will be run if and only if some other step depends on them.

Normally this should only be used by bootstrap internals.

Types

type Context

type Context = internal.Context

func NewContext

func NewContext(ctx context.Context) *Context

type InfoKey

type InfoKey[T any] = internal.InfoKey[T]

func NewKey

func NewKey[T any](name string) InfoKey[T]

type Option added in v0.5.0

type Option func(*config)

func WithAlternatePlanCmd added in v0.5.0

func WithAlternatePlanCmd(
	name string,
	pf func() *Plan,
	customize func(*cobra.Command),
) Option

WithAlternatePlanCmd registers a command that will run an alternate bootstrap plan from the given factory function.

The customize parameter is optional, if given it will be called and can customize the command to e.g. override the short help or add long help or other settings.

func WithChildCmdBuilders

func WithChildCmdBuilders(fns ...func() *cobra.Command) Option

func WithChildCmds

func WithChildCmds(cmds ...*cobra.Command) Option

func WithSteps

func WithSteps(steps ...*Step) Option

type Plan added in v0.5.0

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

func NewDerivedPlan added in v0.5.0

func NewDerivedPlan(exceptions ...string) *Plan

NewDerivedPlan creates a new plan that is derived from the main plan, i.e. it has all of the steps copied to it, and you can then add more custom steps to it.

You can pass exceptions, steps you want to exclude from the copy, if you want to create a plan that has most but not all of the normal steps. It is up to you to ensure this doesn't create a plan with missing dependencies that can't be run.

Excluding a step that has a default factory may simply cause it to be re-added if other steps depend on it.

func NewPlan

func NewPlan() *Plan

func (*Plan) AddDefaultSteps added in v0.5.0

func (p *Plan) AddDefaultSteps()

Add any of the known "Default" steps that are referenced in existing step dependencies but not already added to the plan.

func (*Plan) AddSteps added in v0.5.0

func (p *Plan) AddSteps(steps ...*Step)

func (*Plan) Ready added in v0.5.0

func (p *Plan) Ready() bool

Ready tries to resolve all dependencies between plan steps to form a well-ordered plan. It returns whether this was successful.

You will usually want to call *Plan.AddDefaultSteps before this, or alternately do so if this fails before trying again.

func (*Plan) Run added in v0.5.0

func (p *Plan) Run(ctx context.Context) error

func (*Plan) Sim added in v0.5.0

func (p *Plan) Sim(ctx context.Context) error

type Step

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

func NewStep added in v0.2.0

func NewStep(
	name string,
	run func(*Context) error,
	opts ...StepOpt,
) *Step

NewStep creates a new bootstrap step with the given name and run function.

Dependencies, simulation (dry-run) mode special case, and other options can be set via the additional option arguments.

func (*Step) With added in v0.3.0

func (s *Step) With(opts ...StepOpt) *Step

type StepOpt added in v0.3.0

type StepOpt func(*Step)

func AfterSteps added in v0.3.0

func AfterSteps(names ...string) StepOpt

AfterSteps adds normal dependencies to the step

func BeforeSteps added in v0.3.0

func BeforeSteps(names ...string) StepOpt

BeforeSteps adds reverse dependencies to the step

func SimFunc added in v0.3.0

func SimFunc(f func(*Context) error) StepOpt

SimFunc sets the simulation function that will be run instead of just printing the step name in [Sim] (dry run) invocations.

func SkipFunc added in v0.7.0

func SkipFunc(f func(*Context) (bool, error)) StepOpt

func SkipIfNoGUI added in v0.7.0

func SkipIfNoGUI() StepOpt

func SkipInContainer added in v0.7.0

func SkipInContainer() StepOpt

Directories

Path Synopsis
apt
getkey command
input module
Package internal provides internal types and functions for the bootstrap addon.
Package internal provides internal types and functions for the bootstrap addon.
Package textedit provides helpers for making changes to line-oriented text files.
Package textedit provides helpers for making changes to line-oriented text files.

Jump to

Keyboard shortcuts

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