Documentation
¶
Index ¶
- Constants
- func CAASGetProvider(newProvider CAASProviderFunc) ...
- func IAASGetProvider(newProvider IAASProviderFunc) ...
- func MultiTrackerManifold(config ManifoldConfig) dependency.Manifold
- func NewTrackerWorker(ctx context.Context, config TrackerConfig) (worker.Worker, error)
- func NewWorker(cfg Config) (worker.Worker, error)
- func SingularTrackerManifold(modelTag names.ModelTag, config ManifoldConfig) dependency.Manifold
- type CAASProviderFunc
- type CloudService
- type Config
- type ConfigService
- type CredentialService
- type DomainServices
- type DomainServicesGetter
- type EphemeralConfig
- type GetProviderFunc
- type GetProviderServicesGetterFunc
- type IAASProviderFunc
- type ManifoldConfig
- type ModelService
- type NewEphemeralProviderFunc
- type NewTrackerWorkerFunc
- type NewWorkerFunc
- type Provider
- type ProviderConfigGetter
- type TrackerConfig
- type TrackerType
Constants ¶
const ( // ErrProviderWorkerDying is returned when the provider worker is dying. ErrProviderWorkerDying = errors.ConstError("provider worker is dying") )
Variables ¶
This section is empty.
Functions ¶
func CAASGetProvider ¶
func CAASGetProvider(newProvider CAASProviderFunc) func(ctx context.Context, getter ProviderConfigGetter) (Provider, cloudspec.CloudSpec, error)
CAASGetProvider creates a new provider from the given args.
func IAASGetProvider ¶
func IAASGetProvider(newProvider IAASProviderFunc) func(ctx context.Context, getter ProviderConfigGetter) (Provider, cloudspec.CloudSpec, error)
IAASGetProvider creates a new provider from the given args.
func MultiTrackerManifold ¶
func MultiTrackerManifold(config ManifoldConfig) dependency.Manifold
MultiTrackerManifold creates a new manifold that encapsulates a singular provider tracker. Only one tracker is allowed to exist at a time.
func NewTrackerWorker ¶
func NewTrackerWorker(ctx context.Context, config TrackerConfig) (worker.Worker, error)
NewTrackerWorker loads a provider from the observer and returns a new Worker, or an error if anything goes wrong. If a tracker is returned, its Environ() method is immediately usable.
func SingularTrackerManifold ¶
func SingularTrackerManifold(modelTag names.ModelTag, config ManifoldConfig) dependency.Manifold
SingularTrackerManifold creates a new manifold that encapsulates a singular provider tracker. Only one tracker is allowed to exist at a time.
Types ¶
type CAASProviderFunc ¶
type CAASProviderFunc func(ctx context.Context, args environs.OpenParams, invalidator environs.CredentialInvalidator) (caas.Broker, error)
CAASProviderFunc is a function that returns a IAAS provider.
type CloudService ¶
type CloudService interface { // Cloud returns the named cloud. Cloud(ctx context.Context, name string) (*cloud.Cloud, error) // WatchCloud returns a watcher that observes changes to the specified cloud. WatchCloud(ctx context.Context, name string) (watcher.NotifyWatcher, error) }
CloudService represents the cloud service provided by the provider.
type Config ¶
type Config struct { TrackerType TrackerType DomainServicesGetter DomainServicesGetter GetIAASProvider GetProviderFunc GetCAASProvider GetProviderFunc NewTrackerWorker NewTrackerWorkerFunc NewEphemeralProvider NewEphemeralProviderFunc Logger logger.Logger Clock clock.Clock }
Config describes the dependencies of a Worker.
It's arguable that it should be called WorkerConfig, because of the heavy use of model config in this package.
type ConfigService ¶
type ConfigService interface { // ModelConfig returns the model configuration for the given tag. ModelConfig(ctx context.Context) (*config.Config, error) // WatchModelConfig returns a watcher that observes changes to the specified // model configuration. Watch() (watcher.StringsWatcher, error) }
ConfigService represents the config service provided by the provider.
type CredentialService ¶
type CredentialService interface { // CloudCredential returns the cloud credential for the given tag. CloudCredential(ctx context.Context, key credential.Key) (cloud.Credential, error) // WatchCredential returns a watcher that observes changes to the specified // credential. WatchCredential(ctx context.Context, key credential.Key) (watcher.NotifyWatcher, error) }
CredentialService represents the credential service provided by the provider.
type DomainServices ¶
type DomainServices interface { // Model returns the model service. Model() ModelService // Cloud returns the cloud service. Cloud() CloudService // Config returns the config service. Config() ConfigService // Credential returns the credential service. Credential() CredentialService }
DomainServices provides access to the services required by the provider.
type DomainServicesGetter ¶
type DomainServicesGetter interface { // ServicesForModel returns a ProviderServices for the given model. ServicesForModel(modelUUID string) DomainServices }
DomainServicesGetter defines an interface that returns a DomainServices for a given model UUID.
func GetModelProviderServicesGetter ¶
func GetModelProviderServicesGetter(getter dependency.Getter, name string) (DomainServicesGetter, error)
GetModelProviderServicesGetter is a helper function that gets a service from the manifold. This is a model specific version of GetProviderServicesGetter. As the domain services is plucked out of the provider domain services already, we have to use a different getter. Ideally we would use the services directly, but that's plumbed through the model worker manager config. We can't use generics here, as although the types are the same, the nested interfaces are not (invariance). If the provider domain services returned interfaces, we could just point the getter at the domain services directly.
func GetProviderServicesGetter ¶
func GetProviderServicesGetter(getter dependency.Getter, name string) (DomainServicesGetter, error)
GetProviderServicesGetter is a helper function that gets a service from the manifold. This returns a DomainServicesGetter that is constructed directly from the domain services.
type EphemeralConfig ¶
type EphemeralConfig struct { // ModelType is the type of the model. ModelType coremodel.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 // GetProviderForType returns a provider for the given model type. GetProviderForType func(coremodel.ModelType) (GetProviderFunc, error) }
EphemeralConfig is a struct that contains the necessary information to create a ephemeral worker.
func (EphemeralConfig) Validate ¶
func (config EphemeralConfig) Validate() error
Validate returns an error if the config cannot be used to start a Worker.
type GetProviderFunc ¶
type GetProviderFunc func(context.Context, ProviderConfigGetter) (Provider, cloudspec.CloudSpec, error)
GetProviderFunc is a helper function that gets a provider from the manifold.
type GetProviderServicesGetterFunc ¶
type GetProviderServicesGetterFunc func(dependency.Getter, string) (DomainServicesGetter, error)
GetProviderServicesGetterFunc is a helper function that gets a service factory getter from the manifold.
type IAASProviderFunc ¶
type IAASProviderFunc func(ctx context.Context, args environs.OpenParams, invalidator environs.CredentialInvalidator) (environs.Environ, error)
IAASProviderFunc is a function that returns a IAAS provider.
type ManifoldConfig ¶
type ManifoldConfig struct { // ProviderServiceFactoriesName is the name of the domain services getter // that provides the services required by the provider. ProviderServiceFactoriesName string // NewWorker is a function that creates a new Worker. NewWorker NewWorkerFunc // NewTrackerWorker is a function that creates a new TrackerWorker. NewTrackerWorker NewTrackerWorkerFunc // NewEphemeralProvider is a function that creates a new ephemeral Provider. NewEphemeralProvider NewEphemeralProviderFunc // GetIAASProvider is a helper function that gets a IAAS provider from the // manifold. GetIAASProvider GetProviderFunc // GetCAASProvider is a helper function that gets a CAAS provider from the // manifold. GetCAASProvider GetProviderFunc // GetProviderServicesGetter is a helper function that gets a service // factory getter from the dependency engine. GetProviderServicesGetter GetProviderServicesGetterFunc // Logger represents the methods used by the worker to log details. Logger logger.Logger // Clock is used by the runner. Clock clock.Clock }
ManifoldConfig describes the resources used by a Worker.
func (ManifoldConfig) Validate ¶
func (cfg ManifoldConfig) Validate() error
type ModelService ¶
type ModelService interface { // Model returns information for the current model. Model(ctx context.Context) (model.ModelInfo, error) }
ModelService represents the model service provided by the provider.
type NewEphemeralProviderFunc ¶
type NewEphemeralProviderFunc func(ctx context.Context, cfg EphemeralConfig) (Provider, error)
NewEphemeralProviderFunc is a function that creates a new EphemeralProvider.
type NewTrackerWorkerFunc ¶
type NewTrackerWorkerFunc func(ctx context.Context, cfg TrackerConfig) (worker.Worker, error)
NewTrackerWorkerFunc is a function that creates a new TrackerWorker.
type NewWorkerFunc ¶
NewWorkerFunc is a function that creates a new Worker.
type Provider ¶
type Provider = providertracker.Provider
Provider is an interface that represents a provider, this can either be a CAAS broker or IAAS provider.
func NewEphemeralProvider ¶
func NewEphemeralProvider(ctx context.Context, config EphemeralConfig) (Provider, error)
NewEphemeralProvider loads a new ephemeral provider for the given model type and cloud spec. The provider is not updated, so if the credentials change, the provider will have to be recreated.
type ProviderConfigGetter ¶
type ProviderConfigGetter interface { environs.EnvironConfigGetter // ControllerUUID returns the UUID of the controller. ControllerUUID() uuid.UUID }
ProviderConfigGetter is an interface that extends environs.EnvironConfigGetter to include the ControllerUUID method.
type TrackerConfig ¶
type TrackerConfig struct { ModelService ModelService CloudService CloudService ConfigService ConfigService CredentialService CredentialService GetProviderForType func(coremodel.ModelType) (GetProviderFunc, error) Logger logger.Logger }
TrackerConfig describes the dependencies of a Worker.
func (TrackerConfig) Validate ¶
func (config TrackerConfig) Validate() error
Validate returns an error if the config cannot be used to start a Worker.
type TrackerType ¶
type TrackerType interface { // SingularNamespace returns the namespace for the provider tracker or // false if the tracker is not singular. SingularNamespace() (string, bool) }
TrackerType defines the configuration for a provider tracker.
func MultiType ¶
func MultiType() TrackerType
MultiType returns a new multi type. This allows the provider tracker to have multiple trackers.
func SingularType ¶
func SingularType(namespace string) TrackerType
SingularType returns a new singular type with the given namespace. This ensures that the provider tracker only has one tracker.