source

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotParametrized = errors.New("source is not parametrized")
	ErrNotRegistered   = errors.New("source type is not registered")
)

Functions

func IsVersionNotFound

func IsVersionNotFound(err error) bool

func Register

func Register(name string, builder func(map[string]any) (Source, error)) bool

Types

type Downloads

type Downloads interface {
	// ConfigPreview returns key-value pairs of configuration preview.
	ConfigPreview() (pairs []string)

	WriteDownload(ctx context.Context, w http.ResponseWriter, v util.Version, arch string)

	LatestDownloadVersion(ctx context.Context) (latest util.Version, err error)
}

type Source

type Source interface {
	// Parametrize returns new source with specified parameters.
	Parametrize(module string, params map[string]any) (Source, error)

	// ConfigPreview returns key-value pairs of configuration preview.
	ConfigPreview() (pairs []string)

	// ListVersions returns list of all versions at form v1.0.0.
	// For major 1, also major 0 is used.
	ListVersions(ctx context.Context, major uint) ([]string, error)

	// LatestVersion returns latest version with specified major.
	// For major 1, also major 0 is used.
	// Latest stable version is released if exist.
	LatestVersion(ctx context.Context, major uint) (string, error)

	// DownloadModule download module files at specified version to specified directory.
	//
	// For version v1.0.0 and directory /tmp/package are created files:
	//
	//   /tmp/package/v1.0.0.lock (temporary)
	//   /tmp/package/v1.0.0.tmp (temporary)
	//   /tmp/package/v1.0.0.info
	//   /tmp/package/v1.0.0.mod
	//   /tmp/package/v1.0.0.zip
	//
	// For version v2.0.0 and directory /tmp/package are created files:
	//
	//   /tmp/package/v2.0.0.lock (temporary)
	//   /tmp/package/v2.0.0.tmp (temporary)
	//   /tmp/package/v2.0.0.info
	//   /tmp/package/v2.0.0.mod
	//   /tmp/package/v2.0.0.zip
	//
	// Lock file is created first and removed after function is done.
	DownloadModule(ctx context.Context, dir, version string) error

	// ParametrizeDownloads returns new Downloads with specified parameters.
	ParametrizeDownloads(name, mode string, params map[string]any) (Downloads, error)
}

func New

func New(name string, params map[string]any) (Source, error)

type VersionNotFoundError

type VersionNotFoundError struct {
	Err error
}

func NewVersionNotFoundError

func NewVersionNotFoundError(err error) *VersionNotFoundError

func (*VersionNotFoundError) Error

func (v *VersionNotFoundError) Error() string

func (*VersionNotFoundError) Unwrap

func (v *VersionNotFoundError) Unwrap() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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