credentialvalidator

package
v0.0.0-...-4308112 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrModelCredentialChanged = errors.New("model cloud credential has changed")

ErrModelCredentialChanged indicates that a Worker has bounced because its model's cloud credential has changed.

View Source
var ErrValidityChanged = errors.New("cloud credential validity has changed")

ErrValidityChanged indicates that a Worker has bounced because its credential validity has changed: either a valid credential became invalid or invalid credential became valid.

Functions

func Manifold

func Manifold(config ManifoldConfig) dependency.Manifold

Manifold packages a Worker for use in a dependency.Engine.

func NewWorker

func NewWorker(ctx context.Context, config Config) (worker.Worker, error)

NewWorker returns a Worker that tracks the validity of the Model's cloud credential, as exposed by the Facade.

Types

type Config

type Config struct {
	Facade Facade
	Logger logger.Logger
}

Config holds the dependencies and configuration for a Worker.

func (Config) Validate

func (config Config) Validate() error

Validate returns an error if the config cannot be expected to drive a functional Worker.

type Facade

type Facade interface {
	// ModelCredential gets model's cloud credential.
	// Models that are on the clouds that do not require auth will return
	// false to signify that credential was not set.
	ModelCredential(context.Context) (base.StoredCredential, bool, error)

	// WatchCredential gets cloud credential watcher.
	WatchCredential(context.Context, string) (watcher.NotifyWatcher, error)

	// WatchModelCredential gets model's cloud credential watcher.
	WatchModelCredential(context.Context) (watcher.NotifyWatcher, error)
}

Facade exposes functionality required by a Worker to access and watch a cloud credential that a model uses.

func NewFacade

func NewFacade(apiCaller base.APICaller) (Facade, error)

NewFacade creates a *credentialvalidator.Facade and returns it as a Facade.

type ManifoldConfig

type ManifoldConfig struct {
	APICallerName string

	NewFacade func(base.APICaller) (Facade, error)
	NewWorker func(context.Context, Config) (worker.Worker, error)
	Logger    logger.Logger
}

ManifoldConfig holds the dependencies and configuration for a Worker manifold.

func (ManifoldConfig) Validate

func (config ManifoldConfig) Validate() error

Validate is called by start to check for bad configuration.

Jump to

Keyboard shortcuts

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