state

package
v0.0.0-...-baedfb2 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2025 License: AGPL-3.0 Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigDefaults

func ConfigDefaults(_ context.Context) map[string]any

ConfigDefaults returns the default configuration values set in Juju.

func SetCloudDefaults

func SetCloudDefaults(
	ctx context.Context,
	tx *sqlair.TX,
	cloudName string,
	defaults map[string]string,
) error

SetCloudDefaults is responsible for removing any previously set cloud default values and setting the new cloud defaults to use. If no defaults are supplied to this function then the currently set cloud default values will be removed and no further operations will be performed. If no cloud exists for the cloud name then an error satisfying clouderrors.NotFound is returned.

Types

type State

type State struct {
	*domain.StateBase
}

State represents a type for interacting with the underlying model defaults state.

func NewState

func NewState(factory coredatabase.TxnRunnerFactory) *State

NewState returns a new State for interacting with the underlying model defaults.

func (*State) CloudAllRegionDefaults

func (s *State) CloudAllRegionDefaults(
	ctx context.Context,
	cloudUUID cloud.UUID,
) (map[string]map[string]string, error)

CloudAllRegionDefaults returns the defaults associated with all of the regions for the specified cloud. The result is a map of region name key values, keyed on the name of the region. If no defaults are found then an empty map will be returned with nil error. Note this will not include the defaults set on the cloud itself but just that of its regions.

If no cloud exists for the given uuid an error satisfying clouderrors.NotFound

func (*State) CloudDefaults

func (s *State) CloudDefaults(
	ctx context.Context,
	uuid cloud.UUID,
) (map[string]string, error)

CloudDefaults returns the defaults associated with the given cloud. If no defaults are found then an empty map will be returned with a nil error. If no cloud exists for the given id an error satisfying clouderrors.NotFound will be returned.

func (*State) CloudType

func (s *State) CloudType(
	ctx context.Context,
	uuid cloud.UUID,
) (string, error)

CloudType returns the cloud type of the cloud. If no cloud exists for the given uuid then an error satisfying clouderrors.NotFound is returned.

func (*State) ConfigDefaults

func (s *State) ConfigDefaults(ctx context.Context) map[string]any

ConfigDefaults returns the default configuration values set in Juju.

func (*State) DeleteCloudDefaults

func (s *State) DeleteCloudDefaults(
	ctx context.Context,
	cloudUUID cloud.UUID,
	removeAttrs []string,
) error

DeleteCloudDefaults will delete the specified default keys from the cloud if they exist. If the cloud does not exist an error satisfying clouderrors.NotFound will be returned.

func (*State) DeleteCloudRegionDefaults

func (s *State) DeleteCloudRegionDefaults(
	ctx context.Context,
	cloudUUID cloud.UUID,
	regionName string,
	removeAttrs []string,
) error

DeleteCloudRegionDefaults deletes the specified default config keys for the given cloud region. It returns an error satisfying clouderrors.NotFound if the region doesn't exist.

func (*State) GetCloudUUID

func (s *State) GetCloudUUID(ctx context.Context, cloudName string) (cloud.UUID, error)

GetCloudUUID returns the cloud UUID and region for the given cloud name. If the cloud is not found, an error specifying clouderrors.NotFound is returned.

func (*State) GetModelCloudUUID

func (s *State) GetModelCloudUUID(ctx context.Context, uuid coremodel.UUID) (cloud.UUID, error)

GetModelCloudUUID returns the cloud UUID for the given model. If the model is not found, an error specifying modelerrors.NotFound is returned.

func (*State) ModelCloudRegionDefaults

func (s *State) ModelCloudRegionDefaults(
	ctx context.Context,
	uuid coremodel.UUID,
) (map[string]string, error)

ModelCloudRegionDefaults returns the defaults associated with the model's cloud region. It returns an error satisfying modelerrors.NotFound if the model doesn't exist.

func (*State) ModelMetadataDefaults

func (s *State) ModelMetadataDefaults(
	ctx context.Context,
	uuid coremodel.UUID,
) (map[string]string, error)

ModelMetadataDefaults is responsible for providing metadata defaults for a model's config. These include things like the model's name and uuid. If no model exists for the provided uuid then a modelerrors.NotFound error is returned.

func (*State) UpdateCloudDefaults

func (s *State) UpdateCloudDefaults(
	ctx context.Context,
	cloudUUID cloud.UUID,
	updateAttrs map[string]string,
) error

UpdateCloudDefaults is responsible for updating default config values for a cloud. This function will allow the addition and updating of attributes. If the cloud doesn't exist, an error satisfying clouderrors.NotFound is returned.

func (*State) UpdateCloudRegionDefaults

func (s *State) UpdateCloudRegionDefaults(
	ctx context.Context,
	cloudUUID cloud.UUID,
	regionName string,
	updateAttrs map[string]string,
) error

UpdateCloudRegionDefaults is responsible for updating default config values for a cloud region. This function will allow the addition and updating of attributes. If the cloud region is not found an error satisfying clouderrors.NotFound is returned.

Jump to

Keyboard shortcuts

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