provider

package
v0.0.0-...-0ded388 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: MIT Imports: 2 Imported by: 1

Documentation

Overview

Package provider defines the interface for Git forge providers.

This package contains the common interface and types used by all Git forge implementations (GitHub, GitLab, Gitea).

Interface

The Provider interface defines methods for:

  • Repository listing (organization and user)
  • Single repository retrieval
  • Organization listing
  • Token validation
  • Rate limit checking

Types

  • Repository: Common repository representation
  • Organization: Common organization representation
  • RateLimit: Rate limit status

Implementations

See the github, gitlab, and gitea packages for concrete implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ListOptions

type ListOptions struct {
	Page    int
	PerPage int
}

ListOptions common pagination options.

type Organization

type Organization struct {
	Name        string
	Description string
	URL         string
}

Organization represents an organization or group from any Git platform.

type Provider

type Provider interface {
	// Name returns the provider name (github, gitlab, gitea)
	Name() string

	// ListOrganizationRepos lists all repositories in an organization/group
	ListOrganizationRepos(ctx context.Context, org string) ([]*Repository, error)

	// ListUserRepos lists all repositories for a user
	ListUserRepos(ctx context.Context, user string) ([]*Repository, error)

	// GetRepository gets a single repository
	GetRepository(ctx context.Context, owner, repo string) (*Repository, error)

	// ListOrganizations lists organizations the authenticated user belongs to
	ListOrganizations(ctx context.Context) ([]*Organization, error)

	// GetRateLimit returns current rate limit status
	GetRateLimit(ctx context.Context) (*RateLimit, error)
}

Provider defines the interface for Git platform providers.

type ProviderWithAuth

type ProviderWithAuth interface {
	Provider

	// SetToken sets the authentication token
	SetToken(token string) error

	// ValidateToken validates the current token
	ValidateToken(ctx context.Context) (bool, error)
}

ProviderWithAuth extends Provider with authentication capabilities.

type RateLimit

type RateLimit struct {
	Limit     int
	Remaining int
	Reset     time.Time
	Used      int
}

RateLimit represents API rate limit information.

type Repository

type Repository struct {
	Name          string
	FullName      string
	CloneURL      string
	SSHURL        string
	HTMLURL       string
	Description   string
	DefaultBranch string
	Private       bool
	Archived      bool
	Fork          bool
	Disabled      bool
	Language      string
	Size          int
	Stars         int
	Topics        []string
	Visibility    string
	CreatedAt     time.Time
	UpdatedAt     time.Time
	PushedAt      time.Time
}

Repository represents a repository from any Git platform.

type SyncAction

type SyncAction string

SyncAction represents what action was taken during sync.

const (
	ActionCloned  SyncAction = "cloned"
	ActionUpdated SyncAction = "updated"
	ActionSkipped SyncAction = "skipped"
	ActionFailed  SyncAction = "failed"
)

type SyncOptions

type SyncOptions struct {
	TargetPath      string
	Parallel        int
	IncludeArchived bool
	IncludeForks    bool
	IncludePrivate  bool
	DryRun          bool
}

SyncOptions configures repository synchronization.

type SyncResult

type SyncResult struct {
	Repository *Repository
	Action     SyncAction
	Error      error
}

SyncResult represents the result of syncing a single repository.

type Syncer

type Syncer interface {
	// SyncOrganization syncs all repositories from an organization
	SyncOrganization(ctx context.Context, provider Provider, org string, opts SyncOptions) ([]SyncResult, error)
}

Syncer handles repository synchronization operations.

Jump to

Keyboard shortcuts

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