Documentation
¶
Overview ¶
Package scm provides client implementations for various SCM (Source Code Management) providers
Index ¶
- Variables
- type AuthType
- type AzureClient
- func (c *AzureClient) GetRepository(ctx context.Context, fullName string) (*Repository, error)
- func (c *AzureClient) GetUser(ctx context.Context) (*User, error)
- func (c *AzureClient) ListOrganizations(ctx context.Context, opts ListOptions) ([]Organization, error)
- func (c *AzureClient) ListRepositories(ctx context.Context, opts ListOptions) (*ListResult, error)
- func (c *AzureClient) TestConnection(ctx context.Context) (*ConnectionTestResult, error)
- type BitbucketClient
- func (c *BitbucketClient) GetRepository(ctx context.Context, fullName string) (*Repository, error)
- func (c *BitbucketClient) GetUser(ctx context.Context) (*User, error)
- func (c *BitbucketClient) ListOrganizations(ctx context.Context, opts ListOptions) ([]Organization, error)
- func (c *BitbucketClient) ListRepositories(ctx context.Context, opts ListOptions) (*ListResult, error)
- func (c *BitbucketClient) TestConnection(ctx context.Context) (*ConnectionTestResult, error)
- type Client
- type ClientFactory
- type Config
- type ConnectionTestResult
- type GitHubClient
- func (c *GitHubClient) GetRepository(ctx context.Context, fullName string) (*Repository, error)
- func (c *GitHubClient) GetUser(ctx context.Context) (*User, error)
- func (c *GitHubClient) ListOrganizations(ctx context.Context, opts ListOptions) ([]Organization, error)
- func (c *GitHubClient) ListRepositories(ctx context.Context, opts ListOptions) (*ListResult, error)
- func (c *GitHubClient) TestConnection(ctx context.Context) (*ConnectionTestResult, error)
- type GitLabClient
- func (c *GitLabClient) GetRepository(ctx context.Context, fullName string) (*Repository, error)
- func (c *GitLabClient) GetUser(ctx context.Context) (*User, error)
- func (c *GitLabClient) ListOrganizations(ctx context.Context, opts ListOptions) ([]Organization, error)
- func (c *GitLabClient) ListRepositories(ctx context.Context, opts ListOptions) (*ListResult, error)
- func (c *GitLabClient) TestConnection(ctx context.Context) (*ConnectionTestResult, error)
- type ListOptions
- type ListResult
- type Organization
- type Provider
- type RateLimit
- type Repository
- type SCMError
- type User
Constants ¶
This section is empty.
Variables ¶
var ( ErrUnsupportedProvider = NewSCMError("unsupported SCM provider", "UNSUPPORTED_PROVIDER") ErrAuthFailed = NewSCMError("authentication failed", "AUTH_FAILED") ErrRateLimited = NewSCMError("rate limit exceeded", "RATE_LIMITED") ErrNotFound = NewSCMError("resource not found", "NOT_FOUND") ErrPermissionDenied = NewSCMError("permission denied", "PERMISSION_DENIED") )
Common errors
Functions ¶
This section is empty.
Types ¶
type AzureClient ¶
type AzureClient struct {
// contains filtered or unexported fields
}
AzureClient implements the Client interface for Azure DevOps Supports both Azure DevOps Services (dev.azure.com) and Azure DevOps Server
func NewAzureClient ¶
func NewAzureClient(config Config) (*AzureClient, error)
NewAzureClient creates a new Azure DevOps client
func (*AzureClient) GetRepository ¶
func (c *AzureClient) GetRepository(ctx context.Context, fullName string) (*Repository, error)
GetRepository returns a single repository by full name (project/repo)
func (*AzureClient) GetUser ¶
func (c *AzureClient) GetUser(ctx context.Context) (*User, error)
GetUser returns the authenticated user
func (*AzureClient) ListOrganizations ¶
func (c *AzureClient) ListOrganizations(ctx context.Context, opts ListOptions) ([]Organization, error)
ListOrganizations returns organizations/projects the user has access to
func (*AzureClient) ListRepositories ¶
func (c *AzureClient) ListRepositories(ctx context.Context, opts ListOptions) (*ListResult, error)
ListRepositories returns repositories accessible to the user
func (*AzureClient) TestConnection ¶
func (c *AzureClient) TestConnection(ctx context.Context) (*ConnectionTestResult, error)
TestConnection verifies the connection and returns user/org info
type BitbucketClient ¶
type BitbucketClient struct {
// contains filtered or unexported fields
}
BitbucketClient implements the Client interface for Bitbucket Supports both Bitbucket Cloud (bitbucket.org) and Bitbucket Server/Data Center
func NewBitbucketClient ¶
func NewBitbucketClient(config Config) (*BitbucketClient, error)
NewBitbucketClient creates a new Bitbucket client
func (*BitbucketClient) GetRepository ¶
func (c *BitbucketClient) GetRepository(ctx context.Context, fullName string) (*Repository, error)
GetRepository returns a single repository by full name
func (*BitbucketClient) GetUser ¶
func (c *BitbucketClient) GetUser(ctx context.Context) (*User, error)
GetUser returns the authenticated user
func (*BitbucketClient) ListOrganizations ¶
func (c *BitbucketClient) ListOrganizations(ctx context.Context, opts ListOptions) ([]Organization, error)
ListOrganizations returns workspaces/projects the user has access to
func (*BitbucketClient) ListRepositories ¶
func (c *BitbucketClient) ListRepositories(ctx context.Context, opts ListOptions) (*ListResult, error)
ListRepositories returns repositories accessible to the user
func (*BitbucketClient) TestConnection ¶
func (c *BitbucketClient) TestConnection(ctx context.Context) (*ConnectionTestResult, error)
TestConnection verifies the connection and returns user/org info
type Client ¶
type Client interface {
// TestConnection verifies the connection and returns user/org info
TestConnection(ctx context.Context) (*ConnectionTestResult, error)
// GetUser returns the authenticated user
GetUser(ctx context.Context) (*User, error)
// ListOrganizations returns organizations the user has access to
ListOrganizations(ctx context.Context, opts ListOptions) ([]Organization, error)
// ListRepositories returns repositories accessible to the user
// If organization is set in config, filters by that organization
ListRepositories(ctx context.Context, opts ListOptions) (*ListResult, error)
// GetRepository returns a single repository by full name (owner/repo)
GetRepository(ctx context.Context, fullName string) (*Repository, error)
}
Client defines the interface for SCM provider clients
type ClientFactory ¶
type ClientFactory struct{}
ClientFactory creates SCM clients based on provider
func NewClientFactory ¶
func NewClientFactory() *ClientFactory
NewClientFactory creates a new ClientFactory
func (*ClientFactory) CreateClient ¶
func (f *ClientFactory) CreateClient(config Config) (Client, error)
CreateClient creates an SCM client for the given config
type Config ¶
type Config struct {
Provider Provider
BaseURL string // Base URL for self-hosted instances
AccessToken string
Organization string // Optional: filter by organization/group
AuthType AuthType
}
Config holds the configuration for an SCM client
type ConnectionTestResult ¶
type ConnectionTestResult struct {
Success bool
Message string
User *User
Organization *Organization
RepoCount int
RateLimit *RateLimit
}
ConnectionTestResult represents the result of testing a connection
type GitHubClient ¶
type GitHubClient struct {
// contains filtered or unexported fields
}
GitHubClient implements the Client interface for GitHub
func NewGitHubClient ¶
func NewGitHubClient(config Config) (*GitHubClient, error)
NewGitHubClient creates a new GitHub client
func (*GitHubClient) GetRepository ¶
func (c *GitHubClient) GetRepository(ctx context.Context, fullName string) (*Repository, error)
GetRepository returns a single repository by full name
func (*GitHubClient) GetUser ¶
func (c *GitHubClient) GetUser(ctx context.Context) (*User, error)
GetUser returns the authenticated user
func (*GitHubClient) ListOrganizations ¶
func (c *GitHubClient) ListOrganizations(ctx context.Context, opts ListOptions) ([]Organization, error)
ListOrganizations returns organizations the user has access to
func (*GitHubClient) ListRepositories ¶
func (c *GitHubClient) ListRepositories(ctx context.Context, opts ListOptions) (*ListResult, error)
ListRepositories returns repositories accessible to the user
func (*GitHubClient) TestConnection ¶
func (c *GitHubClient) TestConnection(ctx context.Context) (*ConnectionTestResult, error)
TestConnection verifies the connection and returns user/org info
type GitLabClient ¶
type GitLabClient struct {
// contains filtered or unexported fields
}
GitLabClient implements the Client interface for GitLab
func NewGitLabClient ¶
func NewGitLabClient(config Config) (*GitLabClient, error)
NewGitLabClient creates a new GitLab client
func (*GitLabClient) GetRepository ¶
func (c *GitLabClient) GetRepository(ctx context.Context, fullName string) (*Repository, error)
GetRepository returns a single project by full path (namespace/project)
func (*GitLabClient) GetUser ¶
func (c *GitLabClient) GetUser(ctx context.Context) (*User, error)
GetUser returns the authenticated user
func (*GitLabClient) ListOrganizations ¶
func (c *GitLabClient) ListOrganizations(ctx context.Context, opts ListOptions) ([]Organization, error)
ListOrganizations returns groups the user has access to
func (*GitLabClient) ListRepositories ¶
func (c *GitLabClient) ListRepositories(ctx context.Context, opts ListOptions) (*ListResult, error)
ListRepositories returns projects accessible to the user
func (*GitLabClient) TestConnection ¶
func (c *GitLabClient) TestConnection(ctx context.Context) (*ConnectionTestResult, error)
TestConnection verifies the connection and returns user/org info
type ListOptions ¶
ListOptions represents pagination options
type ListResult ¶
type ListResult struct {
Repositories []Repository
Total int
HasMore bool
NextPage int
}
ListResult represents a paginated list result
type Organization ¶
type Organization struct {
ID string
Name string
Description string
AvatarURL string
RepoCount int
}
Organization represents an organization/group from the SCM provider
type Repository ¶
type Repository struct {
ID string
Name string
FullName string
Description string
HTMLURL string
CloneURL string
SSHURL string
DefaultBranch string
IsPrivate bool
IsFork bool
IsArchived bool
Language string // Primary language
Languages map[string]int // All languages with byte counts
Topics []string
Stars int
Forks int
Size int // Size in KB
CreatedAt time.Time
UpdatedAt time.Time
PushedAt time.Time
}
Repository represents a repository from the SCM provider
type SCMError ¶
SCMError represents an error from an SCM provider
func NewSCMError ¶
NewSCMError creates a new SCMError