crew

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2019 License: Apache-2.0 Imports: 3 Imported by: 3

Documentation

Overview

Package crew is a simple, example foundation for gathering a set of machines.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Crew

type Crew struct {
	sync.RWMutex

	// Id is an optional name for this crew.
	Id string `json:"id"`

	// Machines is the collection of Machines indexed by id.
	Machines map[string]*Machine `json:"machines"`
}

Crew is a simple collection of Machines.

func (*Crew) Copy

func (c *Crew) Copy() *Crew

Copy gets (and later releases) a read lock and returns a deep copy of the crew.

Each Machine is itself Copy()ed, too.

type Machine

type Machine struct {
	Id      string       `json:"id,omitempty"`
	Specter core.Specter `json:"-" yaml:"-"`
	State   *core.State  `json:"state"`

	// SpecSource_ is here only to facilitate serialization and
	// deserialization.  This field is not used anywhere in this
	// package.
	SpecSource *SpecSource `json:"spec,omitempty"`
}

Machine is a triple: id, core.Spec, and core.State.

func (*Machine) Copy

func (m *Machine) Copy() *Machine

Copy returns a new Machine with the same id, same spec, and a copy of the machine's state.

func (*Machine) Update

func (m *Machine) Update(overlay *Machine)

Update overlays the given machine data on the target machine.

State and SpecSource (if any) are copied.

Not thread-safe.

type SpecProvider

type SpecProvider interface {
	FindSpec(ctx context.Context, s *SpecSource) (*core.Spec, error)
}

SpecProvider can FindSpec given a SpecSource.

type SpecSource

type SpecSource struct {
	Name   string     `json:"name,omitempty" yaml:"name,omitempty"`
	URL    string     `json:"url,omitempty" yaml:"url,omitempty"`
	Source string     `json:"source,omitempty" yaml:"source,omitempty"`
	Inline *core.Spec `json:"inline,omitempty" yaml:",omitempty"`
}

SpecSource aspires to hold the origin of a specification.

Currently a source for a Spec can either be a name, a URL, or maybe given explicitly as a string in an unspecified syntax.

func NewSpecSource

func NewSpecSource(name string) *SpecSource

NewSpecSource creates a SpecSource with the given name.

func (*SpecSource) Copy

func (s *SpecSource) Copy() *SpecSource

Copy makes a (deep?) copy of the given SpecSource.

Jump to

Keyboard shortcuts

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