Documentation
¶
Index ¶
- Constants
- Variables
- func DefaultGetter(ctx context.Context, src, dst string) error
- func MovePackage(pkg *Package, newPath string) error
- func PackagePath(root string, name string) (string, error)
- func RemovePackage(pkg *Package) error
- func StorePackage(pkg *Package) error
- type CleanupFunc
- type CopyFileGetter
- type Getter
- type MetadataTypeCastError
- type MockGetter
- type NotFoundError
- type Package
- func (p *Package) All() ([]*Package, error)
- func (p *Package) Children() ([]*Package, error)
- func (p *Package) Description() string
- func (p *Package) MetaFile() string
- func (p *Package) MetaPath() string
- func (p *Package) MetadataLookup(key string) any
- func (p *Package) MetadataMapSlice(key string) []map[string]any
- func (p *Package) MetadataSlice(key string) []any
- func (p *Package) MetadataString(key string) string
- func (p *Package) Name() string
- func (p *Package) Origin() string
- func (p *Package) Parent() *Package
- func (p *Package) Path() string
- func (p *Package) Root() *Package
- func (p *Package) SetDescription(value string)
- func (p *Package) SetName(value string)
- func (p *Package) SetOrigin(value string)
- func (p *Package) SetPath(value string)
- func (p *Package) ShortDescription() string
- type Store
- func (s *Store) Install(src string) (*Package, error)
- func (s *Store) Load(name string) (*Package, error)
- func (s *Store) LoadAll() ([]*Package, error)
- func (s *Store) Stage(src string) (*Package, CleanupFunc, error)
- func (s *Store) Uninstall(name string) (*Package, error)
- func (s *Store) Update(name string) (*Package, error)
- func (s *Store) WithGetter(g Getter) *Store
- func (s *Store) WithMetaFile(filename string) *Store
Constants ¶
const (
DefaultMetaFile string = "package.yaml"
)
Variables ¶
Functions ¶
func DefaultGetter ¶
DefaultGetter uses hashicorp/go-getter to copy packages.
func MovePackage ¶
MovePackage moves the package to the given path.
func PackagePath ¶
PackagePath returns the absolute path to a package. Returns an error if `name` is empty or invalid. For example:
// "/packages/some/nested/name" PackagePath("/packages", "some:nested:name")
func RemovePackage ¶
RemovePackage deletes the package from the filesystem.
func StorePackage ¶
StorePackage updates the package metadata file.
Types ¶
type CleanupFunc ¶
type CleanupFunc func()
type CopyFileGetter ¶
type CopyFileGetter struct {
getter.FileGetter
}
CopyFileGetter is a wrapper around the default getter.FileGetter that copies local files and directories rather than symlinking. The default getter has a `Copy` flag that is _supposed_ to allow for this, but it's only respected when getting individual files (not directories).
func NewCopyFileGetter ¶
func NewCopyFileGetter() *CopyFileGetter
type MetadataTypeCastError ¶
type MetadataTypeCastError struct {
// contains filtered or unexported fields
}
func NewMetadataTypeCastError ¶
func NewMetadataTypeCastError(key string, value any, expectedType string) MetadataTypeCastError
func (MetadataTypeCastError) Error ¶
func (e MetadataTypeCastError) Error() string
type MockGetter ¶
type MockGetter struct { Called bool Ctx context.Context //nolint:containedctx Src string Dst string // contains filtered or unexported fields }
MockGetter delegates to the supplied handler function.
func NewMockGetter ¶
func NewMockGetter(handler Getter) *MockGetter
NewMockGetter returns a new MockGetter struct.
type NotFoundError ¶
type NotFoundError struct {
// contains filtered or unexported fields
}
func NewNotFoundError ¶
func NewNotFoundError(metaFile string) NotFoundError
func (NotFoundError) Error ¶
func (e NotFoundError) Error() string
type Package ¶
func LoadPackage ¶
LoadPackage parses and returns the package at `pkgPath`.
func LoadPackages ¶
LoadPackages returns all valid packages found in `root`. Includes nested sub-packages.
func (*Package) Description ¶ added in v0.4.4
Description returns the description of the package.
func (*Package) MetadataLookup ¶
MetadataLookup returns the value for key in Metadata. If not found, then tries the pascalized version of key.
func (*Package) MetadataMapSlice ¶
MetadataMapSlice returns a slice of maps for the given metadata key.
func (*Package) MetadataSlice ¶
MetadataSlice returns a slice value for the given metadata key.
func (*Package) MetadataString ¶
MetadataString returns a string value for the given metadata key.
func (*Package) Name ¶
Name of the package. Must match the filesystem path (relative to the store) of the package with separators replaced with `:`. For example:
"/package/foo/bar/baz" => "foo:bar:baz"
func (*Package) SetDescription ¶ added in v0.4.4
SetName sets the package description.
func (*Package) ShortDescription ¶ added in v0.6.0
ShortDescription returns the first line of the description.
type Store ¶
func (*Store) LoadAll ¶
Returns all valid packages in the store. Silently ignores any packages that fail to load.
func (*Store) WithGetter ¶
WithGetter returns the receiver with getter set to g.
func (*Store) WithMetaFile ¶
WithMetaFile returns the receiver with MetaFile set to filename.