source

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NewGitHubSource func(config Config) Source

NewGitHubSource creates a GitHub source - placeholder until github package is created

View Source
var NewGitLabSource func(config Config) Source

NewGitLabSource creates a GitLab source - placeholder until gitlab package is created

Functions

This section is empty.

Types

type Commit

type Commit struct {
	Repo       Repo
	GitRef     string // Fallback reference
	GitTag     string // Semantic version tag
	BranchName string // Branch name
	CommitSha  string // Exact commit SHA
}

Commit represents a git reference

type Config

type Config struct {
	ApiVersion string        // v3 for GitHub, v4 for GitLab
	Logger     *logrus.Entry // Logger instance
}

Config holds source-specific configuration

type Release

type Release struct {
	Id     int
	Url    string
	Name   string
	Assets []ReleaseAsset
}

Release represents release info

type ReleaseAsset

type ReleaseAsset struct {
	Id   int    // Asset ID
	Url  string // Direct download URL
	Name string // Asset filename
}

ReleaseAsset represents a downloadable release asset

type Repo

type Repo struct {
	Url     string     // Full repo URL
	BaseUrl string     // Host (github.com, gitlab.com, enterprise host)
	ApiUrl  string     // API endpoint base URL
	Owner   string     // Account/namespace (can be nested for GitLab: group/subgroup)
	Name    string     // Repository name
	Token   string     // Auth token
	Type    SourceType // Provider type
}

Repo represents a repository on any source

type Source

type Source interface {
	// Type returns the source type identifier
	Type() SourceType

	// ParseUrl parses repo URL into Repo struct
	ParseUrl(repoUrl, token string) (Repo, error)

	// FetchTags returns all semver tags from the repository
	FetchTags(repoUrl, token string) ([]string, error)

	// GetReleaseInfo returns release information for a specific tag
	GetReleaseInfo(repo Repo, tag string) (Release, error)

	// DownloadReleaseAsset downloads a release asset to destPath
	DownloadReleaseAsset(repo Repo, asset ReleaseAsset, destPath string, withProgress bool) error

	// MakeArchiveRequest creates HTTP request to download repo archive
	MakeArchiveRequest(commit Commit, token string) (*http.Request, error)

	// DownloadSourceZip downloads repo archive for a git ref and returns temp file path
	DownloadSourceZip(repo Repo, gitRef string) (string, error)
}

Source interface defines operations every provider must implement

func GetSource

func GetSource(repoUrl string, explicitType SourceType, config Config) (Source, error)

GetSource auto-detects or uses explicit type to create a Source implementation

func NewSource

func NewSource(sourceType SourceType, config Config) (Source, error)

NewSource creates a Source implementation based on type

type SourceType

type SourceType string

SourceType identifies the provider type

const (
	TypeGitHub SourceType = "github"
	TypeGitLab SourceType = "gitlab"
	TypeAuto   SourceType = "auto"
)

func DetectSourceType

func DetectSourceType(repoUrl string) (SourceType, error)

DetectSourceType determines provider from URL Auto-detects GitHub or GitLab if the hostname contains "github" or "gitlab" Returns GitHub as default for unknown hosts (backward compatibility)

func ParseSourceType

func ParseSourceType(s string) (SourceType, error)

ParseSourceType converts string to SourceType

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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