Documentation
¶
Overview ¶
Package types defines shared plugin metadata, connection state, and request context values.
Index ¶
- Constants
- Variables
- func LoadPluginMarkdown(path string) (string, error)
- func LoadPluginMetadata(path string) (config.PluginMeta, error)
- func WithConnection(ctx context.Context, c *Connection) context.Context
- func WithPluginContext(ctx context.Context, pluginContext *PluginContext) context.Context
- type Capability
- type Connection
- func (c *Connection) GetData() map[string]any
- func (c *Connection) GetDataKey(key string) (any, bool)
- func (c *Connection) GetSensitiveData() map[string]any
- func (c *Connection) GetSensitiveDataKey(key string) (any, bool)
- func (c *Connection) IsAuthed() bool
- func (c *Connection) SetData(data map[string]any)
- func (c *Connection) SetDataKey(key string, value any)
- func (c *Connection) SetSensitiveData(data map[string]any)
- func (c *Connection) SetSensitiveDataKey(key string, value any)
- type ConnectionAutoConnect
- type ConnectionAutoConnectRetry
- type ConnectionAutoConnectTrigger
- type ConnectionContext
- type ConnectionLifecycle
- type ConnectionOpts
- type ConnectionStatus
- type ConnectionStatusCode
- type Plugindeprecated
- type PluginContext
- func NewPluginContext(ctx context.Context, requester string, pluginConfig settings.Provider, ...) *PluginContext
- func NewPluginContextFromCtx(ctx context.Context) *PluginContext
- func NewPluginContextWithConnection(ctx context.Context, requester string, pluginConfig settings.Provider, ...) *PluginContext
- func PluginContextFromContext(ctx context.Context) *PluginContext
- type PluginInfo
- type PluginTypedeprecated
- type RequestOptions
- type ResourceContext
- type VisualComponentList
- type VisualResourceComponent
Constants ¶
const ( // DefaultTimeout bounds requests that do not specify a timeout. DefaultTimeout = 10 * time.Second // DefaultMaxRetries limits retries for default request options. DefaultMaxRetries = 3 // DefaultBackoffInterval sets the delay between default retries. DefaultBackoffInterval = 1 * time.Second )
const ( // ConnectionDefaultExpiryTime is the default credential validity window for new connections. ConnectionDefaultExpiryTime = time.Hour * 24 )
Variables ¶
var AllConnectionStatusCodes = []struct { Value ConnectionStatusCode TSName string }{ {ConnectionStatusUnknown, "UNKNOWN"}, {ConnectionStatusConnected, "CONNECTED"}, {ConnectionStatusDisconnected, "DISCONNECTED"}, {ConnectionStatusPending, "PENDING"}, {ConnectionStatusFailed, "FAILED"}, {ConnectionStatusError, "ERROR"}, {ConnectionStatusUnauthorized, "UNAUTHORIZED"}, {ConnectionStatusForbidden, "FORBIDDEN"}, {ConnectionStatusBadRequest, "BAD_REQUEST"}, {ConnectionStatusNotFound, "NOT_FOUND"}, {ConnectionStatusTimeout, "TIMEOUT"}, {ConnectionStatusUnavailable, "UNAVAILABLE"}, {ConnectionStatusRequestEntityTooLarge, "REQUEST_ENTITY_TOO_LARGE"}, }
AllConnectionStatusCodes is a list of all setting types. Necessary for Wails to bind the enums.
Functions ¶
func LoadPluginMarkdown ¶
LoadPluginMarkdown loads the plugin markdown from the filesystem. Like LoadPluginMetadata, it closes the README.md it opens before it returns.
func LoadPluginMetadata ¶
func LoadPluginMetadata(path string) (config.PluginMeta, error)
LoadPluginMetadata loads the metadata for a plugin from the given path.
The plugin.yaml it opens is closed before the function returns, on every path: Windows refuses to rename or remove a plugin's directory while a file inside it is open, and waiting for the garbage collector to finalize the file would leave an update or an uninstall failing until it happens to run.
func WithConnection ¶
func WithConnection(ctx context.Context, c *Connection) context.Context
WithConnection stores the connection pointer without copying it or changing its lifecycle.
func WithPluginContext ¶
func WithPluginContext(ctx context.Context, pluginContext *PluginContext) context.Context
WithPluginContext stores a shallow snapshot without retaining the snapshot's Context. A nil pluginContext leaves ctx unchanged; referenced settings and connection data remain shared.
Types ¶
type Capability ¶ added in v0.1.1
type Capability string
Capability represents a plugin capability as a string type. Using strings allows direct matching with YAML/JSON config values and makes adding new capabilities non-breaking.
const ( // CapabilityResource enables resource discovery and operations. CapabilityResource Capability = "resource" // CapabilityExec enables remote command execution. CapabilityExec Capability = "exec" // CapabilityNetworker enables network forwarding. CapabilityNetworker Capability = "networker" // CapabilityLog enables log streaming. CapabilityLog Capability = "log" // CapabilityMetric enables metric queries. CapabilityMetric Capability = "metric" // CapabilitySettings enables plugin settings. CapabilitySettings Capability = "settings" // CapabilityTools enables tool execution. CapabilityTools Capability = "tools" // CapabilityUI enables frontend components without requiring a backend process. CapabilityUI Capability = "ui" )
func AllCapabilities ¶ added in v0.1.1
func AllCapabilities() []Capability
AllCapabilities returns all known capabilities.
func ParseCapability ¶ added in v0.1.1
func ParseCapability(s string) (Capability, bool)
ParseCapability converts a string to a Capability. Returns the Capability and true if valid, or empty and false if unknown.
func (Capability) IsBackend ¶ added in v0.1.1
func (c Capability) IsBackend() bool
IsBackend returns true if this capability requires a backend plugin process.
func (Capability) String ¶ added in v0.1.1
func (c Capability) String() string
String implements the Stringer interface.
type Connection ¶
type Connection struct {
// LastRefresh is the time when the auth context was last refreshed
// +optional
LastRefresh time.Time `json:"last_refresh"`
// Data is an optional map of arbitrary data that can be used to store additional information about the connection,
// such as credential file locations, etc.
//
// This data is exposed to the user in the UI under the settings panel for the namespace. If the data is sensitive,
// it should be stored in the SensitiveData field.
// +optional
Data map[string]any `json:"data"`
// Labels is a map of arbitrary key-value pairs that can be used to store additional information about the connection.
// Users will likely use and modify these labels to help organize and categorize their connections.
Labels map[string]any `json:"labels"`
// Lifecycle contains IDE-managed lifecycle behavior for the connection.
// This is used by the host to orchestrate behaviors like auto-connect.
Lifecycle ConnectionLifecycle `json:"lifecycle"`
// ID is the unique identifier for the connection that makes sense to the plugin implementation.
// +required
ID string `json:"id"`
// UID is an autogenerated unique identifier for the connection that the IDE will use to identify and track.
UID string `json:"uid"`
// Name is the readable name of the connection. Editable by the user.
// +required
Name string `json:"name"`
// Description is an optional description of the connection. This is primarily for the user to customize
// the visual representation of the connection.
// +optional
Description string `json:"description"`
// Avatar is an optional image that can be used to represent the connection. This is primarily for the user to customize
// the visual representation of the connection in the UI.
// +optional
Avatar string `json:"avatar"`
// ExpiryTime is the amount of time before the connection expires.
// +optional
ExpiryTime time.Duration `json:"expiry_time"`
// Client is a client structure that should be populated when the connection is created and used for connections
Client any
// contains filtered or unexported fields
}
Connection holds the current state (and configuration data) for an connection target for a plugin (e.g. a Kubernetes cluster, a cloud role, etc)
This will be passed within the PluginContext so that it may be used across all requests, and data here not within the sensitiveStore will be exposed to the user in the UI for the plugin.
func ConnectionFromContext ¶
func ConnectionFromContext(ctx context.Context) *Connection
ConnectionFromContext returns the stored pointer, or nil for a nil context or absent connection.
func NewConnection ¶
func NewConnection(opts ConnectionOpts) (*Connection, error)
NewConnection requires an ID, supplies missing defaults, and validates lifecycle policies. Supplied maps and trigger slices remain shared; the automatic-connection struct is copied.
func (*Connection) GetData ¶
func (c *Connection) GetData() map[string]any
GetData returns the shared public configuration map without copying it.
func (*Connection) GetDataKey ¶
func (c *Connection) GetDataKey(key string) (any, bool)
GetDataKey returns a public value and whether its key exists; a nil map has no keys.
func (*Connection) GetSensitiveData ¶
func (c *Connection) GetSensitiveData() map[string]any
GetSensitiveData returns the shared private map; callers must synchronize concurrent access.
func (*Connection) GetSensitiveDataKey ¶
func (c *Connection) GetSensitiveDataKey(key string) (any, bool)
GetSensitiveDataKey returns a private value and whether its key exists; a nil map has no keys.
func (*Connection) IsAuthed ¶
func (c *Connection) IsAuthed() bool
IsAuthed returns whether the auth context is authenticated or not.
func (*Connection) SetData ¶
func (c *Connection) SetData(data map[string]any)
SetData replaces the public map without copying it; nil remains nil.
func (*Connection) SetDataKey ¶
func (c *Connection) SetDataKey(key string, value any)
SetDataKey updates the public map, which must already be initialized.
func (*Connection) SetSensitiveData ¶
func (c *Connection) SetSensitiveData(data map[string]any)
SetSensitiveData replaces the private map without copying it; nil remains nil.
func (*Connection) SetSensitiveDataKey ¶
func (c *Connection) SetSensitiveDataKey(key string, value any)
SetSensitiveDataKey updates the private map, which must already be initialized.
type ConnectionAutoConnect ¶ added in v0.2.0
type ConnectionAutoConnect struct {
Enabled bool `json:"enabled"`
Triggers []ConnectionAutoConnectTrigger `json:"triggers"`
Retry ConnectionAutoConnectRetry `json:"retry"`
}
ConnectionAutoConnect configures host-managed connection triggers and retry behavior.
type ConnectionAutoConnectRetry ¶ added in v0.2.0
type ConnectionAutoConnectRetry string
ConnectionAutoConnectRetry selects when the host may retry a failed automatic connection.
const ( // ConnectionAutoConnectRetryNone disables automatic retries after failure. ConnectionAutoConnectRetryNone ConnectionAutoConnectRetry = "NONE" // ConnectionAutoConnectRetryOnChange permits retry after connection configuration changes. ConnectionAutoConnectRetryOnChange ConnectionAutoConnectRetry = "ON_CHANGE" )
func (ConnectionAutoConnectRetry) Valid ¶ added in v0.2.0
func (r ConnectionAutoConnectRetry) Valid() bool
Valid reports whether the retry policy is supported.
type ConnectionAutoConnectTrigger ¶ added in v0.2.0
type ConnectionAutoConnectTrigger string
ConnectionAutoConnectTrigger identifies a host event that may initiate automatic connection.
const ( // ConnectionAutoConnectTriggerPluginStart requests automatic connection when the plugin starts. ConnectionAutoConnectTriggerPluginStart ConnectionAutoConnectTrigger = "PLUGIN_START" // ConnectionAutoConnectTriggerConnectionDiscovered requests connection when a profile is discovered. ConnectionAutoConnectTriggerConnectionDiscovered ConnectionAutoConnectTrigger = "CONNECTION_DISCOVERED" )
func (ConnectionAutoConnectTrigger) Valid ¶ added in v0.2.0
func (t ConnectionAutoConnectTrigger) Valid() bool
Valid reports whether the trigger names a supported automatic connection event.
type ConnectionContext ¶
type ConnectionContext Connection
ConnectionContext is a distinct connection value type for integrations requiring separate typing.
type ConnectionLifecycle ¶ added in v0.2.0
type ConnectionLifecycle struct {
AutoConnect *ConnectionAutoConnect `json:"auto_connect,omitempty"`
}
ConnectionLifecycle holds host-managed lifecycle preferences; nil AutoConnect leaves automatic connection unspecified.
type ConnectionOpts ¶
type ConnectionOpts struct {
// Data is an optional map of arbitrary data that can be used to store additional information about the namespace.
Data map[string]any
// SensitiveData is an optional map of arbitrary data that can be used to store additional information about the
SensitiveData map[string]any
// Labels is a map of arbitrary key-value pairs that can be used to store additional information about the namespace.
Labels map[string]any
// Lifecycle contains IDE-managed lifecycle behavior for the connection.
Lifecycle ConnectionLifecycle
// ID is the unique identifier for the authorization context that makes sense to the
ID string
// UID is an autogenerated unique identifier for the authorization context that the IDE.
// will use to identify the authorization context.
UID string
// Name is the readable name of the namespace.
Name string
// Description is an optional description of the namespace. This is primarily for the user to customize
Description string
// Avatar is an optional image that can be used to represent the namespace. This is primarily for the user to customize
Avatar string
// ExpiryTime is the amount of time before the auth context expires
ExpiryTime time.Duration
}
ConnectionOpts supplies connection metadata and shared maps to NewConnection.
type ConnectionStatus ¶
type ConnectionStatus struct {
// Connection is the connection that the status is for.
Connection *Connection `json:"connection"`
// StatusCode is the status code of the connection status.
Status ConnectionStatusCode `json:"status"`
// Error is the error that occurred when checking the connection status.
Error string `json:"error"`
// Message is a human readable message that describes the status.
Details string `json:"details"`
}
ConnectionStatus pairs a connection with its lifecycle or check result and diagnostic details.
type ConnectionStatusCode ¶
type ConnectionStatusCode string
ConnectionStatusCode classifies connection lifecycle state or a connection-check failure.
const ( // ConnectionStatusUnknown indicates that no connection state is known. ConnectionStatusUnknown ConnectionStatusCode = "UNKNOWN" // ConnectionStatusConnected indicates a registered active connection, not a network-health guarantee. ConnectionStatusConnected ConnectionStatusCode = "CONNECTED" // ConnectionStatusDisconnected indicates that the connection is not active. ConnectionStatusDisconnected ConnectionStatusCode = "DISCONNECTED" // ConnectionStatusPending indicates that connection startup is in progress. ConnectionStatusPending ConnectionStatusCode = "PENDING" // ConnectionStatusFailed indicates that connection startup failed. ConnectionStatusFailed ConnectionStatusCode = "FAILED" // ConnectionStatusError indicates an unclassified connection error. ConnectionStatusError ConnectionStatusCode = "ERROR" ConnectionStatusUnauthorized ConnectionStatusCode = "UNAUTHORIZED" // ConnectionStatusForbidden indicates that access was denied. ConnectionStatusForbidden ConnectionStatusCode = "FORBIDDEN" // ConnectionStatusBadRequest indicates invalid connection-check input. ConnectionStatusBadRequest ConnectionStatusCode = "BAD_REQUEST" // ConnectionStatusNotFound indicates that the requested connection or target was not found. ConnectionStatusNotFound ConnectionStatusCode = "NOT_FOUND" // ConnectionStatusTimeout indicates that the connection check exceeded its deadline. ConnectionStatusTimeout ConnectionStatusCode = "TIMEOUT" ConnectionStatusUnavailable ConnectionStatusCode = "UNAVAILABLE" // ConnectionStatusRequestEntityTooLarge indicates that the request exceeded the target limit. ConnectionStatusRequestEntityTooLarge ConnectionStatusCode = "REQUEST_ENTITY_TOO_LARGE" )
type Plugin
deprecated
type Plugin struct {
ID string `json:"id"`
Metadata config.PluginMeta `json:"metadata"`
Config config.PluginConfig `json:"-"`
Enabled bool `json:"enabled"`
Running bool `json:"running"`
DevMode bool `json:"devMode"`
DevPath string `json:"devPath"`
Loading bool `json:"loading"`
LoadError string `json:"loadError"`
Phase string `json:"phase,omitempty"`
Capabilities []PluginType `json:"capabilities"`
LastError string `json:"lastError,omitempty"`
// Runtime fields — not serialized.
RPCClient any `json:"-"`
PluginClient any `json:"-"`
}
Plugin is the legacy type that combines display + runtime state.
Deprecated: New code should use PluginInfo for display and host-side PluginRecord for runtime state.
func (*Plugin) GetRPCClient ¶
GetRPCClient returns the host-owned RPC client without transferring ownership.
func (*Plugin) HasCapability ¶
func (p *Plugin) HasCapability(capability PluginType) bool
HasCapability reports whether the legacy capability list contains capability.
func (*Plugin) SetDisabled ¶
func (p *Plugin) SetDisabled()
SetDisabled marks the plugin disabled without stopping its process.
func (*Plugin) SetEnabled ¶
func (p *Plugin) SetEnabled()
SetEnabled marks the plugin enabled without starting its process.
func (*Plugin) ToInfo ¶ added in v0.1.1
func (p *Plugin) ToInfo() PluginInfo
ToInfo converts a legacy Plugin to a PluginInfo for API responses.
type PluginContext ¶
type PluginContext struct {
// Current context
Context context.Context `json:"-"`
// RequestOptions are the options that were set for the request.
RequestOptions *RequestOptions `json:"request_options"`
// Connection holds the identifier of the auth context for the plugin.
Connection *Connection `json:"connection"`
// The resource context for the request, if available
ResourceContext *ResourceContext `json:"resource_context"`
// The plugin settings for the request
PluginConfig settings.Provider `json:"-"`
// GlobalSettings are settings that are accessible to all plugins, taken
// from the global settings in the IDE section
GlobalConfig *config.GlobalConfig `json:"global_config"`
// Unique ID for the request
RequestID string `json:"request_id"`
// The ID of the requester
RequesterID string `json:"requester_id"`
// Logger is a request-scoped logger injected by the SDK manager.
// Handlers can use this instead of capturing a logger via closure.
// nil when the manager does not inject one (callers should check).
Logger logging.Logger `json:"-"`
}
PluginContext holds contextual data for requests made to a plugin.
func NewPluginContext ¶
func NewPluginContext( ctx context.Context, requester string, pluginConfig settings.Provider, globalConfig *config.GlobalConfig, resourceContext *ResourceContext, ) *PluginContext
NewPluginContext creates a request context with a new request ID and shared resource and settings pointers.
func NewPluginContextFromCtx ¶
func NewPluginContextFromCtx(ctx context.Context) *PluginContext
NewPluginContextFromCtx creates request defaults using ctx's global configuration without storing itself in ctx.
func NewPluginContextWithConnection ¶
func NewPluginContextWithConnection( ctx context.Context, requester string, pluginConfig settings.Provider, globalConfig *config.GlobalConfig, connection *Connection, ) *PluginContext
NewPluginContextWithConnection creates a request context with a new request ID and the supplied connection.
func PluginContextFromContext ¶
func PluginContextFromContext(ctx context.Context) *PluginContext
PluginContextFromContext returns a fresh shallow snapshot bound to ctx, or nil when the private context entry is absent, invalid, or a typed-nil pointer.
func (*PluginContext) IsAuthenticated ¶
func (c *PluginContext) IsAuthenticated() bool
IsAuthenticated reports whether a connection is selected, not whether its credentials remain valid.
func (*PluginContext) SetConnection ¶
func (c *PluginContext) SetConnection(authContext *Connection)
SetConnection replaces the connection pointer without changing its authentication state.
func (*PluginContext) SetResourceContext ¶
func (c *PluginContext) SetResourceContext(resourceContext *ResourceContext)
SetResourceContext replaces the resource pointer without copying its contents.
func (*PluginContext) SetSettingsProvider ¶
func (c *PluginContext) SetSettingsProvider(provider settings.Provider)
SetSettingsProvider replaces the shared settings provider for this request.
type PluginInfo ¶ added in v0.1.1
type PluginInfo struct {
ID string `json:"id"`
Metadata config.PluginMeta `json:"metadata"`
Phase string `json:"phase"`
Enabled bool `json:"enabled"`
DevMode bool `json:"devMode"`
DevPath string `json:"devPath,omitempty"`
Capabilities []Capability `json:"capabilities"`
LastError string `json:"lastError,omitempty"`
}
PluginInfo represents the display/API-facing view of a plugin. This type is safe to serialize to JSON for the frontend. Runtime fields (RPCClient, PluginClient) live in the host-only PluginRecord.
type PluginType
deprecated
type PluginType int
PluginType is the legacy integer enum for plugin capabilities.
Deprecated: Use Capability instead.
const ( // ExecutorPlugin identifies the legacy remote-execution capability. ExecutorPlugin PluginType = iota // FilesystemPlugin identifies the legacy filesystem capability. FilesystemPlugin // LogPlugin identifies the legacy log-streaming capability. LogPlugin // MetricPlugin identifies the legacy metric-query capability. MetricPlugin // ReporterPlugin identifies the legacy reporting capability. ReporterPlugin // ResourcePlugin identifies the legacy resource capability. ResourcePlugin // SettingsPlugin identifies the legacy settings capability. SettingsPlugin // NetworkerPlugin identifies the legacy network-forwarding capability. NetworkerPlugin // UIPlugin identifies the legacy frontend capability. UIPlugin )
func (PluginType) MarshalText ¶
func (pt PluginType) MarshalText() ([]byte, error)
MarshalText encodes the legacy capability using its manifest name.
func (PluginType) String ¶
func (pt PluginType) String() string
String returns the manifest capability name, or "unknown" for an unrecognized value.
func (PluginType) ToCapability ¶ added in v0.1.1
func (pt PluginType) ToCapability() Capability
ToCapability converts a legacy PluginType to the new Capability type.
type RequestOptions ¶
type RequestOptions struct {
// The timeout for the request
Timeout time.Duration `json:"timeout"`
// The maximum number of retries for the request, if set
MaxRetries int `json:"max_retries"`
// The backoff interval for the request
BackoffInterval time.Duration `json:"backoff_interval"`
}
RequestOptions are the options that were set for the request.
func NewDefaultRequestOptions ¶
func NewDefaultRequestOptions() *RequestOptions
NewDefaultRequestOptions returns independently mutable request options initialized to SDK defaults.
type ResourceContext ¶
type ResourceContext struct {
// Key identifies the resource type being requested
Key string `json:"key"`
}
ResourceContext holds the context of the resource that the request is for, if the request is for a resource.
type VisualComponentList ¶
type VisualComponentList struct {
Resource []VisualResourceComponent `json:"resource"`
}
VisualComponentList is a list of visual components that can be used to visualize resources in the IDE.
type VisualResourceComponent ¶
type VisualResourceComponent struct {
ID string `json:"id"`
Plugin string `json:"plugin"`
Type string `json:"type"`
Resources []string `json:"resources"`
}
VisualResourceComponent is a component that can be used to visualize a resource in one of the injectable areas in the IDE.