Documentation
¶
Index ¶
- Variables
- func GuessMimeType(path string) string
- type ContainerListerFactoryImpl
- func (f *ContainerListerFactoryImpl) Create(ctx context.Context, providerType domain.ProviderType, connectionID string) (driven.ContainerLister, error)
- func (f *ContainerListerFactoryImpl) Register(providerType domain.ProviderType, factory ProviderContainerListerFactory)
- func (f *ContainerListerFactoryImpl) SupportsContainerSelection(providerType domain.ProviderType) bool
- type Factory
- func (f *Factory) Create(ctx context.Context, source *domain.Source, containerID string) (driven.Connector, error)
- func (f *Factory) GetBuilder(providerType domain.ProviderType) (driven.ConnectorBuilder, error)
- func (f *Factory) GetOAuthConfig(providerType domain.ProviderType) *driven.OAuthConfig
- func (f *Factory) GetOAuthHandler(platform domain.PlatformType) OAuthHandler
- func (f *Factory) Register(builder driven.ConnectorBuilder)
- func (f *Factory) RegisterOAuthHandler(platform domain.PlatformType, handler OAuthHandler)
- func (f *Factory) SupportedTypes() []domain.ProviderType
- func (f *Factory) SupportsContainerSelection(providerType domain.ProviderType) bool
- func (f *Factory) SupportsOAuth(providerType domain.ProviderType) bool
- type OAuthDefaults
- type OAuthHandler
- type OAuthHandlerFactoryAdapter
- type ProviderContainerListerFactory
Constants ¶
This section is empty.
Variables ¶
var ErrRefreshNotSupported = domain.ErrUnsupportedProvider // Reuse existing error for now
ErrRefreshNotSupported indicates refresh must be handled via TokenProviderFactory
Functions ¶
func GuessMimeType ¶
GuessMimeType determines the MIME type of a file based on its extension or filename. Returns "text/plain" for unrecognised extensions.
Types ¶
type ContainerListerFactoryImpl ¶
type ContainerListerFactoryImpl struct {
// contains filtered or unexported fields
}
ContainerListerFactoryImpl creates ContainerListers for different providers.
func NewContainerListerFactory ¶
func NewContainerListerFactory() *ContainerListerFactoryImpl
NewContainerListerFactory creates a new container lister factory.
func (*ContainerListerFactoryImpl) Create ¶
func (f *ContainerListerFactoryImpl) Create(ctx context.Context, providerType domain.ProviderType, connectionID string) (driven.ContainerLister, error)
Create creates a ContainerLister for the given provider and connection.
func (*ContainerListerFactoryImpl) Register ¶
func (f *ContainerListerFactoryImpl) Register(providerType domain.ProviderType, factory ProviderContainerListerFactory)
Register registers a provider-specific factory.
func (*ContainerListerFactoryImpl) SupportsContainerSelection ¶
func (f *ContainerListerFactoryImpl) SupportsContainerSelection(providerType domain.ProviderType) bool
SupportsContainerSelection returns true if the provider supports container selection.
type Factory ¶
type Factory struct {
// contains filtered or unexported fields
}
Factory creates connectors and manages OAuth handlers. It maintains a registry of ConnectorBuilders and OAuthHandlers for each provider type.
func NewFactory ¶
func NewFactory(tokenProviderFactory driven.TokenProviderFactory) *Factory
NewFactory creates a connector factory.
func (*Factory) Create ¶
func (f *Factory) Create(ctx context.Context, source *domain.Source, containerID string) (driven.Connector, error)
Create creates a connector for the given source, scoped to a container. Called by SyncOrchestrator once per container in source.SelectedContainers. For providers without container selection, containerID may be empty.
func (*Factory) GetBuilder ¶
func (f *Factory) GetBuilder(providerType domain.ProviderType) (driven.ConnectorBuilder, error)
GetBuilder returns the builder for a provider type.
func (*Factory) GetOAuthConfig ¶
func (f *Factory) GetOAuthConfig(providerType domain.ProviderType) *driven.OAuthConfig
GetOAuthConfig returns OAuth configuration for a provider. Returns nil if the provider doesn't support OAuth.
func (*Factory) GetOAuthHandler ¶
func (f *Factory) GetOAuthHandler(platform domain.PlatformType) OAuthHandler
GetOAuthHandler returns the OAuth handler for a platform type. Returns nil if no handler is registered.
func (*Factory) Register ¶
func (f *Factory) Register(builder driven.ConnectorBuilder)
Register registers a connector builder for a provider type.
func (*Factory) RegisterOAuthHandler ¶
func (f *Factory) RegisterOAuthHandler(platform domain.PlatformType, handler OAuthHandler)
RegisterOAuthHandler registers an OAuth handler for a platform type.
func (*Factory) SupportedTypes ¶
func (f *Factory) SupportedTypes() []domain.ProviderType
SupportedTypes returns all registered provider types.
func (*Factory) SupportsContainerSelection ¶
func (f *Factory) SupportsContainerSelection(providerType domain.ProviderType) bool
SupportsContainerSelection returns true if the provider supports container selection.
func (*Factory) SupportsOAuth ¶
func (f *Factory) SupportsOAuth(providerType domain.ProviderType) bool
SupportsOAuth returns true if the provider supports OAuth authentication.
type OAuthDefaults ¶
type OAuthDefaults struct {
// AuthURL is the OAuth authorization endpoint.
AuthURL string
// TokenURL is the OAuth token exchange endpoint.
TokenURL string
// Scopes are the default OAuth scopes to request.
Scopes []string
// UserInfoURL is the endpoint to fetch user information (optional).
UserInfoURL string
// SupportsPKCE indicates if the provider supports PKCE.
SupportsPKCE bool
}
OAuthDefaults contains a provider's default OAuth configuration.
type OAuthHandler ¶
type OAuthHandler interface {
// BuildAuthURL constructs the OAuth authorization URL.
// Parameters:
// - clientID: OAuth application client ID
// - redirectURI: Where to redirect after authorization
// - state: CSRF protection token
// - codeChallenge: PKCE code challenge (S256 hash of code verifier)
// - scopes: Requested OAuth scopes
// Returns the full authorization URL to redirect the user to.
BuildAuthURL(clientID, redirectURI, state, codeChallenge string, scopes []string) string
// ExchangeCode exchanges an authorization code for tokens.
// Parameters:
// - ctx: Context for cancellation
// - clientID: OAuth application client ID
// - clientSecret: OAuth application client secret
// - code: Authorization code from callback
// - redirectURI: Must match the URI used in authorization
// - codeVerifier: PKCE code verifier (plain text)
// Returns the OAuth tokens (access token, refresh token, etc.)
ExchangeCode(ctx context.Context, clientID, clientSecret, code, redirectURI, codeVerifier string) (*driven.OAuthToken, error)
// RefreshToken refreshes an expired access token.
// Parameters:
// - ctx: Context for cancellation
// - clientID: OAuth application client ID
// - clientSecret: OAuth application client secret
// - refreshToken: The refresh token from previous authorization
// Returns new OAuth tokens.
RefreshToken(ctx context.Context, clientID, clientSecret, refreshToken string) (*driven.OAuthToken, error)
// GetUserInfo fetches the account identifier (email or username).
// This is used to display which account is connected and to prevent duplicates.
// Parameters:
// - ctx: Context for cancellation
// - accessToken: Valid access token
// Returns the account identifier (typically email or username).
GetUserInfo(ctx context.Context, accessToken string) (*driven.OAuthUserInfo, error)
// DefaultConfig returns the provider's default OAuth configuration.
// This includes auth URL, token URL, and default scopes.
DefaultConfig() OAuthDefaults
}
OAuthHandler provides OAuth operations for a specific provider. Each provider (GitHub, Google Drive, etc.) has its own implementation.
type OAuthHandlerFactoryAdapter ¶
type OAuthHandlerFactoryAdapter struct {
// contains filtered or unexported fields
}
OAuthHandlerFactoryAdapter adapts connectors.Factory to implement driven.OAuthHandlerFactory. This abstraction allows services to avoid importing the adapters layer directly.
func NewOAuthHandlerFactory ¶
func NewOAuthHandlerFactory(factory *Factory) *OAuthHandlerFactoryAdapter
NewOAuthHandlerFactory creates an adapter that implements driven.OAuthHandlerFactory
func (*OAuthHandlerFactoryAdapter) GetOAuthHandler ¶
func (a *OAuthHandlerFactoryAdapter) GetOAuthHandler(platform domain.PlatformType) driven.OAuthHandler
GetOAuthHandler implements driven.OAuthHandlerFactory
type ProviderContainerListerFactory ¶
type ProviderContainerListerFactory interface {
// Create creates a ContainerLister for a connection.
Create(ctx context.Context, connectionID string) (driven.ContainerLister, error)
}
ProviderContainerListerFactory creates ContainerListers for a specific provider type.