Documentation
¶
Overview ¶
Package keystore manages credential persistence, token refresh, client pooling, and operation execution for integration providers
Index ¶
- Variables
- func FlattenDescriptors(entries map[types.ProviderType][]types.ClientDescriptor) []types.ClientDescriptor
- func FlattenOperationDescriptors(entries map[types.ProviderType][]types.OperationDescriptor) []types.OperationDescriptor
- func Schema() *jsonschema.Schema
- type AuthType
- type Broker
- type ClientBuilder
- type ClientBuilderFunc
- type ClientDescriptor
- type ClientName
- type ClientPool
- type ClientPoolManager
- type ClientPoolOption
- type ClientRequestOption
- type CredentialSource
- type GitHubAppSpec
- type GoogleWorkloadIdentitySpec
- type OperationDescriptor
- type OperationManager
- type OperationManagerOption
- type OperationName
- type OperationRequest
- type OperationResult
- type PersistenceSpec
- type Store
- func (s *Store) DeleteIntegration(ctx context.Context, orgID string, integrationID string) (types.ProviderType, string, error)
- func (s *Store) EnsureIntegration(ctx context.Context, orgID string, provider types.ProviderType) (*ent.Integration, error)
- func (s *Store) LoadCredential(ctx context.Context, orgID string, provider types.ProviderType) (types.CredentialPayload, error)
- func (s *Store) SaveCredential(ctx context.Context, orgID string, payload types.CredentialPayload) (types.CredentialPayload, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrProviderRequired indicates a credential operation lacked a provider identifier ErrProviderRequired = errors.New("keystore: provider required") // ErrOrgIDRequired indicates the caller did not provide an organization identifier ErrOrgIDRequired = errors.New("keystore: org id required") // ErrCredentialNotFound indicates no credential exists for the supplied org/provider ErrCredentialNotFound = errors.New("keystore: credential not found") // ErrProviderNotRegistered indicates the registry does not have a provider implementation for the requested type ErrProviderNotRegistered = errors.New("keystore: provider not registered") // ErrBrokerRequired indicates a client pool was constructed without a credential broker/source ErrBrokerRequired = errors.New("keystore: credential broker required") // ErrClientBuilderRequired indicates a client pool was constructed without a builder ErrClientBuilderRequired = errors.New("keystore: client builder required") ErrClientUnavailable = errors.New("keystore: client unavailable") // ErrClientNotRegistered indicates no client descriptor/pool exists for the requested provider+client pair ErrClientNotRegistered = errors.New("keystore: client not registered") // ErrClientDescriptorInvalid indicates a provider published an invalid client descriptor ErrClientDescriptorInvalid = errors.New("keystore: client descriptor invalid") // ErrOperationNameRequired indicates the caller omitted an operation identifier ErrOperationNameRequired = errors.New("keystore: operation name required") // ErrOperationNotRegistered indicates no operation exists for the requested provider/name pair ErrOperationNotRegistered = errors.New("keystore: operation not registered") // ErrOperationDescriptorInvalid indicates a provider published an invalid operation descriptor ErrOperationDescriptorInvalid = errors.New("keystore: operation descriptor invalid") // ErrOperationClientManagerRequired indicates an operation requires a client pool but none was provided ErrOperationClientManagerRequired = errors.New("keystore: client manager required for operation") // ErrStoreNotInitialized indicates the store instance is nil ErrStoreNotInitialized = errors.New("keystore: store not initialized") )
Functions ¶
func FlattenDescriptors ¶
func FlattenDescriptors(entries map[types.ProviderType][]types.ClientDescriptor) []types.ClientDescriptor
FlattenDescriptors converts a map of provider descriptors into a single slice for manager construction
func FlattenOperationDescriptors ¶
func FlattenOperationDescriptors(entries map[types.ProviderType][]types.OperationDescriptor) []types.OperationDescriptor
FlattenOperationDescriptors converts a map of provider operations into a single slice for manager construction
func Schema ¶
func Schema() *jsonschema.Schema
Schema returns the JSON schema for integration provider specifications.
Types ¶
type Broker ¶
type Broker struct {
// contains filtered or unexported fields
}
Broker exchanges persisted credentials for short-lived tokens via registered providers
type ClientBuilder ¶
type ClientBuilder[T any, Config any] interface { // Build constructs a new client instance using the supplied credential payload and configuration Build(ctx context.Context, payload types.CredentialPayload, config Config) (T, error) // ProviderType returns the provider identifier handled by this builder ProviderType() types.ProviderType }
ClientBuilder constructs provider SDK clients from credential payloads
type ClientBuilderFunc ¶
type ClientBuilderFunc[T any, Config any] struct { // Provider identifies which provider this builder handles Provider types.ProviderType // BuildFn is the function that constructs the client BuildFn func(context.Context, types.CredentialPayload, Config) (T, error) }
ClientBuilderFunc adapts a function to the ClientBuilder interface
func (ClientBuilderFunc[T, Config]) Build ¶
func (f ClientBuilderFunc[T, Config]) Build(ctx context.Context, payload types.CredentialPayload, config Config) (T, error)
Build constructs the client using the configured function
func (ClientBuilderFunc[T, Config]) ProviderType ¶
func (f ClientBuilderFunc[T, Config]) ProviderType() types.ProviderType
ProviderType returns the provider identifier for the builder
type ClientDescriptor ¶
type ClientDescriptor = types.ClientDescriptor
type ClientName ¶
type ClientName = types.ClientName
type ClientPool ¶
ClientPool orchestrates credential retrieval and client caching for a specific provider type
func NewClientPool ¶
func NewClientPool[T any, Config any](source CredentialSource, builder ClientBuilder[T, Config], opts ...ClientPoolOption[T, Config]) (*ClientPool[T, Config], error)
NewClientPool builds a client pool that reuses provider SDK clients using eddy's caching primitives
func (*ClientPool[T, Config]) Get ¶
func (p *ClientPool[T, Config]) Get(ctx context.Context, orgID string, opts ...ClientRequestOption[Config]) (T, error)
Get returns a provider-specific client for the supplied organization, reusing cached instances when possible
func (*ClientPool[T, Config]) Provider ¶
func (p *ClientPool[T, Config]) Provider() types.ProviderType
Provider returns the provider type handled by this pool
type ClientPoolManager ¶
type ClientPoolManager struct {
// contains filtered or unexported fields
}
ClientPoolManager manages client pools constructed from provider-published descriptors
func NewClientPoolManager ¶
func NewClientPoolManager(source CredentialSource, descriptors []types.ClientDescriptor) (*ClientPoolManager, error)
NewClientPoolManager builds a manager from the supplied credential source and descriptors
func (*ClientPoolManager) Descriptors ¶
func (m *ClientPoolManager) Descriptors() map[types.ProviderType][]types.ClientDescriptor
Descriptors returns a copy of all registered descriptors keyed by provider
func (*ClientPoolManager) Get ¶
func (m *ClientPoolManager) Get(ctx context.Context, orgID string, provider types.ProviderType, client types.ClientName, opts ...ClientRequestOption[map[string]any]) (any, error)
Get retrieves a client for the given provider/client name pair
func (*ClientPoolManager) RegisterDescriptor ¶
func (m *ClientPoolManager) RegisterDescriptor(descriptor types.ClientDescriptor) error
RegisterDescriptor registers a single client descriptor and lazily constructs its pool
type ClientPoolOption ¶
type ClientPoolOption[T any, Config any] func(*ClientPool[T, Config], *clientPoolSettings[Config])
ClientPoolOption customizes client pool construction
func WithClientConfigClone ¶
func WithClientConfigClone[T any, Config any](clone func(Config) Config) ClientPoolOption[T, Config]
WithClientConfigClone configures how per-request config structs are cloned before invoking the builder
func WithClientPoolTTL ¶
func WithClientPoolTTL[T any, Config any](ttl time.Duration) ClientPoolOption[T, Config]
WithClientPoolTTL overrides the default client cache TTL
type ClientRequestOption ¶
type ClientRequestOption[Config any] func(*clientRequest[Config])
ClientRequestOption customizes Get requests
func WithClientConfig ¶
func WithClientConfig[Config any](config Config) ClientRequestOption[Config]
WithClientConfig supplies provider-specific builder configuration
func WithClientForceRefresh ¶
func WithClientForceRefresh[Config any]() ClientRequestOption[Config]
WithClientForceRefresh bypasses cached credentials and forces a mint operation
type CredentialSource ¶
type CredentialSource interface {
// Get retrieves the latest credential payload for the given org/provider pair
Get(ctx context.Context, orgID string, provider types.ProviderType) (types.CredentialPayload, error)
// Mint obtains a fresh credential payload for the given org/provider pair
Mint(ctx context.Context, orgID string, provider types.ProviderType) (types.CredentialPayload, error)
}
CredentialSource exposes the subset of broker operations required by the client pool
type GitHubAppSpec ¶
type GitHubAppSpec = config.GitHubAppSpec
type GoogleWorkloadIdentitySpec ¶
type GoogleWorkloadIdentitySpec = config.GoogleWorkloadIdentitySpec
type OperationDescriptor ¶
type OperationDescriptor = types.OperationDescriptor
type OperationManager ¶
type OperationManager struct {
// contains filtered or unexported fields
}
OperationManager executes provider-published operations using stored credentials and optional client pools
func NewOperationManager ¶
func NewOperationManager(source CredentialSource, descriptors []types.OperationDescriptor, opts ...OperationManagerOption) (*OperationManager, error)
NewOperationManager builds an OperationManager from the supplied credential source and descriptors
func (*OperationManager) Descriptors ¶
func (m *OperationManager) Descriptors() map[types.ProviderType][]types.OperationDescriptor
Descriptors returns a copy of all registered operations keyed by provider
func (*OperationManager) RegisterDescriptor ¶
func (m *OperationManager) RegisterDescriptor(descriptor types.OperationDescriptor) error
RegisterDescriptor registers an operation descriptor and makes it available to callers
func (*OperationManager) Run ¶
func (m *OperationManager) Run(ctx context.Context, req types.OperationRequest) (types.OperationResult, error)
Run executes the requested provider operation using stored credentials and optional clients
type OperationManagerOption ¶
type OperationManagerOption func(*OperationManager)
OperationManagerOption customizes manager construction
func WithOperationClients ¶
func WithOperationClients(clients *ClientPoolManager) OperationManagerOption
WithOperationClients registers the client pool manager used to satisfy operation client dependencies
type OperationName ¶
type OperationName = types.OperationName
type OperationRequest ¶
type OperationRequest = types.OperationRequest
type OperationResult ¶
type OperationResult = types.OperationResult
type PersistenceSpec ¶
type PersistenceSpec = config.PersistenceSpec
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store persists credential payloads using Ent-backed integrations and hush secrets
func (*Store) DeleteIntegration ¶
func (s *Store) DeleteIntegration(ctx context.Context, orgID string, integrationID string) (types.ProviderType, string, error)
DeleteIntegration removes the integration and associated secrets for the given org
func (*Store) EnsureIntegration ¶
func (s *Store) EnsureIntegration(ctx context.Context, orgID string, provider types.ProviderType) (*ent.Integration, error)
EnsureIntegration guarantees an integration record exists for the given org/provider pair
func (*Store) LoadCredential ¶
func (s *Store) LoadCredential(ctx context.Context, orgID string, provider types.ProviderType) (types.CredentialPayload, error)
LoadCredential retrieves the credential payload for the given org/provider pair
func (*Store) SaveCredential ¶
func (s *Store) SaveCredential(ctx context.Context, orgID string, payload types.CredentialPayload) (types.CredentialPayload, error)
SaveCredential upserts the credential payload for the given org/provider pair