pkgmgr

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrContainerAlreadyExists = errors.New("specified container already exists")

ErrContainerAlreadyExists is returned when creating a new container with a name that is already in use

View Source
var ErrContainerNotExists = errors.New("specified container does not exist")

ErrContainerNotExists is returned when querying a container by name that doesn't exist

View Source
var ErrContextAlreadyExists = errors.New("specified context already exists")

ErrContextAlreadyExists is returned when creating a context with a name that is already in use

View Source
var ErrContextInstallNoNetwork = errors.New("no network specified for context")

ErrContextInstallNoNetwork is returned when performing an install with no network specified on the active context

View Source
var ErrContextNoChangeNetwork = errors.New("cannot change the configured network for a context")

ErrContextNoChangeNetwork is returned when updating a context with a network different than what was previously configured

View Source
var ErrContextNoDeleteActive = errors.New("cannot delete active context")

ErrContextNoDeleteActive is returned when attempting to delete the active context

View Source
var ErrContextNotExist = errors.New("context does not exist")

ErrContextNotExist is returned when trying to selecting/managing a context that does not exist

View Source
var ErrMultipleInstallMethods = errors.New("only one install method may be specified in an install step")

ErrMultipleInstallMethods is returned when a package's install steps specify more than one install method on a single install step

View Source
var ErrNoInstallMethods = errors.New("no supported install method specified on install step")

ErrNoInstallMethods is returned when a package's install steps include an install step which has no recognized install method specified

View Source
var ErrNoRegistryConfigured = errors.New("no package registry is configured")

ErrNoRegistryConfigured is returned when no registry is configured

View Source
var ErrOperationFailed = errors.New("the operation has failed")

ErrOperationFailed is a placeholder error for operations that directly log errors. It's used to signify when an operation has failed when the actual error message is sent through the provided logger

View Source
var ErrValidationFailed = errors.New("validation failed")

ErrValidationFailed is returned when loading the package registry while doing package validation when a package failed to load

Functions

func CheckDockerConnectivity

func CheckDockerConnectivity() error

func NewDockerClient

func NewDockerClient() (*client.Client, error)

func NewInstallStepConditionError

func NewInstallStepConditionError(condition string, err error) error

func NewNoPackageAvailableForUpgradeError

func NewNoPackageAvailableForUpgradeError(pkgSpec string) error

func NewNoServicesFoundError

func NewNoServicesFoundError(pkgName string) error

func NewPackageNotInstalledError

func NewPackageNotInstalledError(pkgName string, context string) error

func NewPackageUninstallWouldBreakDepsError

func NewPackageUninstallWouldBreakDepsError(uninstallPkgName string, uninstallPkgVersion string, dependentPkgName string, dependentPkgVersion string) error

func NewResolverInstalledPackageNoMatchVersionSpecError

func NewResolverInstalledPackageNoMatchVersionSpecError(pkgName string, pkgVersion string, depSpec string) error

func NewResolverNoAvailablePackage added in v0.2.0

func NewResolverNoAvailablePackage(pkgSpec string) error

func NewResolverNoAvailablePackageDependencyError

func NewResolverNoAvailablePackageDependencyError(depSpec string) error

func NewResolverPackageAlreadyInstalledError

func NewResolverPackageAlreadyInstalledError(pkgName string) error

func NewUnknownNetworkError

func NewUnknownNetworkError(networkName string) error

func RemoveDockerImage

func RemoveDockerImage(imageName string) error

Types

type Config

type Config struct {
	BinDir              string
	CacheDir            string
	ConfigDir           string
	ContextDir          string
	DataDir             string
	Logger              *slog.Logger
	Template            *Template
	RequiredPackageTags []string
	RegistryUrl         string
	RegistryDir         string
}

func NewDefaultConfig

func NewDefaultConfig() (Config, error)

type Context

type Context struct {
	Description  string `yaml:"description"`
	Network      string `yaml:"network"`
	NetworkMagic uint32 `yaml:"networkMagic"`
}

type DockerService

type DockerService struct {
	ContainerId   string
	ContainerName string
	Image         string
	Env           map[string]string
	Command       []string
	Args          []string
	Binds         []string
	Ports         []string
	// contains filtered or unexported fields
}

func NewDockerServiceFromContainerName

func NewDockerServiceFromContainerName(containerName string, logger *slog.Logger) (*DockerService, error)

func (*DockerService) Create

func (d *DockerService) Create() error

func (*DockerService) Logs

func (d *DockerService) Logs(follow bool, tail string, stdoutWriter io.Writer, stderrWriter io.Writer) error

func (*DockerService) Remove

func (d *DockerService) Remove() error

func (*DockerService) Running

func (d *DockerService) Running() (bool, error)

func (*DockerService) Start

func (d *DockerService) Start() error

func (*DockerService) Stop

func (d *DockerService) Stop() error

type InstalledPackage

type InstalledPackage struct {
	Package          Package
	InstalledTime    time.Time
	Context          string
	PostInstallNotes string
	Options          map[string]bool
	Outputs          map[string]string
}

func NewInstalledPackage

func NewInstalledPackage(pkg Package, context string, postInstallNotes string, outputs map[string]string, options map[string]bool) InstalledPackage

func (InstalledPackage) IsEmpty

func (i InstalledPackage) IsEmpty() bool

type Package

type Package struct {
	Name                string               `yaml:"name,omitempty"`
	Version             string               `yaml:"version,omitempty"`
	Description         string               `yaml:"description,omitempty"`
	InstallSteps        []PackageInstallStep `yaml:"installSteps,omitempty"`
	Dependencies        []string             `yaml:"dependencies,omitempty"`
	Tags                []string             `yaml:"tags,omitempty"`
	PreInstallScript    string               `yaml:"preInstallScript,omitempty"`
	PostInstallScript   string               `yaml:"postInstallScript,omitempty"`
	PreUninstallScript  string               `yaml:"preUninstallScript,omitempty"`
	PostUninstallScript string               `yaml:"postUninstallScript,omitempty"`
	PostInstallNotes    string               `yaml:"postInstallNotes,omitempty"`
	Options             []PackageOption      `yaml:"options,omitempty"`
	Outputs             []PackageOutput      `yaml:"outputs,omitempty"`
	// contains filtered or unexported fields
}

func NewPackageFromFile

func NewPackageFromFile(path string) (Package, error)

func NewPackageFromReader

func NewPackageFromReader(r io.Reader) (Package, error)

func (Package) IsEmpty added in v0.2.0

func (p Package) IsEmpty() bool

type PackageInstallStep

type PackageInstallStep struct {
	Condition string                    `yaml:"condition,omitempty"`
	Docker    *PackageInstallStepDocker `yaml:"docker,omitempty"`
	File      *PackageInstallStepFile   `yaml:"file,omitempty"`
}

type PackageInstallStepDocker

type PackageInstallStepDocker struct {
	ContainerName string            `yaml:"containerName"`
	Image         string            `yaml:"image,omitempty"`
	Env           map[string]string `yaml:"env,omitempty"`
	Command       []string          `yaml:"command,omitempty"`
	Args          []string          `yaml:"args,omitempty"`
	Binds         []string          `yaml:"binds,omitempty"`
	Ports         []string          `yaml:"ports,omitempty"`
	PullOnly      bool              `yaml:"pullOnly"`
}

type PackageInstallStepFile

type PackageInstallStepFile struct {
	Binary   bool        `yaml:"binary"`
	Filename string      `yaml:"filename"`
	Source   string      `yaml:"source"`
	Content  string      `yaml:"content"`
	Mode     fs.FileMode `yaml:"mode,omitempty"`
}

type PackageManager

type PackageManager struct {
	// contains filtered or unexported fields
}

func NewDefaultPackageManager

func NewDefaultPackageManager() (*PackageManager, error)

func NewPackageManager

func NewPackageManager(cfg Config) (*PackageManager, error)

func (*PackageManager) ActiveContext

func (p *PackageManager) ActiveContext() (string, Context)

func (*PackageManager) AddContext

func (p *PackageManager) AddContext(name string, context Context) error

func (*PackageManager) AvailablePackages

func (p *PackageManager) AvailablePackages() []Package

func (*PackageManager) ContextEnv

func (p *PackageManager) ContextEnv() map[string]string

func (*PackageManager) Contexts

func (p *PackageManager) Contexts() map[string]Context

func (*PackageManager) DeleteContext

func (p *PackageManager) DeleteContext(name string) error

func (*PackageManager) Down

func (p *PackageManager) Down() error

func (*PackageManager) Info

func (p *PackageManager) Info(pkgs ...string) error

func (*PackageManager) Install

func (p *PackageManager) Install(pkgs ...string) error

func (*PackageManager) InstalledPackages

func (p *PackageManager) InstalledPackages() []InstalledPackage

func (*PackageManager) InstalledPackagesAllContexts

func (p *PackageManager) InstalledPackagesAllContexts() []InstalledPackage

func (*PackageManager) Logs

func (p *PackageManager) Logs(pkgName string, follow bool, tail string, stdoutWriter io.Writer, stderrWriter io.Writer) error

func (*PackageManager) SetActiveContext

func (p *PackageManager) SetActiveContext(name string) error

func (*PackageManager) Uninstall

func (p *PackageManager) Uninstall(pkgName string, keepData bool, force bool) error

func (*PackageManager) Up

func (p *PackageManager) Up() error

func (*PackageManager) UpdateContext

func (p *PackageManager) UpdateContext(name string, context Context) error

func (*PackageManager) UpdatePackages added in v0.2.0

func (p *PackageManager) UpdatePackages() error

func (*PackageManager) Upgrade

func (p *PackageManager) Upgrade(pkgs ...string) error

func (*PackageManager) ValidatePackages added in v0.2.0

func (p *PackageManager) ValidatePackages() error

type PackageOption

type PackageOption struct {
	Name        string `yaml:"name"`
	Description string `yaml:"description"`
	Default     bool   `yaml:"default"`
}

type PackageOutput

type PackageOutput struct {
	Name        string `yaml:"name"`
	Description string `yaml:"description"`
	Value       string `yaml:"value"`
}

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

func NewResolver

func NewResolver(installedPkgs []InstalledPackage, availablePkgs []Package, context string, logger *slog.Logger) (*Resolver, error)

func (*Resolver) Install

func (r *Resolver) Install(pkgs ...string) ([]ResolverInstallSet, error)

func (*Resolver) Uninstall

func (r *Resolver) Uninstall(pkgs ...InstalledPackage) error

func (*Resolver) Upgrade

func (r *Resolver) Upgrade(pkgs ...string) ([]ResolverUpgradeSet, error)

type ResolverInstallSet

type ResolverInstallSet struct {
	Install  Package
	Options  map[string]bool
	Selected bool
}

type ResolverUpgradeSet

type ResolverUpgradeSet struct {
	Installed InstalledPackage
	Upgrade   Package
	Options   map[string]bool
}

type State

type State struct {
	ActiveContext     string
	Contexts          map[string]Context
	InstalledPackages []InstalledPackage
	// contains filtered or unexported fields
}

func NewState

func NewState(cfg Config) *State

func (*State) Load

func (s *State) Load() error

func (*State) Save

func (s *State) Save() error

type Template

type Template struct {
	// contains filtered or unexported fields
}

func NewTemplate

func NewTemplate(baseVars map[string]any) *Template

func (*Template) EvaluateCondition

func (t *Template) EvaluateCondition(condition string, extraVars map[string]any) (bool, error)

func (*Template) Render

func (t *Template) Render(tmplBody string, extraVars map[string]any) (string, error)

func (*Template) WithVars

func (t *Template) WithVars(extraVars map[string]any) *Template

WithVars creates a copy of the Template with the extra variables added to the original base variables

Jump to

Keyboard shortcuts

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