seed

package
v2.42.5-go-mod+incompa... Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2020 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package seed implements loading and validating of seed data.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoAssertions = errors.New("no seed assertions")
	ErrNoMeta       = errors.New("no seed metadata")
)

Functions

func MockTrusted

func MockTrusted(mockTrusted []asserts.Assertion) (restore func())

func ValidateFromYaml

func ValidateFromYaml(seedYamlFile string) error

ValidateFromYaml validates the given seed.yaml file and surrounding seed.

Types

type Seed

type Seed interface {
	// LoadAssertions loads all assertions from the seed with
	// cross-checks.  A read-only view on an assertions database
	// can be passed in together with a commitTo function which
	// will be used to commit the assertions to the underlying
	// database. If db is nil an internal temporary database will
	// be setup instead. ErrNoAssertions will be returned if there
	// is no assertions directory in the seed, this is legitimate
	// only on classic.
	LoadAssertions(db asserts.RODatabase, commitTo func(*asserts.Batch) error) error

	// Model returns the seed provided model assertion. It is an
	// error to call Model before LoadAssertions.
	Model() (*asserts.Model, error)

	// LoadMeta loads the seed and seed's snaps metadata. It can
	// return ErrNoMeta if there is no metadata nor snaps in the
	// seed, this is legitimate only on classic. It is an error to
	// call LoadMeta before LoadAssertions.
	LoadMeta(tm timings.Measurer) error

	// UsesSnapdSnap returns whether the system as defined by the
	// seed will use the snapd snap, after LoadMeta.
	UsesSnapdSnap() bool

	// EssentialSnaps returns the essential snaps as defined by
	// the seed, after LoadMeta.
	EssentialSnaps() []*Snap

	// ModeSnaps returns the snaps that should be available
	// in the given mode as defined by the seed, after LoadMeta.
	ModeSnaps(mode string) ([]*Snap, error)
}

Seed supports loading assertions and seed snaps' metadata.

func Open

func Open(seedDir string) (Seed, error)

Open returns a Seed implementation for the seed at seedDir. TODO: more parameters for the Core20 case

type Seed16

type Seed16 struct {
	Snaps []*Snap16 `yaml:"snaps"`
}

func ReadYaml

func ReadYaml(fn string) (*Seed16, error)

func (*Seed16) Write

func (seed *Seed16) Write(seedFn string) error

type Snap

type Snap struct {
	Path string

	SideInfo *snap.SideInfo

	Essential bool
	Required  bool

	// options
	Channel string
	DevMode bool
	Classic bool
}

Snap holds the details of a snap in a seed.

func (*Snap) ID

func (s *Snap) ID() string

func (*Snap) SnapName

func (s *Snap) SnapName() string

type Snap16

type Snap16 struct {
	Name string `yaml:"name"`

	// cross-reference/audit
	SnapID string `yaml:"snap-id,omitempty"`

	// bits that are orthongonal/not in assertions
	Channel string `yaml:"channel,omitempty"`
	DevMode bool   `yaml:"devmode,omitempty"`
	Classic bool   `yaml:"classic,omitempty"`

	Private bool `yaml:"private,omitempty"`

	Contact string `yaml:"contact,omitempty"`

	// no assertions are available in the seed for this snap
	Unasserted bool `yaml:"unasserted,omitempty"`

	File string `yaml:"file"`
}

Snap points to a snap in the seed to install, together with assertions (or alone if unasserted is true) it will be used to drive the installation and ultimately set SideInfo/SnapState for it. TODO: make this internal

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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