pkgmgmt

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2020 License: Apache-2.0 Imports: 10 Imported by: 28

Documentation

Overview

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

Index

Constants

View Source
const FileExt = ""

Variables

This section is empty.

Functions

func GetPackageListURL

func GetPackageListURL(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 {
	Name    string
	URL     string
	FeedURL string
	Version string

	DefaultFeedURL 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 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(name string) (PackageMetadata, error)
	Install(InstallOptions) error
	Uninstall(UninstallOptions) error

	// Run a command against the installed package.
	Run(pkgContext *context.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 contains a packr.Box containing a searchable list of packages

func NewSearcher

func NewSearcher(list PackageList) Searcher

NewSearcher returns a Searcher with the provided packr.Box

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