client

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: 22 Imported by: 0

Documentation

Overview

Package client provides a package management client for Porter's mixins and plugins.

Index

Constants

View Source
const PackageCacheJSON string = "cache.json"

Variables

This section is empty.

Functions

This section is empty.

Types

type FileSystem

type FileSystem struct {
	*config.Config

	// PackageType is the type of package managed by this instance of the
	// package manager. It must also correspond to the directory name in
	// PORTER_HOME.
	PackageType string

	// PreRun is executed before commands are run against a package, giving
	// consumers a chance to tweak the command first.
	PreRun pkgmgmt.PreRunHandler

	// BuildMetadata allows mixins/plugins to supply the proper struct that
	// represents its package metadata.
	BuildMetadata PackageMetadataBuilder
}

func NewFileSystem

func NewFileSystem(config *config.Config, pkgType string) *FileSystem

func (*FileSystem) BuildClientPath

func (fs *FileSystem) BuildClientPath(pkgDir string, name string) string

func (*FileSystem) GetMetadata

func (fs *FileSystem) GetMetadata(ctx context.Context, name string) (pkgmgmt.PackageMetadata, error)

func (*FileSystem) GetPackageDir

func (fs *FileSystem) GetPackageDir(name string) (string, error)

func (*FileSystem) GetPackagesDir

func (fs *FileSystem) GetPackagesDir() (string, error)

func (*FileSystem) Install

func (fs *FileSystem) Install(ctx context.Context, opts pkgmgmt.InstallOptions) error

func (*FileSystem) InstallFromFeedURL

func (fs *FileSystem) InstallFromFeedURL(ctx context.Context, opts pkgmgmt.InstallOptions) error

func (*FileSystem) InstallFromURL

func (fs *FileSystem) InstallFromURL(ctx context.Context, opts pkgmgmt.InstallOptions) error

func (*FileSystem) List

func (fs *FileSystem) List() ([]string, error)

func (*FileSystem) Run

func (fs *FileSystem) Run(ctx context.Context, pkgContext *portercontext.Context, name string, commandOpts pkgmgmt.CommandOptions) error

func (*FileSystem) Uninstall

func (fs *FileSystem) Uninstall(ctx context.Context, opts pkgmgmt.UninstallOptions) error

type PackageInfo

type PackageInfo struct {
	Name    string `json:"name"`
	FeedURL string `json:"URL,omitempty"`
	URL     string `json:"url,omitempty"`
}

type PackageMetadataBuilder

type PackageMetadataBuilder func() pkgmgmt.PackageMetadata

type Runner

type Runner struct {
	*portercontext.Context
	// contains filtered or unexported fields
}

func NewRunner

func NewRunner(pkgName, pkgDir string, runtime bool) *Runner

func (*Runner) Run

func (r *Runner) Run(ctx context.Context, commandOpts pkgmgmt.CommandOptions) error

func (*Runner) Validate

func (r *Runner) Validate() error

type TestPackageManager

type TestPackageManager struct {
	PkgType           string
	Packages          []pkgmgmt.PackageMetadata
	RunAssertions     []func(pkgContext *portercontext.Context, name string, commandOpts pkgmgmt.CommandOptions) error
	InstallAssertions []func(installOpts pkgmgmt.InstallOptions) error
	// contains filtered or unexported fields
}

TestPackageManager helps us test mixins/plugins in our unit tests without actually hitting any real executables on the file system.

func (*TestPackageManager) GetCalled added in v1.0.1

func (p *TestPackageManager) GetCalled(mixin string) int

GetCalled tracks how many times each package was called

func (*TestPackageManager) GetMetadata

func (p *TestPackageManager) GetMetadata(ctx context.Context, name string) (pkgmgmt.PackageMetadata, error)

func (*TestPackageManager) GetPackageDir

func (p *TestPackageManager) GetPackageDir(name string) (string, error)

func (*TestPackageManager) Install

func (*TestPackageManager) List

func (p *TestPackageManager) List() ([]string, error)

func (*TestPackageManager) Run

func (p *TestPackageManager) Run(ctx context.Context, pkgContext *portercontext.Context, name string, commandOpts pkgmgmt.CommandOptions) error

func (*TestPackageManager) Uninstall

type TestRunner

type TestRunner struct {
	*Runner
	TestContext *portercontext.TestContext
}

func NewTestRunner

func NewTestRunner(t *testing.T, name string, pkgType string, runtime bool) *TestRunner

NewTestRunner initializes a test runner, with the output buffered, and an in-memory file system.

Jump to

Keyboard shortcuts

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