state

package
v0.0.0-...-c3d9892 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2025 License: AGPL-3.0 Imports: 17 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllowCloudType

func AllowCloudType(ctx context.Context, db coredatabase.TxnRunner, version int, name string) error

AllowCloudType is responsible for applying the cloud type to the given database. If the unique constraint applies the error is masked and returned as NIL.

func CreateCloud

func CreateCloud(ctx context.Context, tx *sqlair.TX, ownerName user.Name, cloudUUID string, cloud cloud.Cloud) error

CreateCloud saves the specified cloud and creates Admin permission on the cloud for the provided user. Exported for use in the related cloud bootstrap package. Should never be directly called outside of the cloud bootstrap package.

func GetCloudForUUID

func GetCloudForUUID(
	ctx context.Context,
	st domain.Preparer,
	tx *sqlair.TX,
	uuid corecloud.UUID,
) (cloud.Cloud, error)

GetCloudForUUID returns the cloud associated with the provided uuid. If no cloud is found for the given id then a clouderrors.NotFound error is returned.

func LoadClouds

func LoadClouds(ctx context.Context, st domain.Preparer, tx *sqlair.TX, name string) ([]cloud.Cloud, error)

LoadClouds loads the cloud information from the database for the provided name.

Types

type State

type State struct {
	*domain.StateBase
}

State is used to access the database.

func NewState

func NewState(factory coredatabase.TxnRunnerFactory) *State

NewState creates a state to access the database.

func (*State) Cloud

func (st *State) Cloud(ctx context.Context, name string) (*cloud.Cloud, error)

Cloud returns the cloud with the specified name.

func (*State) CreateCloud

func (st *State) CreateCloud(ctx context.Context, ownerName user.Name, cloudUUID string, cloud cloud.Cloud) error

CreateCloud creates a cloud and provides admin permissions to the provided ownerName. This is the exported method for use with the cloud state.

func (*State) DeleteCloud

func (st *State) DeleteCloud(ctx context.Context, name string) error

DeleteCloud removes a cloud credential with the given name.

func (*State) GetCloudForUUID

func (st *State) GetCloudForUUID(ctx context.Context, id corecloud.UUID) (cloud.Cloud, error)

GetCloudForUUID returns the cloud associated with the provided uuid. If no cloud is found for the given uuid then a clouderrors.NotFound error is returned.

func (*State) ListClouds

func (st *State) ListClouds(ctx context.Context) ([]cloud.Cloud, error)

ListClouds lists the clouds with the specified filter, if any.

func (*State) UpdateCloud

func (st *State) UpdateCloud(ctx context.Context, cloud cloud.Cloud) error

UpdateCloud updates the specified cloud.

func (*State) WatchCloud

func (st *State) WatchCloud(
	ctx context.Context,
	getWatcher func(string, string, changestream.ChangeType) (watcher.NotifyWatcher, error),
	cloudName string,
) (watcher.NotifyWatcher, error)

WatchCloud returns a new NotifyWatcher watching for changes to the specified cloud.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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