registry

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: AGPL-3.0 Imports: 21 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	CodeRegistryUnavailable = "REGISTRY_UNAVAILABLE"
	CodeSignatureInvalid    = "SIGNATURE_INVALID"
	CodeIncompatibleEngine  = "INCOMPATIBLE_ENGINE"
	CodeUnsupportedPlatform = "UNSUPPORTED_PLATFORM"
	CodeChecksumMismatch    = "CHECKSUM_MISMATCH"
	CodeUnsafeArchive       = "UNSAFE_ARCHIVE"
	CodeConfigMismatch      = "CONFIG_MISMATCH"
	CodeHealthFailed        = "PLUGIN_HEALTH_FAILED"
	CodeRollbackCompleted   = "ROLLBACK_COMPLETED"
	CodeNotFound            = "PLUGIN_NOT_FOUND"
	CodeNotInstallable      = "PLUGIN_NOT_INSTALLABLE"
	CodeInUse               = "PLUGIN_IN_USE"
	CodeRegistryDisabled    = "REGISTRY_DISABLED"
	CodeDownloadFailed      = "DOWNLOAD_FAILED"
	CodeSizeMismatch        = "SIZE_MISMATCH"
	CodeHostNotAllowed      = "HOST_NOT_ALLOWED"
	CodeLocalUploadDisabled = "LOCAL_UPLOAD_DISABLED"
	CodeForbidden           = "FORBIDDEN"
)

Coded errors returned to Console/CLI. Stable strings; do not reword codes.

View Source
const EmbeddedApitoCatalogPublicKeyHex = "ffaacff457ed3c882ad3e947b4e74f646fe8b1f382f21155abde26088e4a7e0b"

EmbeddedApitoCatalogPublicKeyHex is the Apito catalog Ed25519 public key. Override with PLUGIN_REGISTRY_PUBLIC_KEY. Private key is a GitHub Actions secret.

Variables

View Source
var AllowLocalhostDownloads bool

AllowLocalhostDownloads is for tests (httptest.Server).

Functions

func CompatibleEngine

func CompatibleEngine(engineVersion, rangeExpr string) bool

CompatibleEngine reports whether engineVersion satisfies a simple range. Supported: "*", ">=x.y.z", ">x.y.z", "<=x.y.z", "<x.y.z", "=x.y.z", "x.y.z".

func DigestSHA256

func DigestSHA256(b []byte) string

DigestSHA256 returns lowercase hex SHA-256.

func DownloadVerified

func DownloadVerified(ctx context.Context, client *http.Client, rawURL string, expectedSize int64, expectedSHA string, destPath string, maxBytes int64) error

DownloadVerified fetches url, enforces host/size/sha256, writes destPath.

func ParsePublicKey

func ParsePublicKey(hexKey string) (ed25519.PublicKey, error)

ParsePublicKey decodes a 32-byte Ed25519 public key from hex.

func SafeExtractZip

func SafeExtractZip(zipPath, dest string, expectedBinary string, maxUncompressed int64) error

SafeExtractZip extracts a zip into dest. Only root-level regular files. Rejects zip-slip, symlinks, absolute paths, nested dirs, and duplicate names.

func SignCatalog

func SignCatalog(catalogJSON []byte, priv ed25519.PrivateKey) []byte

SignCatalog is used by tests and the registry generate tool.

func VerifyCatalogSignature

func VerifyCatalogSignature(catalogJSON, sig []byte, pub ed25519.PublicKey) error

VerifyCatalogSignature checks Ed25519 over the exact catalog bytes.

func VersionNewer

func VersionNewer(a, b string) bool

VersionNewer reports whether a is semver-greater than b.

Types

type ApprovalMeta

type ApprovalMeta struct {
	ReviewedBy string `json:"reviewed_by,omitempty"`
	ReviewedAt string `json:"reviewed_at,omitempty"`
}

ApprovalMeta is reviewer provenance.

type Catalog

type Catalog struct {
	SchemaVersion int            `json:"schema_version"`
	GeneratedAt   string         `json:"generated_at"`
	Plugins       []CatalogEntry `json:"plugins"`
}

Catalog is the signed registry document.

func ParseCatalogJSON

func ParseCatalogJSON(b []byte) (*Catalog, error)

ParseCatalogJSON decodes and lightly validates schema_version.

func (*Catalog) Find

func (cat *Catalog) Find(id string) *CatalogEntry

Find returns a plugin by id.

type CatalogEntry

type CatalogEntry struct {
	ID              string                `json:"id"`
	Name            string                `json:"name"`
	Publisher       string                `json:"publisher"`
	Repository      string                `json:"repository"`
	License         string                `json:"license"`
	Description     string                `json:"description"`
	LongDescription string                `json:"long_description,omitempty"`
	Icon            string                `json:"icon,omitempty"`
	Tags            []string              `json:"tags,omitempty"`
	Category        string                `json:"category"`
	Language        string                `json:"language"`
	Capabilities    []string              `json:"capabilities"`
	EngineSemver    string                `json:"engine_semver"`
	PluginVersion   string                `json:"plugin_version"`
	Trust           string                `json:"trust"`  // official | community
	Status          string                `json:"status"` // available | deprecated | blocked | catalog-stub
	Documentation   string                `json:"documentation_url,omitempty"`
	Runtime         RuntimeContract       `json:"runtime"`
	Releases        []ReleaseAsset        `json:"releases"`
	Approval        *ApprovalMeta         `json:"approval,omitempty"`
	Contributions   *plugin.Contributions `json:"contributions,omitempty"`
}

CatalogEntry is one reviewed plugin.

func (*CatalogEntry) SelectRelease

func (e *CatalogEntry) SelectRelease(goos, goarch string) *ReleaseAsset

SelectRelease picks GOOS/GOARCH from the entry.

type Client

type Client struct {
	URL        string
	SigURL     string
	PublicKey  ed25519.PublicKey
	HTTP       *http.Client
	CacheDir   string
	StaleAfter time.Duration
	// contains filtered or unexported fields
}

Client fetches and caches the signed catalog.

func (*Client) Get

func (c *Client) Get(ctx context.Context) (*Catalog, string, error)

Get returns the verified catalog, using ETag cache and bounded stale fallback.

type Error

type Error struct {
	Code    string
	Message string
	Cause   error
}

Error is a typed installer/catalog failure.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type Handshake

type Handshake struct {
	ProtocolVersion  int32  `json:"protocol_version"`
	MagicCookieKey   string `json:"magic_cookie_key"`
	MagicCookieValue string `json:"magic_cookie_value"`
}

Handshake is the HashiCorp cookie pair.

type InstallRecord

type InstallRecord struct {
	ID              string    `json:"id"`
	Version         string    `json:"version"`
	CatalogDigest   string    `json:"catalog_digest"`
	ArtifactSHA256  string    `json:"artifact_sha256"`
	OS              string    `json:"os"`
	Arch            string    `json:"arch"`
	Actor           string    `json:"actor"`
	InstalledAt     time.Time `json:"installed_at"`
	State           string    `json:"state"` // installed | rolled_back | uninstalled
	PreviousVersion string    `json:"previous_version,omitempty"`
	SourceURL       string    `json:"source_url,omitempty"`
}

InstallRecord is persisted next to the plugin directory.

func ReadInstallRecord

func ReadInstallRecord(pluginPath, id string) (*InstallRecord, error)

ReadInstallRecord loads the persisted install record, if any.

type InstalledInfo

type InstalledInfo struct {
	Version string
	Health  string
}

InstalledInfo is local host state for a plugin id.

type Installer

type Installer struct {
	PluginPath    string
	EngineVersion string
	Client        *Client
	HTTP          *http.Client
	MaxBytes      int64
	GOOS          string
	GOARCH        string

	HotLoad func(id string) error
	Stop    func(id string) error
	// ActiveProjects returns project IDs that still have this plugin enabled.
	ActiveProjects func(ctx context.Context, pluginID string) ([]string, error)
}

Installer performs verified install/update/uninstall/rollback.

func (*Installer) Install

func (in *Installer) Install(ctx context.Context, id, version, actor string) (*InstallRecord, error)

Install downloads and atomically promotes a catalog plugin.

func (*Installer) Rollback

func (in *Installer) Rollback(ctx context.Context, id string) error

Rollback restores .previous/<id> if present.

func (*Installer) Uninstall

func (in *Installer) Uninstall(ctx context.Context, id string, force bool) error

Uninstall removes a plugin. force skips in-use protection.

func (*Installer) Update

func (in *Installer) Update(ctx context.Context, id, actor string) (*InstallRecord, error)

Update installs the currently approved catalog version.

type MergedPlugin

type MergedPlugin struct {
	CatalogEntry
	Installed         bool   `json:"installed"`
	InstalledVersion  string `json:"installed_version,omitempty"`
	Health            string `json:"health,omitempty"`
	UpdateAvailable   bool   `json:"update_available"`
	Compatible        bool   `json:"compatible"`
	PlatformSupported bool   `json:"platform_supported"`
	BlockedReason     string `json:"blocked_reason,omitempty"`
}

MergedPlugin is catalog + local install/health.

func Merge

func Merge(cat *Catalog, installed map[string]InstalledInfo, engineVer, goos, goarch string) []MergedPlugin

Merge overlays signed catalog metadata with local install/health.

type ReleaseAsset

type ReleaseAsset struct {
	OS     string `json:"os"`
	Arch   string `json:"arch"`
	URL    string `json:"url"`
	Size   int64  `json:"size"`
	SHA256 string `json:"sha256"`
}

ReleaseAsset is one immutable GitHub Release zip.

type RuntimeContract

type RuntimeContract struct {
	ID           string    `json:"id"`
	Version      string    `json:"version"`
	BinaryPath   string    `json:"binary_path"`
	Capabilities []string  `json:"capabilities"`
	Handshake    Handshake `json:"handshake"`
}

RuntimeContract must match repository config.yml.

Jump to

Keyboard shortcuts

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