Documentation
¶
Overview ¶
Package plugin provides functionality for loading and managing HashiCorp plugins from individual config.yml files in plugin directories.
Index ¶
- Constants
- func CapabilitiesFor(id string) []string
- func CapabilitiesFromLegacyType(pluginType string) ([]string, error)
- func ConvertEnvVariablesFromProto(protoEnvVars []*protobuff.EnvVariable) []*protobuff.EnvVariable
- func ConvertGraphQLSchemaToProto(schema *protobuff.ThirdPartyGraphQLSchemas) (*protobuff.ThirdPartyGraphQLSchemas, error)
- func ConvertProtoRestApisToLocal(protoApis []*protobuff.ThirdPartyRESTApi) []*protobuff.ThirdPartyRESTApi
- func ConvertRestApisToProto(apis []*protobuff.ThirdPartyRESTApi) []*protobuff.ThirdPartyRESTApi
- func HasCapability(id, cap string) bool
- func IsKnownCapability(cap string) bool
- func KnownCapabilityList() []string
- func LoadHashiCorpPluginRegistry(cfg *models.Config) (map[string]*protobuff.PluginDetails, error)
- func LoadHashiCorpPluginRegistryFromYAML(cfg *models.Config) (map[string]*protobuff.PluginDetails, error)
- func MergeRuntimeContributions(id string, snap *RuntimeAPISnapshot)
- func NormalizeCapabilities(caps []string) []string
- func PluginIDFromSource(source interface{}) string
- func RejectLegacyProjectTypeInDev(pluginType string, caps []string) error
- func SetPluginCapabilities(id string, caps []string)
- func SetPluginContributions(id string, c *Contributions)
- func SetPluginUIManifest(id string, ui UIManifest)
- func UIBundlePath(pluginRoot, id string, ui UIManifest) (string, error)
- type APIContribution
- type APIOperation
- type Contributions
- type FieldContribution
- type HashiCorpNormalPluginGRPC
- func (p *HashiCorpNormalPluginGRPC) Execute(ctx context.Context, functionName, functionType string, ...) (*protobuff.ExecuteResponse, error)
- func (p *HashiCorpNormalPluginGRPC) GRPCClient(ctx context.Context, broker *hcplugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)
- func (p *HashiCorpNormalPluginGRPC) GRPCServer(broker *hcplugin.GRPCBroker, s *grpc.Server) error
- func (p *HashiCorpNormalPluginGRPC) GetVersion(ctx context.Context) (string, error)
- func (p *HashiCorpNormalPluginGRPC) Init(ctx context.Context, env []*protobuff.EnvVariable) error
- func (p *HashiCorpNormalPluginGRPC) Migration(ctx context.Context) error
- func (p *HashiCorpNormalPluginGRPC) RESTApiRegister(ctx context.Context) ([]*protobuff.ThirdPartyRESTApi, error)
- func (p *HashiCorpNormalPluginGRPC) SchemaRegister(ctx context.Context) (*protobuff.ThirdPartyGraphQLSchemas, error)
- type HashiCorpNormalPluginGRPCServer
- func (s *HashiCorpNormalPluginGRPCServer) GetVersion(ctx context.Context, req *protobuff.GetVersionRequest) (*protobuff.GetVersionResponse, error)
- func (s *HashiCorpNormalPluginGRPCServer) Init(ctx context.Context, req *protobuff.InitRequest) (*protobuff.InitResponse, error)
- func (s *HashiCorpNormalPluginGRPCServer) Migration(ctx context.Context, req *protobuff.MigrationRequest) (*protobuff.MigrationResponse, error)
- func (s *HashiCorpNormalPluginGRPCServer) RESTApiRegister(ctx context.Context, req *protobuff.RESTApiRegisterRequest) (*protobuff.RESTApiRegisterResponse, error)
- func (s *HashiCorpNormalPluginGRPCServer) SchemaRegister(ctx context.Context, req *protobuff.SchemaRegisterRequest) (*protobuff.SchemaRegisterResponse, error)
- type HashiCorpPluginManager
- func (pm *HashiCorpPluginManager) GetAllPlugins() map[string]*models.HashiCorpPluginCache
- func (pm *HashiCorpPluginManager) GetPlugin(pluginID string) (*models.HashiCorpPluginCache, bool)
- func (pm *HashiCorpPluginManager) GetPluginMetrics(pluginID string) (*PluginMetrics, error)
- func (pm *HashiCorpPluginManager) GetPluginsByType(pluginType protobuff.PluginType) []*models.HashiCorpPluginCache
- func (pm *HashiCorpPluginManager) HealthCheckAllPlugins(ctx context.Context) map[string]*PluginHealthCheck
- func (pm *HashiCorpPluginManager) HealthCheckPlugin(ctx context.Context, pluginID string) (*PluginHealthCheck, error)
- func (pm *HashiCorpPluginManager) RegisterPlugin(pluginID string, cache *models.HashiCorpPluginCache)
- func (pm *HashiCorpPluginManager) RestartPlugin(ctx context.Context, pluginID string, details *protobuff.PluginDetails) error
- func (pm *HashiCorpPluginManager) ShutdownAllPlugins() error
- func (pm *HashiCorpPluginManager) UnregisterPlugin(pluginID string) error
- func (pm *HashiCorpPluginManager) ValidatePlugin(ctx context.Context, pluginID string) error
- type NavPlacement
- type PluginHealthCheck
- type PluginMetrics
- type RESTOperation
- type RuntimeAPISnapshot
- type SettingsSurface
- type UIContribution
- type UIManifest
- type UIRoute
- type YAMLEnvVar
- type YAMLHandshakeConfig
- type YAMLPlugin
- type YAMLPluginConfig
- type YAMLUIConfig
Constants ¶
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
CapabilitiesFor returns declared capabilities for a plugin id.
func CapabilitiesFromLegacyType ¶ added in v1.8.21
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
HasCapability reports whether plugin id declares cap.
func IsKnownCapability ¶ added in v1.8.21
IsKnownCapability reports whether cap is in the allowlist.
func KnownCapabilityList ¶ added in v1.8.21
func KnownCapabilityList() []string
KnownCapabilityList returns the sorted allowlist.
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
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
RejectLegacyProjectTypeInDev returns a migration error in development when config.yml still uses type: project without explicit capabilities.
func SetPluginCapabilities ¶ added in v1.8.21
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 (p *HashiCorpNormalPluginGRPC) Init(ctx context.Context, env []*protobuff.EnvVariable) error
func (*HashiCorpNormalPluginGRPC) Migration ¶
func (p *HashiCorpNormalPluginGRPC) Migration(ctx context.Context) error
func (*HashiCorpNormalPluginGRPC) RESTApiRegister ¶
func (p *HashiCorpNormalPluginGRPC) RESTApiRegister(ctx context.Context) ([]*protobuff.ThirdPartyRESTApi, error)
func (*HashiCorpNormalPluginGRPC) SchemaRegister ¶
func (p *HashiCorpNormalPluginGRPC) SchemaRegister(ctx context.Context) (*protobuff.ThirdPartyGraphQLSchemas, error)
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 (s *HashiCorpNormalPluginGRPCServer) GetVersion(ctx context.Context, req *protobuff.GetVersionRequest) (*protobuff.GetVersionResponse, error)
func (*HashiCorpNormalPluginGRPCServer) Init ¶
func (s *HashiCorpNormalPluginGRPCServer) Init(ctx context.Context, req *protobuff.InitRequest) (*protobuff.InitResponse, error)
func (*HashiCorpNormalPluginGRPCServer) Migration ¶
func (s *HashiCorpNormalPluginGRPCServer) Migration(ctx context.Context, req *protobuff.MigrationRequest) (*protobuff.MigrationResponse, error)
func (*HashiCorpNormalPluginGRPCServer) RESTApiRegister ¶
func (s *HashiCorpNormalPluginGRPCServer) RESTApiRegister(ctx context.Context, req *protobuff.RESTApiRegisterRequest) (*protobuff.RESTApiRegisterResponse, error)
func (*HashiCorpNormalPluginGRPCServer) SchemaRegister ¶
func (s *HashiCorpNormalPluginGRPCServer) SchemaRegister(ctx context.Context, req *protobuff.SchemaRegisterRequest) (*protobuff.SchemaRegisterResponse, error)
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 ¶ added in v1.8.21
type NavPlacement struct {
}
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
func SnapshotRuntimeAPI(schemas *protobuff.ThirdPartyGraphQLSchemas, apis []*protobuff.ThirdPartyRESTApi) *RuntimeAPISnapshot
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"`
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 ¶
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