pkg

package module
v0.0.0-...-11aa17c Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2026 License: ISC Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const PLUGIN_API_VERSION = "v1.0.0"

Variables

View Source
var (
	ErrInvalidOptions        = errors.New("invalid options")
	ErrAlreadyInstalled      = errors.New("already installed")
	ErrAuthorizationRequired = errors.New("authorization required")
)
View Source
var (
	ErrBadPackageName = errors.New("invalid package name")
)

Functions

func Build

func Build(*BuildOptions) error

func WithBearer

func WithBearer(fn func() (string, error)) func(*http.Request) error

WithBearer adds an Authorization header with the Bearer token returned by the given callback. It's meant to be passed as [Options.RequestHook]. If it yields an empty token, the header will not be added.

Types

type AddOptions

type AddOptions struct {
	// The version to install, if given.  Otherwise, the latest
	// version available will be used.
	Version string

	// If exists a older version of the plugin, remove it prior
	// to install this version.
	Upgrade bool

	// If exists a newer version of the plugin, remove it prior
	// to install this version.
	Downgrade bool

	// Remove other version of the plugin, even if it's the same,
	// and install this version.
	Replace bool

	// Don't fail if other versions of the same plugin exist.
	AllowMultipleVersions bool

	// If target does not point at a .ptar file, attempt to fetch
	// the pre-packaged plugin from the repository.
	ImplicitFetch bool
}

type Backend

type Backend interface {
	// List returns an iterator of plugin names,
	// e.g. s3_v1.0.0_openbsd_amd64.ptar, optionally filtered by
	// the given name, or an error.
	List(name string) iter.Seq2[*Package, error]

	// Load a plugin' ptar from the given reader.
	Load(*Package, io.Reader) error

	// Unload a plugin
	Unload(*Package) error
}

type BuildOptions

type BuildOptions struct{}

type CreateOptions

type CreateOptions struct{}

type DelOptions

type DelOptions struct {
	// If target is the empty string, delete all the packages
	// installed.
	All bool
}

type FlatBackend

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

A backend that stores integrations in a single, flat, directory.

func NewFlatBackend

func NewFlatBackend(kctx *kcontext.KContext, pkgdir, cachedir string, opts *FlatBackendOptions) (*FlatBackend, error)

func (*FlatBackend) List

func (f *FlatBackend) List(name string) iter.Seq2[*Package, error]

func (*FlatBackend) Load

func (f *FlatBackend) Load(pkg *Package, rd io.Reader) error

func (*FlatBackend) LoadAll

func (f *FlatBackend) LoadAll() error

func (*FlatBackend) Unload

func (f *FlatBackend) Unload(pkg *Package) error

type FlatBackendOptions

type FlatBackendOptions struct {
	PreLoadHook func(*Manifest) error
	LoadHook    func(*Manifest, *Package, string)
	UnloadHook  func(*Manifest, *Package)
}

type Integration

type Integration struct {
	Id            string           `json:"id"`
	Name          string           `json:"name"`
	DisplayName   string           `json:"display_name"`
	Description   string           `json:"description"`
	Homepage      string           `json:"homepage"`
	Repository    string           `json:"repository"`
	License       string           `json:"license"`
	Tags          []string         `json:"tags"`
	APIVersion    string           `json:"api_version"`
	LatestVersion string           `json:"latest_version"`
	Stage         string           `json:"stage"`
	Types         IntegrationTypes `json:"types"`

	Documentation string `json:"documentation"` // README.md
	Icon          string `json:"icon"`          // assets/icon.{png,svg}
	Featured      string `json:"featured"`      // assets/featured.{png,svg}

	Installation IntegrationInstallation `json:"installation"`
}

type IntegrationIndex

type IntegrationIndex struct {
	Plugins []Integration `json:"integrations"`
}

type IntegrationInstallation

type IntegrationInstallation struct {
	Status    string `json:"status"`
	Version   string `json:"version,omitempty"`
	Available bool   `json:"available"`
}

type IntegrationTypes

type IntegrationTypes struct {
	Storage     bool `json:"storage"`
	Source      bool `json:"source"`
	Destination bool `json:"destination"`
	Provider    bool `json:"provider"`
}

type Manager

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

func New

func New(store Backend, opts *Options) (*Manager, error)

New creates a new package manager.

func (*Manager) Add

func (p *Manager) Add(target string, opts *AddOptions) error

Add installs a package. By default, it will fail if another version of the same plugin is already present.

func (*Manager) Create

func (p *Manager) Create(manifest *Manifest, opts *CreateOptions) error

func (*Manager) Del

func (p *Manager) Del(target string, opts *DelOptions) error

Del uninstalls all matching packages.

func (*Manager) List

func (p *Manager) List() iter.Seq2[*Package, error]

List lists all the installed packages.

func (*Manager) Query

func (p *Manager) Query() iter.Seq2[*Integration, error]

type Manifest

type Manifest struct {
	Name        string   `yaml:"name"`
	DisplayName string   `yaml:"display_name"`
	Description string   `yaml:"description"`
	Homepage    string   `yaml:"homepage"`
	License     string   `yaml:"license"`
	Tags        []string `yaml:"tags"`
	APIVersion  string   `yaml:"api_version"`

	Connectors []ManifestConnector `yaml:"connectors"`
}

func (*Manifest) Parse

func (m *Manifest) Parse(rd io.Reader) error

type ManifestConnector

type ManifestConnector struct {
	Type          string   `yaml:"type"`
	Protocols     []string `yaml:"protocols"`
	LocationFlags []string `yaml:"location_flags"`
	Executable    string   `yaml:"executable"`
	Args          []string `yaml:"args"`
	ExtraFiles    []string `yaml:"extra_files"`
}

func (*ManifestConnector) Flags

func (conn *ManifestConnector) Flags() (flags location.Flags, err error)

type Options

type Options struct {
	InstallURL      string
	ApiURL          string
	BinaryNeedsAuth bool
	RequestHook     RequestHook

	// User agent name for network requests on the repository at
	// InstallURL.  "(os/architecture)" will be appended
	// implicitly.
	UserAgent string
}

type Package

type Package struct {
	Name            string
	Version         string
	Architecture    string
	OperatingSystem string
}

func (*Package) Filename

func (p *Package) Filename() string

func (*Package) Validate

func (pkg *Package) Validate() error

type Recipe

type Recipe struct {
	Name       string `yaml:"name"`
	Version    string `yaml:"version"`
	Repository string `yaml:"repository"`
}

func (*Recipe) Parse

func (recipe *Recipe) Parse(rd io.Reader) error

func (*Recipe) PkgName

func (recipe *Recipe) PkgName() string

xxx unused

type RequestHook

type RequestHook func(*http.Request) error

Jump to

Keyboard shortcuts

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