Help us shape the future of Go! Take the 2026 Go Developer Survey

pkg

package
v0.31.1 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Overview

Package pkg provides interfaces to interact with the package system used for plugins and scrapers.

Package http provides a repository implementation for HTTP.

Index

Constants

View Source
const ManifestFile = "manifest"

ManifestFile is the default filename for the package manifest.

View Source
const (
	// TimeFormat is the format used for marshalling/unmarshalling time.Time.
	// Times are stored in UTC.
	TimeFormat = "2006-01-02 15:04:05"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type LocalPackageIndex

type LocalPackageIndex map[models.PackageSpecInput]Manifest

LocalPackageIndex is a map of package name to RemotePackage

type Manager

type Manager struct {
	Local             *Store
	PackagePathGetter SourcePathGetter

	Client *http.Client
	// contains filtered or unexported fields
}

Manager manages the installation of paks.

func (*Manager) Install

func (m *Manager) Install(ctx context.Context, spec models.PackageSpecInput) error

func (*Manager) InstalledStatus

func (m *Manager) InstalledStatus(ctx context.Context) (PackageStatusIndex, error)

func (*Manager) ListInstalled

func (m *Manager) ListInstalled(ctx context.Context) (LocalPackageIndex, error)

func (*Manager) ListInstalledRemotes

func (m *Manager) ListInstalledRemotes(ctx context.Context, installed LocalPackageIndex) (RemotePackageIndex, error)

func (*Manager) ListRemote

func (m *Manager) ListRemote(ctx context.Context, remoteURL string) (RemotePackageIndex, error)

func (*Manager) Uninstall

func (m *Manager) Uninstall(ctx context.Context, spec models.PackageSpecInput) error

Uninstall uninstalls the given package.

type Manifest

type Manifest struct {
	ID             string          `yaml:"id"`
	Name           string          `yaml:"name"`
	Metadata       PackageMetadata `yaml:"metadata"`
	PackageVersion `yaml:",inline"`
	Requires       []string `yaml:"requires"`

	RepositoryURL string   `yaml:"source_repository"`
	Files         []string `yaml:"files"`
}

func (Manifest) PackageSpecInput

func (m Manifest) PackageSpecInput() models.PackageSpecInput

type PackageLocation

type PackageLocation struct {
	// Path is the path to the package zip file.
	// This may be relative or absolute.
	Path   string `yaml:"path"`
	Sha256 string `yaml:"sha256"`
}

type PackageMetadata

type PackageMetadata map[string]interface{}

type PackageStatus

type PackageStatus struct {
	Local  *Manifest
	Remote *RemotePackage
}

func (PackageStatus) Upgradable

func (s PackageStatus) Upgradable() bool

type PackageStatusIndex

type PackageStatusIndex map[models.PackageSpecInput]PackageStatus

func MakePackageStatusIndex

func MakePackageStatusIndex(installed LocalPackageIndex, remote RemotePackageIndex) PackageStatusIndex

func (PackageStatusIndex) Upgradable

func (i PackageStatusIndex) Upgradable() []PackageStatus

type PackageVersion

type PackageVersion struct {
	Version string `yaml:"version"`
	Date    Time   `yaml:"date"`
}

func (PackageVersion) String

func (v PackageVersion) String() string

func (PackageVersion) Upgradable

func (v PackageVersion) Upgradable(o PackageVersion) bool

type RemotePackage

type RemotePackage struct {
	ID              string           `yaml:"id"`
	Name            string           `yaml:"name"`
	Repository      remoteRepository `yaml:"-"`
	Requires        []string         `yaml:"requires"`
	Metadata        PackageMetadata  `yaml:"metadata"`
	PackageVersion  `yaml:",inline"`
	PackageLocation `yaml:",inline"`
}

func (RemotePackage) PackageSpecInput

func (p RemotePackage) PackageSpecInput() models.PackageSpecInput

type RemotePackageGetter

type RemotePackageGetter interface {
	GetPackageZip(ctx context.Context, pkg RemotePackage) (io.ReadCloser, error)
}

type RemotePackageIndex

type RemotePackageIndex map[models.PackageSpecInput]RemotePackage

RemotePackageIndex is a map of package name to RemotePackage

type RemotePackageLister

type RemotePackageLister interface {
	// List returns all specs in the repository.
	List(ctx context.Context) ([]RemotePackage, error)
}

type SourcePathGetter

type SourcePathGetter interface {
	// GetAllSourcePaths gets all source paths.
	GetAllSourcePaths() []string

	// GetSourcePath gets the source path for the given package URL.
	GetSourcePath(srcURL string) string
}

SourcePathGetter gets the source path for a given package URL.

type Store

type Store struct {
	BaseDir string
	// ManifestFile is the filename of the package file.
	ManifestFile string
}

Store is a folder-based local repository. Packages are installed in their own directory under BaseDir. The package details are stored in a file named based on PackageFile.

func (*Store) List

func (r *Store) List(ctx context.Context) ([]Manifest, error)

type Time

type Time struct {
	time.Time
}

Time is a wrapper around time.Time that allows for custom YAML marshalling/unmarshalling using TimeFormat.

func (Time) MarshalYAML

func (t Time) MarshalYAML() (interface{}, error)

func (*Time) UnmarshalYAML

func (t *Time) UnmarshalYAML(unmarshal func(interface{}) error) error

Jump to

Keyboard shortcuts

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