manager

package
v0.0.75 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package manager contains logic for creating Provider instances

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthManager

type AuthManager interface {
	NewOAuthConfig(providerClass db.ProviderClass, cli bool) (*oauth2.Config, error)
	ValidateCredentials(ctx context.Context, providerClass db.ProviderClass, cred v1.Credential, opts ...CredentialVerifyOptFn) error
}

AuthManager is the interface for managing authentication with provider classes

func NewAuthManager

func NewAuthManager(
	classManagers ...ProviderClassManager,
) (AuthManager, error)

NewAuthManager creates a new AuthManager for managing authentication with providers classes

type CredentialVerifyOptFn

type CredentialVerifyOptFn func(*CredentialVerifyParams)

CredentialVerifyOptFn is a function that sets options for credential verification

func WithRemoteUser

func WithRemoteUser(remoteUser string) CredentialVerifyOptFn

WithRemoteUser sets the remote user for the credential verification

type CredentialVerifyParams

type CredentialVerifyParams struct {
	RemoteUser string
}

CredentialVerifyParams are the currently supported parameters for credential verification

type NameProviderTuple

type NameProviderTuple struct {
	Name     string
	Provider v1.Provider
}

NameProviderTuple is a tuple of a provider name and the provider instance

type ProviderClassManager

type ProviderClassManager interface {

	// MarshallConfig validates the config and marshalls it into a format that can be stored in the database
	MarshallConfig(ctx context.Context, class db.ProviderClass, config json.RawMessage) (json.RawMessage, error)
	// Build creates an instance of Provider based on the config in the DB
	Build(ctx context.Context, config *db.Provider) (v1.Provider, error)
	// Delete deletes an instance of this provider
	Delete(ctx context.Context, config *db.Provider) error
	// GetSupportedClasses lists the types of Provider class which this manager
	// can produce.
	GetSupportedClasses() []db.ProviderClass
	// GetWebhookHandler returns the webhook handler for the provider class
	GetWebhookHandler() http.Handler
	// contains filtered or unexported methods
}

ProviderClassManager describes an interface for creating instances of a specific Provider class. The idea is that ProviderManager determines the class of the Provider, and delegates to the appropraite ProviderClassManager

type ProviderManager

type ProviderManager interface {
	// CreateFromConfig creates a new Provider instance in the database with a given configuration or the provider default
	CreateFromConfig(
		ctx context.Context, providerClass db.ProviderClass, projectID uuid.UUID, name string, config json.RawMessage,
	) (*db.Provider, error)
	// InstantiateFromID creates the provider from the Provider's UUID
	InstantiateFromID(ctx context.Context, providerID uuid.UUID) (v1.Provider, error)
	// InstantiateFromNameProject creates the provider using the provider's name and
	// project hierarchy.
	InstantiateFromNameProject(ctx context.Context, name string, projectID uuid.UUID) (v1.Provider, error)
	// BulkInstantiateByTrait instantiates multiple providers in the
	// project hierarchy. Providers are filtered by trait, and optionally by
	// name (empty name string means no filter by name).
	// To preserve compatibility with behaviour expected by the API, if a
	// provider cannot be instantiated, it will not cause the method to error
	// out, instead a list of failed provider names will be returned.
	BulkInstantiateByTrait(
		ctx context.Context,
		projectID uuid.UUID,
		trait db.ProviderType,
		name string,
	) (map[uuid.UUID]NameProviderTuple, []string, error)
	// DeleteByID deletes the specified instance of the Provider, and
	// carries out any cleanup needed.
	DeleteByID(ctx context.Context, providerID uuid.UUID, projectID uuid.UUID) error
	// DeleteByName deletes the specified instance of the Provider, and
	// carries out any cleanup needed.
	// Deletion will only occur if the provider is in the specified project -
	// it will not attempt to find a provider elsewhere in the hierarchy.
	DeleteByName(ctx context.Context, name string, projectID uuid.UUID) error
	// PatchProviderConfig updates the configuration of the specified provider with the specified patch.
	// All keys in the configMap will overwrite the fields in the provider config.
	PatchProviderConfig(ctx context.Context, providerName string, projectID uuid.UUID, configPatch map[string]any) error
	// IterateWebhookHandlers iterates over the classes and returns the associated webhook handler
	IterateWebhookHandlers() iter.Seq2[string, http.Handler]
}

ProviderManager encapsulates operations for manipulating Provider instances

func NewProviderManager

func NewProviderManager(
	ctx context.Context,
	store providers.ProviderStore,
	classManagers ...ProviderClassManager,
) (ProviderManager, func(), error)

NewProviderManager creates a new instance of ProviderManager

Directories

Path Synopsis
Package mock_manager is a generated GoMock package.
Package mock_manager is a generated GoMock package.
fixtures
Package fixtures contains code for creating ProfileService fixtures and is used in various parts of the code.
Package fixtures contains code for creating ProfileService fixtures and is used in various parts of the code.

Jump to

Keyboard shortcuts

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