Documentation
¶
Index ¶
- Constants
- Variables
- func CompatibleEngine(engineVersion, rangeExpr string) bool
- func DigestSHA256(b []byte) string
- func DownloadVerified(ctx context.Context, client *http.Client, rawURL string, expectedSize int64, ...) error
- func ParsePublicKey(hexKey string) (ed25519.PublicKey, error)
- func SafeExtractZip(zipPath, dest string, expectedBinary string, maxUncompressed int64) error
- func SignCatalog(catalogJSON []byte, priv ed25519.PrivateKey) []byte
- func VerifyCatalogSignature(catalogJSON, sig []byte, pub ed25519.PublicKey) error
- func VersionNewer(a, b string) bool
- type ApprovalMeta
- type Catalog
- type CatalogEntry
- type Client
- type Error
- type Handshake
- type InstallRecord
- type InstalledInfo
- type Installer
- func (in *Installer) Install(ctx context.Context, id, version, actor string) (*InstallRecord, error)
- func (in *Installer) Rollback(ctx context.Context, id string) error
- func (in *Installer) Uninstall(ctx context.Context, id string, force bool) error
- func (in *Installer) Update(ctx context.Context, id, actor string) (*InstallRecord, error)
- type MergedPlugin
- type ReleaseAsset
- type RuntimeContract
Constants ¶
const ( 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.
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 ¶
var AllowLocalhostDownloads bool
AllowLocalhostDownloads is for tests (httptest.Server).
Functions ¶
func CompatibleEngine ¶
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 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 ¶
ParsePublicKey decodes a 32-byte Ed25519 public key from hex.
func SafeExtractZip ¶
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 ¶
VerifyCatalogSignature checks Ed25519 over the exact catalog bytes.
func VersionNewer ¶
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 ¶
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.
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 ¶
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.
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.