pkgmgmt

package
v1.0.17 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 12 Imported by: 26

Documentation

Overview

Package pkgmgmt implements the backing package management used by mixins and plugins.

Index

Constants

View Source
const DefaultPackageMirror = "https://cdn.porter.sh"

DefaultPackageMirror is the default location from which to download Porter assets, such as binaries, atom feeds and package indexes.

View Source
const FileExt = ""

Variables

This section is empty.

Functions

func GetDefaultPackageMirrorURL added in v0.37.3

func GetDefaultPackageMirrorURL() url.URL

GetDefaultPackageMirrorURL returns DefaultPackageMirror parsed as a url.URL

func GetPackageListURL

func GetPackageListURL(mirror url.URL, pkgType string) string

GetPackageListURL returns the URL for package listings of the provided type.

Types

type CommandOptions

type CommandOptions struct {
	// Runtime specifies if the client or runtime executable should be targeted.
	Runtime bool

	// Command to pass to the package.
	Command string

	// Input to pipe to stdin.
	Input string

	// File argument to specify as --file.
	File string

	// PreRun allows the caller to tweak the command before it is executed.
	// This is only necessary if being called directly from a runner, if
	// using a PackageManager, this is set for you.
	PreRun PreRunHandler
}

CommandOptions is data necessary to execute a command against a package (mixin or plugin).

type InstallOptions

type InstallOptions struct {
	PackageDownloadOptions

	Name    string
	URL     string
	FeedURL string
	Version string

	PackageType string
	// contains filtered or unexported fields
}

func (*InstallOptions) GetParsedFeedURL

func (o *InstallOptions) GetParsedFeedURL() url.URL

func (*InstallOptions) GetParsedURL

func (o *InstallOptions) GetParsedURL() url.URL

GetParsedURL returns a copy of of the parsed URL that is safe to modify.

func (*InstallOptions) Validate

func (o *InstallOptions) Validate(args []string) error

type Metadata

type Metadata struct {
	// Name of package.
	Name string `json:"name"`
	// VersionInfo for the package.
	VersionInfo
}

Metadata about an installed package.

func (Metadata) GetName

func (m Metadata) GetName() string

GetName of the installed package.

func (Metadata) GetVersionInfo

func (m Metadata) GetVersionInfo() VersionInfo

GetVersionInfo for the installed package.

type PackageDownloadOptions added in v0.37.3

type PackageDownloadOptions struct {
	Mirror string
	// contains filtered or unexported fields
}

PackageDownloadOptions are options for downloading Porter packages, such as mixins and plugins.

func (*PackageDownloadOptions) GetMirror added in v0.37.3

func (o *PackageDownloadOptions) GetMirror() url.URL

GetMirror returns a copy of of the parsed Mirror that is safe to modify.

func (*PackageDownloadOptions) Validate added in v0.37.3

func (o *PackageDownloadOptions) Validate() error

type PackageList

type PackageList []PackageListing

PackageList is a collection of PackageListings

func GetPackageListings

func GetPackageListings(url string) (PackageList, error)

GetPackageListings returns the listings for packages via the provided URL

func (PackageList) Len

func (rml PackageList) Len() int

PackageList implements the sort.Interface for []PackageListing based on the Name field.

func (PackageList) Less

func (rml PackageList) Less(i, j int) bool

func (PackageList) Swap

func (rml PackageList) Swap(i, j int)

type PackageListing

type PackageListing struct {
	Name        string `json:"name"`
	Author      string `json:"author"`
	Description string `json:"description"`
	URL         string `json:"URL"`
}

PackageListing represents discovery information for a package

type PackageManager

type PackageManager interface {
	List() ([]string, error)
	GetPackageDir(name string) (string, error)
	GetMetadata(ctx context.Context, name string) (PackageMetadata, error)
	Install(ctx context.Context, opts InstallOptions) error
	Uninstall(ctx context.Context, opts UninstallOptions) error

	// Run a command against the installed package.
	Run(ctx context.Context, pkgContext *portercontext.Context, name string, commandOpts CommandOptions) error
}

PackageManager handles searching, installing and communicating with packages.

type PackageMetadata

type PackageMetadata interface {
	// GetName of the installed package.
	GetName() string

	// GetVersionInfo for the installed package.
	GetVersionInfo() VersionInfo
}

PackageMetadata is a common interface for packages managed by Porter.

type PreRunHandler

type PreRunHandler func(command string, cmd *exec.Cmd)

type Searcher

type Searcher struct {
	List PackageList
}

Searcher can locate a mixin or plugin from the community feeds.

func NewSearcher

func NewSearcher(list PackageList) Searcher

NewSearcher creates a new Searcher from a package distribution list.

func (*Searcher) Search

func (s *Searcher) Search(name, pkgType string) (PackageList, error)

Search searches for packages matching the optional provided name, returning the full list if none is provided

type UninstallOptions

type UninstallOptions struct {
	Name string
}

func (*UninstallOptions) Validate

func (o *UninstallOptions) Validate(args []string) error

type VersionInfo

type VersionInfo struct {
	Version string `json:"version"`
	Commit  string `json:"commit"`
	Author  string `json:"author,omitempty"`
}

VersionInfo contains metadata from running the version command against the client executable.

Directories

Path Synopsis
Package client provides a package management client for Porter's mixins and plugins.
Package client provides a package management client for Porter's mixins and plugins.
Package feed helps work with a Porter package feed (mixin or plugin).
Package feed helps work with a Porter package feed (mixin or plugin).

Jump to

Keyboard shortcuts

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