providertracker

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: 7 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EphemeralProviderRunnerFromConfig

func EphemeralProviderRunnerFromConfig[T any](providerFactory ProviderFactory, config EphemeralProviderConfig) func(context.Context, func(context.Context, T) error) error

EphemeralProviderRunnerFromConfig returns the ProviderGetter function for a given generic type. This is useful for ad-hoc providers that are not tracked, but instead created and discarded. Credential invalidation is not enforced during the call to the provider. For that reason alone, a closure is returned and the provider is created and discarded on each call.

func ProviderRunner

func ProviderRunner[T any](providerFactory ProviderFactory, namespace string) func(context.Context) (T, error)

ProviderRunner returns the ProviderGetter function for a given generic type. If the returned provider is not of the expected type, a not supported error will be returned.

Types

type EphemeralProvider

type EphemeralProvider interface {
	// Provider returns the provider.
	Provider() (Provider, error)
}

EphemeralProvider returns a provider that is not tracked by the worker. It is created and then discarded. No credential invalidation is enforced during the call to the provider.

type EphemeralProviderConfig

type EphemeralProviderConfig struct {
	// ModelType is the type of the model.
	ModelType model.ModelType

	// ModelConfig is the model configuration for the provider.
	ModelConfig *config.Config

	// CloudSpec is the cloud spec for the provider.
	CloudSpec cloudspec.CloudSpec

	// ControllerUUID is the UUID of the controller that the provider is
	// associated with. This is currently only used for k8s providers.
	ControllerUUID uuid.UUID
}

EphemeralProviderConfig is a struct that contains the necessary information to create a provider.

type Provider

type Provider interface {
	// InstancePrechecker provides a means of "prechecking" placement
	// arguments before recording them in state.
	environs.InstancePrechecker

	// BootstrapEnviron defines methods for bootstrapping a controller.
	environs.BootstrapEnviron

	// ResourceAdopter defines methods for adopting resources.
	environs.ResourceAdopter
}

Provider in the intersection of a environs.Environ and a caas.Broker.

We ideally don't want to import the environs package here, but I've not sure how to avoid it.

type ProviderFactory

type ProviderFactory interface {
	// ProviderForModel returns the encapsulated provider for a given model
	// namespace. It will continue to be updated in the background for as long
	// as the Worker continues to run. If the worker is not a singular worker,
	// then an error will be returned.
	ProviderForModel(ctx context.Context, namespace string) (Provider, error)

	// EphemeralProviderFromConfig returns an ephemeral provider for a given
	// configuration. The provider is not tracked, instead is created and then
	// discarded.
	EphemeralProviderFromConfig(ctx context.Context, config EphemeralProviderConfig) (Provider, error)
}

ProviderFactory is an interface that provides a way to get a provider for a given model namespace. It will continue to be updated in the background for as long as the Worker continues to run.

type ProviderGetter

type ProviderGetter[T any] func(ctx context.Context) (T, error)

ProviderGetter is a function that returns a provider for a given type. It's generic type any because it can return any type of provider, this should be used in conjunction with the ProviderRunner function.

Jump to

Keyboard shortcuts

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