state

package
v0.0.0-...-f88c608 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 License: AGPL-3.0 Imports: 10 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	// ID is the address UUID.
	ID string `db:"uuid"`

	// Addr holds a single host:port value for
	// the external controller's API server.
	Addr string `db:"address"`

	// ControllerUUID holds the controller uuid.
	ControllerUUID string `db:"controller_uuid"`
}

Address represents a single row from external_controller_address.

type Controller

type Controller struct {
	// ID is the controller UUID.
	ID string `db:"uuid"`

	// Alias holds is a human-friendly name for the controller.
	Alias sql.NullString `db:"alias"`

	// CACert holds the certificate to validate the external
	// controller's API server TLS certificate.
	CACert string `db:"ca_cert"`

	// Addr holds a single host:port value for
	// the external controller's API server.
	Addr sql.NullString `db:"address"`

	// ModelUUID holds a modelUUID value.
	ModelUUID sql.NullString `db:"model"`
}

Controller represents a single row from the database when external_controller is joined with external_controller_address and external_model.

type ControllerUUIDs

type ControllerUUIDs []string

ControllerUUIDs is a slice of controller uuids from the database.

type Controllers

type Controllers []Controller

func (Controllers) ToControllerInfo

func (e Controllers) ToControllerInfo() []crossmodel.ControllerInfo

ToControllerInfo Controllers to a slice of crossmodel.ControllerInfo structs. This method makes sure only unique models and addresses are mapped and flattens them into each controller. Order of addresses, models and the resulting crossmodel.ControllerInfo elements are not guaranteed, no sorting is applied.

type Model

type Model struct {
	// ID is the model UUID.
	ID string `db:"uuid"`

	// ControllerUUID holds the controller uuid.
	ControllerUUID string `db:"controller_uuid"`
}

Model represents a single row from external_model.

type ModelUUIDs

type ModelUUIDs []string

type State

type State struct {
	*domain.StateBase
}

State implements the domain external controller state.

func NewState

func NewState(factory coredatabase.TxnRunnerFactory) *State

NewState returns a new State instance.

func (*State) Controller

func (st *State) Controller(
	ctx context.Context,
	controllerUUID string,
) (*crossmodel.ControllerInfo, error)

Controller returns the external controller with the given UUID.

func (*State) ControllersForModels

func (st *State) ControllersForModels(ctx context.Context, modelUUIDs ...string) ([]crossmodel.ControllerInfo, error)

ControllersForModels returns the external controllers for the given model UUIDs. If no model UUIDs are provided, then no controllers are returned.

func (*State) ImportExternalControllers

func (st *State) ImportExternalControllers(ctx context.Context, infos []crossmodel.ControllerInfo) error

ImportExternalControllers imports the list of ControllerInfo external controllers on one single transaction.

func (*State) ModelsForController

func (st *State) ModelsForController(
	ctx context.Context,
	controllerUUID string,
) ([]string, error)

ModelsForController returns the model UUIDs associated with the given controller UUID.

func (*State) UpdateExternalController

func (st *State) UpdateExternalController(
	ctx context.Context,
	ci crossmodel.ControllerInfo,
) error

UpdateExternalController updates the external controller information.

Jump to

Keyboard shortcuts

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