release

package
v1.10.5 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package release provides the shared release model (Release, ReleaseAsset) and a Provider factory that resolves the correct VCS backend (GitHub or GitLab) from tool configuration for use by the self-update system.

Index

Constants

View Source
const (
	SourceTypeGitHub    = "github"
	SourceTypeGitLab    = "gitlab"
	SourceTypeBitbucket = "bitbucket"
	SourceTypeGitea     = "gitea"
	SourceTypeCodeberg  = "codeberg"
	SourceTypeDirect    = "direct"
)

SourceType constants identify the built-in release provider types. Any string is accepted by the registry; downstream consumers may define their own constants for custom providers.

Variables

View Source
var (
	// ErrProviderNotFound is returned by Lookup when no factory has been
	// registered for the requested source type.
	ErrProviderNotFound = errors.New("no release provider registered for source type")

	// ErrNotSupported is returned by provider methods that are not applicable
	// for the underlying platform (e.g. ListReleases on Bitbucket).
	ErrNotSupported = errors.New("operation not supported by this release provider")

	// ErrVersionUnknown is returned by the direct provider when neither
	// version_url nor pinned_version is configured and a version check is
	// requested.
	ErrVersionUnknown = errors.New("cannot determine latest version: configure version_url or pinned_version in Params")
)

Functions

func Register added in v1.8.0

func Register(sourceType string, factory ProviderFactory)

Register associates a source type string with a ProviderFactory. Safe to call concurrently. Intended to be called from init() functions or early in main() before any Lookup call. Calling Register with an already-registered type overwrites the previous factory.

func RegisteredTypes added in v1.8.0

func RegisteredTypes() []string

RegisteredTypes returns a sorted slice of all currently registered source type strings. Used for generating user-facing error messages.

Types

type Provider

type Provider interface {
	GetLatestRelease(ctx context.Context, owner, repo string) (Release, error)
	GetReleaseByTag(ctx context.Context, owner, repo, tag string) (Release, error)
	ListReleases(ctx context.Context, owner, repo string, limit int) ([]Release, error)
	DownloadReleaseAsset(ctx context.Context, owner, repo string, asset ReleaseAsset) (io.ReadCloser, string, error)
}

Provider defines the operations a release backend must support.

type ProviderFactory added in v1.8.0

type ProviderFactory func(source ReleaseSourceConfig, cfg config.Containable) (Provider, error)

ProviderFactory is a function that constructs a release.Provider from a ReleaseSourceConfig and a Viper configuration subtree.

func Lookup added in v1.8.0

func Lookup(sourceType string) (ProviderFactory, error)

Lookup returns the ProviderFactory registered for the given source type. Returns ErrProviderNotFound if no factory has been registered for that type.

type Release

type Release interface {
	GetName() string
	GetTagName() string
	GetBody() string
	GetDraft() bool
	GetAssets() []ReleaseAsset
}

Release defines the common abstraction for a software release.

type ReleaseAsset

type ReleaseAsset interface {
	GetID() int64
	GetName() string
	GetBrowserDownloadURL() string
}

ReleaseAsset defines the common abstraction for a release asset.

type ReleaseSourceConfig added in v1.8.0

type ReleaseSourceConfig struct {
	Type    string
	Host    string
	Owner   string
	Repo    string
	Private bool
	// Params holds provider-specific configuration key/value pairs.
	// Keys use snake_case. Valid keys are documented per provider.
	Params map[string]string
}

ReleaseSourceConfig carries the information a ProviderFactory needs to construct its client. It is populated from props.ReleaseSource, and exists as a separate type to avoid a circular import between pkg/vcs/release and pkg/props.

Jump to

Keyboard shortcuts

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