plugin

package
v1.8.25 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package plugin provides functionality for loading and managing HashiCorp plugins from individual config.yml files in plugin directories.

Index

Constants

View Source
const (
	CapSystemGraphQL   = "system.graphql"
	CapSystemREST      = "system.rest"
	CapProjectGraphQL  = "project.graphql"
	CapProjectREST     = "project.rest"
	CapConsoleRoutes   = "console.routes"
	CapConsoleSettings = "console.settings"
	CapContentFields   = "content.fields"
	CapEventSink       = "system.events"
)

Capability identifiers declared by a system-installed plugin.

Variables

This section is empty.

Functions

func CapabilitiesFor added in v1.8.21

func CapabilitiesFor(id string) []string

CapabilitiesFor returns declared capabilities for a plugin id.

func CapabilitiesFromLegacyType added in v1.8.21

func CapabilitiesFromLegacyType(pluginType string) ([]string, error)

CapabilitiesFromLegacyType maps retired YAML `type:` to capabilities. `project` is accepted only as a migration shim.

func ConvertEnvVariablesFromProto

func ConvertEnvVariablesFromProto(protoEnvVars []*protobuff.EnvVariable) []*protobuff.EnvVariable

ConvertEnvVariablesFromProto converts protobuf environment variables to extensions environment variables

func ConvertGraphQLSchemaToProto

func ConvertGraphQLSchemaToProto(schema *protobuff.ThirdPartyGraphQLSchemas) (*protobuff.ThirdPartyGraphQLSchemas, error)

ConvertGraphQLSchemaToProto converts protobuf GraphQL schema to protobuf format (passthrough)

func ConvertProtoRestApisToLocal

func ConvertProtoRestApisToLocal(protoApis []*protobuff.ThirdPartyRESTApi) []*protobuff.ThirdPartyRESTApi

ConvertProtoRestApisToLocal converts protobuf REST APIs to local format (passthrough)

func ConvertRestApisToProto

func ConvertRestApisToProto(apis []*protobuff.ThirdPartyRESTApi) []*protobuff.ThirdPartyRESTApi

ConvertRestApisToProto converts protobuf REST APIs to protobuf format (passthrough)

func HasCapability added in v1.8.21

func HasCapability(id, cap string) bool

HasCapability reports whether plugin id declares cap.

func IsKnownCapability added in v1.8.21

func IsKnownCapability(cap string) bool

IsKnownCapability reports whether cap is in the allowlist.

func KnownCapabilityList added in v1.8.21

func KnownCapabilityList() []string

KnownCapabilityList returns the sorted allowlist.

func LoadHashiCorpPluginRegistry

func LoadHashiCorpPluginRegistry(cfg *models.Config) (map[string]*protobuff.PluginDetails, error)

func LoadHashiCorpPluginRegistryFromYAML

func LoadHashiCorpPluginRegistryFromYAML(cfg *models.Config) (map[string]*protobuff.PluginDetails, error)

LoadHashiCorpPluginRegistryFromYAML loads plugin configurations from individual config.yml files

func MergeRuntimeContributions added in v1.8.21

func MergeRuntimeContributions(id string, snap *RuntimeAPISnapshot)

MergeRuntimeContributions overlays live SchemaRegister/REST metadata onto declared contributions.

func NormalizeCapabilities added in v1.8.21

func NormalizeCapabilities(caps []string) []string

NormalizeCapabilities drops unknown values and de-duplicates.

func PluginIDFromSource added in v1.8.21

func PluginIDFromSource(source interface{}) string

PluginIDFromSource extracts a plugin id from GraphQL/REST source values.

func RejectLegacyProjectTypeInDev added in v1.8.21

func RejectLegacyProjectTypeInDev(pluginType string, caps []string) error

RejectLegacyProjectTypeInDev returns a migration error in development when config.yml still uses type: project without explicit capabilities.

func SetPluginCapabilities added in v1.8.21

func SetPluginCapabilities(id string, caps []string)

SetPluginCapabilities records declared capabilities for a plugin id.

func SetPluginContributions added in v1.8.21

func SetPluginContributions(id string, c *Contributions)

SetPluginContributions records declared + merged contributions for a plugin id.

func SetPluginUIManifest added in v1.8.21

func SetPluginUIManifest(id string, ui UIManifest)

SetPluginUIManifest records official UI metadata for a plugin id.

func UIBundlePath added in v1.8.21

func UIBundlePath(pluginRoot, id string, ui UIManifest) (string, error)

UIBundlePath is the on-disk UI file for an installed plugin.

Types

type APIContribution added in v1.8.21

type APIContribution struct {
	Scope     string          `json:"scope,omitempty" yaml:"scope,omitempty"` // system | project
	Queries   []APIOperation  `json:"queries,omitempty" yaml:"queries,omitempty"`
	Mutations []APIOperation  `json:"mutations,omitempty" yaml:"mutations,omitempty"`
	REST      []RESTOperation `json:"rest,omitempty" yaml:"rest,omitempty"`
	Events    []string        `json:"events,omitempty" yaml:"events,omitempty"`
}

APIContribution describes GraphQL, REST, and events.

type APIOperation added in v1.8.21

type APIOperation struct {
	Name        string `json:"name" yaml:"name"`
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
	Args        string `json:"args,omitempty" yaml:"args,omitempty"`
	Returns     string `json:"returns,omitempty" yaml:"returns,omitempty"`
}

APIOperation is one GraphQL query or mutation.

type Contributions added in v1.8.21

type Contributions struct {
	API    *APIContribution    `json:"api,omitempty" yaml:"api,omitempty"`
	UI     *UIContribution     `json:"ui,omitempty" yaml:"ui,omitempty"`
	Fields []FieldContribution `json:"fields,omitempty" yaml:"fields,omitempty"`
}

Contributions is the signed + runtime plugin surface: API, UI, fields. Absence of a section means the plugin does not contribute that surface.

func ContributionsFor added in v1.8.21

func ContributionsFor(id string) *Contributions

ContributionsFor returns merged contributions for a plugin id.

func MergeContributions added in v1.8.21

func MergeContributions(declared *Contributions, snap *RuntimeAPISnapshot, defaults *Contributions) *Contributions

MergeContributions prefers runtime API names, keeps declared UI/fields, fills defaults.

func NormalizeContributions added in v1.8.21

func NormalizeContributions(c *Contributions) *Contributions

NormalizeContributions drops unknown nav anchors and storage types.

func (*Contributions) Clone added in v1.8.21

func (c *Contributions) Clone() *Contributions

Clone deep-copies contributions.

func (*Contributions) Empty added in v1.8.21

func (c *Contributions) Empty() bool

Empty reports whether no surface is declared.

type FieldContribution added in v1.8.21

type FieldContribution struct {
	ID               string `json:"id" yaml:"id"`
	Label            string `json:"label" yaml:"label"`
	Icon             string `json:"icon,omitempty" yaml:"icon,omitempty"`
	StorageType      string `json:"storage_type" yaml:"storage_type"`
	FormComponent    string `json:"form_component,omitempty" yaml:"form_component,omitempty"`
	DisplayComponent string `json:"display_component,omitempty" yaml:"display_component,omitempty"`
	ValidationSchema string `json:"validation_schema,omitempty" yaml:"validation_schema,omitempty"`
	ContentForm      bool   `json:"content_form" yaml:"content_form"`
}

FieldContribution is a model/content field renderer bound to a core storage type.

type HashiCorpNormalPluginGRPC

type HashiCorpNormalPluginGRPC struct {
	hcplugin.NetRPCUnsupportedPlugin

	Impl interfaces.HashiCorpPluginInterface
	// contains filtered or unexported fields
}

HashiCorpNormalPluginGRPC is the gRPC implementation for normal plugins

func (*HashiCorpNormalPluginGRPC) Execute

func (p *HashiCorpNormalPluginGRPC) Execute(ctx context.Context, functionName, functionType string, args map[string]interface{}, contextData map[string]interface{}) (*protobuff.ExecuteResponse, error)

Execute calls the plugin's Execute method for function/resolver execution

func (*HashiCorpNormalPluginGRPC) GRPCClient

func (p *HashiCorpNormalPluginGRPC) GRPCClient(ctx context.Context, broker *hcplugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)

GRPCClient implementation

func (*HashiCorpNormalPluginGRPC) GRPCServer

func (p *HashiCorpNormalPluginGRPC) GRPCServer(broker *hcplugin.GRPCBroker, s *grpc.Server) error

GRPCServer implementation

func (*HashiCorpNormalPluginGRPC) GetVersion

func (p *HashiCorpNormalPluginGRPC) GetVersion(ctx context.Context) (string, error)

func (*HashiCorpNormalPluginGRPC) Init

func (*HashiCorpNormalPluginGRPC) Migration

func (p *HashiCorpNormalPluginGRPC) Migration(ctx context.Context) error

func (*HashiCorpNormalPluginGRPC) RESTApiRegister

func (*HashiCorpNormalPluginGRPC) SchemaRegister

type HashiCorpNormalPluginGRPCServer

type HashiCorpNormalPluginGRPCServer struct {
	protobuff.UnimplementedPluginServiceServer
	Impl interfaces.HashiCorpPluginInterface
	// contains filtered or unexported fields
}

HashiCorpNormalPluginGRPCServer is the gRPC server implementation for normal plugins

func (*HashiCorpNormalPluginGRPCServer) GetVersion

func (*HashiCorpNormalPluginGRPCServer) Init

func (*HashiCorpNormalPluginGRPCServer) Migration

func (*HashiCorpNormalPluginGRPCServer) RESTApiRegister

func (*HashiCorpNormalPluginGRPCServer) SchemaRegister

type HashiCorpPluginManager

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

HashiCorpPluginManager handles lifecycle operations for HashiCorp plugins

func NewHashiCorpPluginManager

func NewHashiCorpPluginManager() *HashiCorpPluginManager

NewHashiCorpPluginManager creates a new plugin manager

func (*HashiCorpPluginManager) GetAllPlugins

func (pm *HashiCorpPluginManager) GetAllPlugins() map[string]*models.HashiCorpPluginCache

GetAllPlugins returns all registered plugins

func (*HashiCorpPluginManager) GetPlugin

func (pm *HashiCorpPluginManager) GetPlugin(pluginID string) (*models.HashiCorpPluginCache, bool)

GetPlugin retrieves a plugin from the cache

func (*HashiCorpPluginManager) GetPluginMetrics

func (pm *HashiCorpPluginManager) GetPluginMetrics(pluginID string) (*PluginMetrics, error)

GetPluginMetrics collects metrics for a specific plugin

func (*HashiCorpPluginManager) GetPluginsByType

func (pm *HashiCorpPluginManager) GetPluginsByType(pluginType protobuff.PluginType) []*models.HashiCorpPluginCache

GetPluginsByType returns all plugins of a specific type

func (*HashiCorpPluginManager) HealthCheckAllPlugins

func (pm *HashiCorpPluginManager) HealthCheckAllPlugins(ctx context.Context) map[string]*PluginHealthCheck

HealthCheckAllPlugins performs health checks on all registered plugins

func (*HashiCorpPluginManager) HealthCheckPlugin

func (pm *HashiCorpPluginManager) HealthCheckPlugin(ctx context.Context, pluginID string) (*PluginHealthCheck, error)

HealthCheckPlugin performs a health check on a specific plugin

func (*HashiCorpPluginManager) RegisterPlugin

func (pm *HashiCorpPluginManager) RegisterPlugin(pluginID string, cache *models.HashiCorpPluginCache)

RegisterPlugin adds a plugin to the cache

func (*HashiCorpPluginManager) RestartPlugin

func (pm *HashiCorpPluginManager) RestartPlugin(ctx context.Context, pluginID string, details *protobuff.PluginDetails) error

RestartPlugin attempts to restart a failed plugin

func (*HashiCorpPluginManager) ShutdownAllPlugins

func (pm *HashiCorpPluginManager) ShutdownAllPlugins() error

ShutdownAllPlugins gracefully shuts down all plugins

func (*HashiCorpPluginManager) UnregisterPlugin

func (pm *HashiCorpPluginManager) UnregisterPlugin(pluginID string) error

UnregisterPlugin removes a plugin from the cache and cleans up

func (*HashiCorpPluginManager) ValidatePlugin

func (pm *HashiCorpPluginManager) ValidatePlugin(ctx context.Context, pluginID string) error

ValidatePlugin checks if a plugin is properly configured and functional

type NavPlacement struct {
	After    string `json:"after,omitempty" yaml:"after,omitempty"`
	Before   string `json:"before,omitempty" yaml:"before,omitempty"`
	Group    string `json:"group,omitempty" yaml:"group,omitempty"`
	Settings bool   `json:"settings,omitempty" yaml:"settings,omitempty"`
	Hidden   bool   `json:"hidden,omitempty" yaml:"hidden,omitempty"`
	Label    string `json:"label,omitempty" yaml:"label,omitempty"`
	Path     string `json:"path,omitempty" yaml:"path,omitempty"`
	Icon     string `json:"icon,omitempty" yaml:"icon,omitempty"`
}

NavPlacement is an allowlisted sidebar insert.

type PluginHealthCheck

type PluginHealthCheck struct {
	Status      string `json:"status"`
	Message     string `json:"message"`
	LastChecked int64  `json:"last_checked"`
}

PluginHealthCheck represents the health status of a plugin

type PluginMetrics

type PluginMetrics struct {
	RequestCount    int64   `json:"request_count"`
	ErrorCount      int64   `json:"error_count"`
	AverageLatency  float64 `json:"average_latency"`
	LastRequestTime int64   `json:"last_request_time"`
	MemoryUsage     int64   `json:"memory_usage"`
}

PluginMetrics represents metrics collected for a plugin

type RESTOperation added in v1.8.21

type RESTOperation struct {
	Method      string `json:"method" yaml:"method"`
	Path        string `json:"path" yaml:"path"`
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
}

RESTOperation is one REST endpoint.

type RuntimeAPISnapshot added in v1.8.21

type RuntimeAPISnapshot struct {
	Queries   []APIOperation
	Mutations []APIOperation
	REST      []RESTOperation
}

RuntimeAPISnapshot is SchemaRegister / RESTApiRegister truth captured at load.

func SnapshotRuntimeAPI added in v1.8.21

SnapshotRuntimeAPI extracts operation metadata from plugin register payloads.

type SettingsSurface added in v1.8.21

type SettingsSurface struct {
	Path  string `json:"path,omitempty" yaml:"path,omitempty"`
	Label string `json:"label,omitempty" yaml:"label,omitempty"`
}

SettingsSurface is a host settings page for the plugin.

type UIContribution added in v1.8.21

type UIContribution struct {
	Available    bool              `json:"ui_available" yaml:"ui_available"`
	Routes       []UIRoute         `json:"routes,omitempty" yaml:"routes,omitempty"`
	Navigation   []NavPlacement    `json:"navigation,omitempty" yaml:"navigation,omitempty"`
	Settings     []SettingsSurface `json:"settings,omitempty" yaml:"settings,omitempty"`
	ComponentIDs []string          `json:"component_ids,omitempty" yaml:"component_ids,omitempty"`
}

UIContribution describes console routes, nav, and settings.

type UIManifest added in v1.8.21

type UIManifest struct {
	EntryPath    string
	Official     bool
	BundleURL    string
	BundleSHA256 string
	Publisher    string
	Signed       bool
}

UIManifest is signed-official Console UI metadata from config.yml.

func SealUIBundle added in v1.8.21

func SealUIBundle(id, pluginDir string, cfg *YAMLUIConfig) UIManifest

SealUIBundle hashes the extracted UI file and points Console at Engine, never GitHub.

func UIManifestFor added in v1.8.21

func UIManifestFor(id string) UIManifest

UIManifestFor returns official UI metadata for a plugin id.

type UIRoute added in v1.8.21

type UIRoute struct {
	Path  string `json:"path" yaml:"path"`
	Title string `json:"title,omitempty" yaml:"title,omitempty"`
}

UIRoute is a console plugin route.

type YAMLEnvVar

type YAMLEnvVar struct {
	Key   string `yaml:"key"`
	Value string `yaml:"value"`
}

YAMLEnvVar represents an environment variable in YAML

type YAMLHandshakeConfig

type YAMLHandshakeConfig struct {
	ProtocolVersion  int32  `yaml:"protocol_version"`
	MagicCookieKey   string `yaml:"magic_cookie_key"`
	MagicCookieValue string `yaml:"magic_cookie_value"`
}

YAMLHandshakeConfig represents the handshake configuration in YAML

type YAMLPlugin

type YAMLPlugin struct {
	ID               string              `yaml:"id"`
	Language         string              `yaml:"language"`
	Title            string              `yaml:"title"`
	Icon             string              `yaml:"icon"`
	Description      string              `yaml:"description"`
	Type             string              `yaml:"type"` // deprecated; use capabilities
	Capabilities     []string            `yaml:"capabilities"`
	Role             string              `yaml:"role"`
	ExportedVariable string              `yaml:"exported_variable"`
	Enable           bool                `yaml:"enable"`
	Debug            bool                `yaml:"debug"`
	Version          string              `yaml:"version"`
	Author           string              `yaml:"author"`
	RepositoryURL    string              `yaml:"repository_url"`
	Branch           string              `yaml:"branch"`
	BinaryPath       string              `yaml:"binary_path"`
	HandshakeConfig  YAMLHandshakeConfig `yaml:"handshake_config"`
	UIConfig         *YAMLUIConfig       `yaml:"ui_config,omitempty"`
	Contributions    *Contributions      `yaml:"contributions,omitempty"`
	EnvVars          []YAMLEnvVar        `yaml:"env_vars"`
}

YAMLPlugin represents a single plugin configuration in YAML

type YAMLPluginConfig

type YAMLPluginConfig struct {
	Plugin YAMLPlugin `yaml:"plugin"`
}

YAMLPluginConfig represents the structure of the individual plugin config.yml file

type YAMLUIConfig added in v1.1.8

type YAMLUIConfig struct {
	EntryPath    string `yaml:"entry_path"`
	Official     bool   `yaml:"official"`
	BundleURL    string `yaml:"bundle_url"`
	BundleSHA256 string `yaml:"bundle_sha256"`
	Publisher    string `yaml:"publisher"`
	Signed       bool   `yaml:"signed"`
}

YAMLUIConfig represents the UI configuration in YAML

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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