service

package
v0.0.0-...-1f8c1e5 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2025 License: AGPL-3.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ControllerKeyProvider

type ControllerKeyProvider interface {
	// ControllerAuthorisedKeys returns controller wide authorised keys.
	ControllerAuthorisedKeys(context.Context) ([]string, error)
}

ControllerKeyProvider is responsible for providing controller wide authorised keys that should be included as part of every machine.

type ControllerKeyService

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

ControllerKeyService provides a service for interacting with the underlying ssh keys stored for a controller.

func NewControllerKeyService

func NewControllerKeyService(st ControllerKeyState) *ControllerKeyService

NewControllerKeyService constructs a new ControllerKeyService for retrieving the controller's ssh keys.

func (*ControllerKeyService) ControllerAuthorisedKeys

func (s *ControllerKeyService) ControllerAuthorisedKeys(
	ctx context.Context,
) ([]string, error)

ControllerAuthorisedKeys returns the juju controller's ssh public keys. If no keys are defined for the controller, a zero length slice is returned.

type ControllerKeyState

type ControllerKeyState interface {
	GetControllerConfigKeys(context.Context, []string) (map[string]string, error)
}

ControllerKeyState defines the state layer for interacting with a controller's config and ssh keys.

type ControllerState

type ControllerState interface {
	// GetUserAuthorizedKeysForModel is responsible for returning all of the
	// user authorized keys for a model.
	// The following errors can be expected:
	// - [modelerrors.NotFound] if the model does not exist.
	GetUserAuthorizedKeysForModel(context.Context, model.UUID) ([]string, error)
}

ControllerState provides the access layer the Service needs for retrieving user based authorized key information.

type Service

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

Service provides the means for interacting with the authorised keys in a model.

func NewService

func NewService(
	controllerKeyProvider ControllerKeyProvider,
	controllerState ControllerState,
	st State,
) *Service

NewService constructs a new Service for gathering up the authorised keys within a model.

func (*Service) GetAuthorisedKeysForMachine

func (s *Service) GetAuthorisedKeysForMachine(
	ctx context.Context,
	machineName coremachine.Name,
) ([]string, error)

GetAuthorisedKeysForMachine is responsible for fetching the authorised keys that should be available on a machine. The following errors can be expected: - github.com/juju/errors.NotValid if the machine id is not valid. - github.com/juju/juju/domain/machine/errors.NotFound if the machine does not exist.

func (*Service) GetInitialAuthorisedKeysForContainer

func (s *Service) GetInitialAuthorisedKeysForContainer(ctx context.Context) ([]string, error)

GetInitialAuthorisedKeysForContainer returns the authorised keys to be used when provisioning a new container for the model.

type State

type State interface {
	// GetModelUUID returns the unique uuid for the model represented by this state.
	GetModelUUID(context.Context) (model.UUID, error)

	// CheckMachineExists check to see if the given machine exists in the model. If
	// the machine does not exist an error satisfying
	// [github.com/juju/juju/domain/machine/errors.MachineNotFound] is returned.
	CheckMachineExists(context.Context, coremachine.Name) error
}

State provides the access layer the Service needs for persisting and retrieving a models authorised keys.

type WatchableService

type WatchableService struct {
	// Service is the inherited service to extend upon.
	Service
	// contains filtered or unexported fields
}

WatchableService is a normal Service that can also be watched for updates to authorised key values.

func NewWatchableService

func NewWatchableService(
	controllerKeyProvider ControllerKeyProvider,
	controllerState ControllerState,
	st State,
	watcherFactory WatcherFactory,
) *WatchableService

NewWatchableService creates a new WatchableService for consuming changes in authorised keys for a model.

func (*WatchableService) WatchAuthorisedKeysForMachine

func (s *WatchableService) WatchAuthorisedKeysForMachine(
	ctx context.Context,
	machineName coremachine.Name,
) (watcher.NotifyWatcher, error)

WatchAuthorisedKeysForMachine will watch for authorised key changes for a give machine name. The following errors can be expected: - github.com/juju/errors.NotValid if the machine id is not valid. - machineerrors.MachineNotFound if no machine exists for the provided name.

type WatcherFactory

type WatcherFactory interface {
	// NewNamespaceNotifyWatcher returns a new namespace notify watcher for
	// events based on the input change mask.
	NewNamespaceNotifyWatcher(string, changestream.ChangeType) (watcher.NotifyWatcher, error)

	// NewValueWatcher returns a watcher for a particular change value in a
	// namespace, based on the input change mask.
	NewValueWatcher(string, string, changestream.ChangeType) (watcher.NotifyWatcher, error)
}

WatcherFactory describes the methods required for creating new watchers for key updates.

Jump to

Keyboard shortcuts

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