model

package
v0.0.0-...-2ee77c6 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: AGPL-3.0 Imports: 8 Imported by: 37

Documentation

Index

Constants

View Source
const (
	// ControllerModelName is the name given to the model that hosts the Juju
	// controller. This is a static value that we use for every Juju deployment.
	// It provides a common reference point that we can leverage in business
	// logic to ask questions and calculate defaults in Juju.
	ControllerModelName = "controller"

	// ControllerModelOwnerUsername is the user name of the owner that is
	// assigned to the controller model. This is a static value that we use for
	// every Juju deployment.
	ControllerModelOwnerUsername = user.AdminUserName
)
View Source
const GenerationMaster = "master"

GenerationMaster is used to indicate the main model configuration, i.e. that not dealing with in-flight branches.

Variables

This section is empty.

Functions

func AnyJobNeedsState

func AnyJobNeedsState(jobs ...MachineJob) bool

AnyJobNeedsState returns true if any of the provided jobs require a state connection.

func ValidateBranchName

func ValidateBranchName(name string) error

ValidateBranchName returns an error if the input name is not suitable for identifying a new in-flight branch.

Types

type BlockType

type BlockType string

BlockType values define model block type.

const (
	// BlockDestroy type identifies destroy blocks.
	BlockDestroy BlockType = "BlockDestroy"

	// BlockRemove type identifies remove blocks.
	BlockRemove BlockType = "BlockRemove"

	// BlockChange type identifies change blocks.
	BlockChange BlockType = "BlockChange"
)

type Generation

type Generation struct {
	// Created is the formatted time at generation creation.
	Created string `yaml:"created"`

	// Created is the user who created the generation.
	CreatedBy string `yaml:"created-by"`

	// Applications is a collection of applications with changes in this
	// generation including advanced units and modified configuration.
	Applications []GenerationApplication `yaml:"applications"`
}

Generation represents detail of a model generation including config changes.

type GenerationApplication

type GenerationApplication struct {
	// ApplicationsName is the name of the application.
	ApplicationName string `yaml:"application"`

	// UnitProgress is summary information about units tracking the branch.
	UnitProgress string `yaml:"progress,omitempty"`

	// UnitDetail specifies which units are and are not tracking the branch.
	UnitDetail *GenerationUnits `yaml:"units,omitempty"`

	// Config changes are the differing configuration values between this
	// generation and the current.
	// TODO (manadart 2018-02-22) This data-type will evolve as more aspects
	// of the application are made generational.
	ConfigChanges map[string]interface{} `yaml:"config"`
}

GenerationApplication represents changes to an application made under a generation.

type GenerationCommit

type GenerationCommit struct {
	// BranchName uniquely identifies a branch *amongst in-flight branches*.
	BranchName string `yaml:"branch"`

	// Created is the Unix timestamp at generation creation.
	Completed time.Time `yaml:"completed"`

	// Created is the user who created the generation.
	CompletedBy string `yaml:"completed-by"`

	// Created is the Unix timestamp at generation creation.
	Created time.Time `yaml:"created,omitempty"`

	// Created is the user who created the generation.
	CreatedBy string `yaml:"created-by,omitempty"`

	// GenerationId is the id .
	GenerationId int `yaml:"generation-id,omitempty"`

	// Applications holds the collection of application changes
	// made under this generation.
	Applications []GenerationApplication `yaml:"applications,omitempty"`
}

GenerationCommit represents a model generation's commit details.

type GenerationCommits

type GenerationCommits = []GenerationCommit

GenerationCommits is a type alias for a representation of each commit. Keyed by the generation id

type GenerationSummaries

type GenerationSummaries = map[string]Generation

GenerationSummaries is a type alias for a representation of changes-by-generation.

type GenerationUnits

type GenerationUnits struct {
	// UnitsTracking is the names of application units that have been set to
	// track the branch.
	UnitsTracking []string `yaml:"tracking,omitempty"`

	// UnitsPending is the names of application units that are still tracking
	// the master generation.
	UnitsPending []string `yaml:"incomplete,omitempty"`
}

GenerationUnits indicates which units from an application are and are not tracking a model branch.

type Graph

Graph is a type for representing a Directed acyclic graph (DAG).

func UpgradeSeriesGraph

func UpgradeSeriesGraph() Graph

UpgradeSeriesGraph defines a graph for moving between vertices of an upgrade series.

func (Graph) ValidState

func (g Graph) ValidState(state UpgradeSeriesStatus) bool

ValidState checks that a state is a valid vertex, as graphs have to ensure that all edges to other vertices are also valid then this should be fine to do.

func (Graph) Validate

func (g Graph) Validate() error

Validate attempts to ensure that all edges from a vertex have a vertex to the root graph.

type MachineJob

type MachineJob string

MachineJob values define responsibilities that machines may be expected to fulfil.

const (
	JobHostUnits   MachineJob = "JobHostUnits"
	JobManageModel MachineJob = "JobManageModel"
)

func (MachineJob) NeedsState

func (job MachineJob) NeedsState() bool

NeedsState returns true if the job requires a state connection.

type Model

type Model struct {
	// Name returns the human friendly name of the model.
	Name string

	// Life is the current state of the model.
	// Options are alive, dying, dead. Every model starts as alive, only
	// during the destruction of the model it transitions to dying and then
	// dead.
	Life life.Value

	// UUID is the universally unique identifier of the model.
	UUID UUID

	// ModelType is the type of model.
	ModelType ModelType

	// AgentVersion is the target version for agents running under this model.
	AgentVersion version.Number

	// Cloud is the name of the cloud to associate with the model.
	// Must not be empty for a valid struct.
	Cloud string

	// CloudRegion is the region that the model will use in the cloud.
	CloudRegion string

	// Credential is the id attributes for the credential to be associated with
	// model. Credential must be for the same cloud as that of the model.
	// Credential can be the zero value of the struct to not have a credential
	// associated with the model.
	Credential credential.Key

	// Owner is the uuid of the user that owns this model in the Juju controller.
	Owner user.UUID

	// OwnerName is the name of the owner in the Juju controller.
	OwnerName string
}

Model represents the state of a model.

type ModelType

type ModelType string

ModelType indicates a model type.

const (
	// IAAS is the type for IAAS models.
	IAAS ModelType = "iaas"

	// CAAS is the type for CAAS models.
	CAAS ModelType = "caas"
)

func (ModelType) IsValid

func (m ModelType) IsValid() bool

IsValid returns true if the value of Type is a known valid type. Currently supported values are: - CAAS - IAAS

func (ModelType) String

func (m ModelType) String() string

String returns m as a string.

type ReadOnlyModel

type ReadOnlyModel struct {
	// UUID represents the model UUID.
	UUID UUID

	// AgentVersion reports the current target agent version for the model.
	AgentVersion version.Number

	// ControllerUUID represents the controller UUID.
	ControllerUUID uuid.UUID

	// Name is the name of the model.
	Name string

	// Type is the type of the model.
	Type ModelType

	// Cloud is the name of the cloud to associate with the model.
	Cloud string

	// CloudRegion is the region that the model will use in the cloud.
	CloudRegion string

	// CredentialOwner is the owner of the model.
	CredentialOwner string

	// Credential name is the name of the credential to use for the model.
	CredentialName string
}

ReadOnlyModel represents the state of a read-only model found in the model database, not the controller database. All the fields are are denormalized from the model database.

type UUID

type UUID string

UUID represents a model unique identifier.

func NewUUID

func NewUUID() (UUID, error)

NewUUID is a convince function for generating a new model uuid.

func (UUID) String

func (u UUID) String() string

String implements the stringer interface for UUID.

func (UUID) Validate

func (u UUID) Validate() error

Validate ensures the consistency of the UUID. If the uuid is invalid an error satisfying errors.NotValid will be returned.

type UpgradeSeriesFSM

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

UpgradeSeriesFSM defines a finite state machine from a given graph of possible vertices to transition. The FSM can start in any position using the initial state and can move along the edges to the correct vertex.

func NewUpgradeSeriesFSM

func NewUpgradeSeriesFSM(graph Graph, initial UpgradeSeriesStatus) (*UpgradeSeriesFSM, error)

NewUpgradeSeriesFSM creates a UpgradeSeriesFSM from a graph and an initial state.

func (*UpgradeSeriesFSM) State

State returns the current state of the fsm.

func (*UpgradeSeriesFSM) TransitionTo

func (u *UpgradeSeriesFSM) TransitionTo(state UpgradeSeriesStatus) bool

TransitionTo attempts to transition from the current state to the new given state. If the state is currently at the requested state, then that's classified as a no-op and no transition is required.

type UpgradeSeriesStatus

type UpgradeSeriesStatus string

UpgradeSeriesStatus is the current status of a series upgrade for units

const (
	UpgradeSeriesNotStarted       UpgradeSeriesStatus = "not started"
	UpgradeSeriesValidate         UpgradeSeriesStatus = "validate"
	UpgradeSeriesPrepareStarted   UpgradeSeriesStatus = "prepare started"
	UpgradeSeriesPrepareRunning   UpgradeSeriesStatus = "prepare running"
	UpgradeSeriesPrepareCompleted UpgradeSeriesStatus = "prepare completed"
	UpgradeSeriesCompleteStarted  UpgradeSeriesStatus = "complete started"
	UpgradeSeriesCompleteRunning  UpgradeSeriesStatus = "complete running"
	UpgradeSeriesCompleted        UpgradeSeriesStatus = "completed"
	UpgradeSeriesError            UpgradeSeriesStatus = "error"
)

func (UpgradeSeriesStatus) String

func (s UpgradeSeriesStatus) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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