types

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: AGPL-3.0 Imports: 11 Imported by: 9

Documentation

Index

Constants

View Source
const (
	DefaultTimeout         = 10 * time.Second
	DefaultMaxRetries      = 3
	DefaultBackoffInterval = 1 * time.Second
)
View Source
const (
	ConnectionDefaultExpiryTime = time.Hour * 24
)

Variables

View Source
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

func LoadPluginMarkdown(path string) (string, error)

LoadPluginMarkdown loads the plugin markdown from the filesystem.

func LoadPluginMetadata

func LoadPluginMetadata(path string) (config.PluginMeta, error)

LoadPluginMetadata loads the metadata for a plugin from the given path.

func WithConnection

func WithConnection(ctx context.Context, c *Connection) context.Context

func WithPluginContext

func WithPluginContext(ctx context.Context, pluginContext *PluginContext) context.Context

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  Capability = "resource"
	CapabilityExec      Capability = "exec"
	CapabilityNetworker Capability = "networker"
	CapabilityLog       Capability = "log"
	CapabilityMetric    Capability = "metric"
	CapabilitySettings  Capability = "settings"
	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

func NewConnection

func NewConnection(opts ConnectionOpts) (*Connection, error)

func (*Connection) GetData

func (c *Connection) GetData() map[string]any

func (*Connection) GetDataKey

func (c *Connection) GetDataKey(key string) (any, bool)

func (*Connection) GetSensitiveData

func (c *Connection) GetSensitiveData() map[string]any

func (*Connection) GetSensitiveDataKey

func (c *Connection) GetSensitiveDataKey(key string) (any, bool)

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)

func (*Connection) SetDataKey

func (c *Connection) SetDataKey(key string, value any)

func (*Connection) SetSensitiveData

func (c *Connection) SetSensitiveData(data map[string]any)

func (*Connection) SetSensitiveDataKey

func (c *Connection) SetSensitiveDataKey(key string, value any)

type ConnectionAutoConnect added in v0.2.0

type ConnectionAutoConnect struct {
	Enabled  bool                           `json:"enabled"`
	Triggers []ConnectionAutoConnectTrigger `json:"triggers"`
	Retry    ConnectionAutoConnectRetry     `json:"retry"`
}

type ConnectionAutoConnectRetry added in v0.2.0

type ConnectionAutoConnectRetry string
const (
	ConnectionAutoConnectRetryNone     ConnectionAutoConnectRetry = "NONE"
	ConnectionAutoConnectRetryOnChange ConnectionAutoConnectRetry = "ON_CHANGE"
)

func (ConnectionAutoConnectRetry) Valid added in v0.2.0

func (r ConnectionAutoConnectRetry) Valid() bool

type ConnectionAutoConnectTrigger added in v0.2.0

type ConnectionAutoConnectTrigger string
const (
	ConnectionAutoConnectTriggerPluginStart          ConnectionAutoConnectTrigger = "PLUGIN_START"
	ConnectionAutoConnectTriggerConnectionDiscovered ConnectionAutoConnectTrigger = "CONNECTION_DISCOVERED"
)

func (ConnectionAutoConnectTrigger) Valid added in v0.2.0

type ConnectionContext

type ConnectionContext Connection

type ConnectionLifecycle added in v0.2.0

type ConnectionLifecycle struct {
	AutoConnect *ConnectionAutoConnect `json:"auto_connect,omitempty"`
}

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
}

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"`
}

type ConnectionStatusCode

type ConnectionStatusCode string
const (
	ConnectionStatusUnknown               ConnectionStatusCode = "UNKNOWN"
	ConnectionStatusConnected             ConnectionStatusCode = "CONNECTED"
	ConnectionStatusDisconnected          ConnectionStatusCode = "DISCONNECTED"
	ConnectionStatusPending               ConnectionStatusCode = "PENDING"
	ConnectionStatusFailed                ConnectionStatusCode = "FAILED"
	ConnectionStatusError                 ConnectionStatusCode = "ERROR"
	ConnectionStatusUnauthorized          ConnectionStatusCode = "UNAUTHORIZED"
	ConnectionStatusForbidden             ConnectionStatusCode = "FORBIDDEN"
	ConnectionStatusBadRequest            ConnectionStatusCode = "BAD_REQUEST"
	ConnectionStatusNotFound              ConnectionStatusCode = "NOT_FOUND"
	ConnectionStatusTimeout               ConnectionStatusCode = "TIMEOUT"
	ConnectionStatusUnavailable           ConnectionStatusCode = "UNAVAILABLE"
	ConnectionStatusRequestEntityTooLarge ConnectionStatusCode = "REQUEST_ENTITY_TOO_LARGE"
)

type Plugin

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    interface{} `json:"-"`
	PluginClient interface{} `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

func (p *Plugin) GetRPCClient() interface{}

func (*Plugin) HasCapability

func (p *Plugin) HasCapability(capability PluginType) bool

func (*Plugin) IsRunning

func (p *Plugin) IsRunning() bool

func (*Plugin) SetDisabled

func (p *Plugin) SetDisabled()

func (*Plugin) SetEnabled

func (p *Plugin) SetEnabled()

func (*Plugin) String

func (p *Plugin) String() string

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

Construct a new plugin context with the given requester, resource key, and resource context.

func NewPluginContextFromCtx

func NewPluginContextFromCtx(ctx context.Context) *PluginContext

func NewPluginContextWithConnection

func NewPluginContextWithConnection(
	ctx context.Context,
	requester string,
	pluginConfig settings.Provider,
	globalConfig *config.GlobalConfig,
	connection *Connection,
) *PluginContext

Construct a new plugin context with a valid connection.

func PluginContextFromContext

func PluginContextFromContext(ctx context.Context) *PluginContext

func (*PluginContext) IsAuthenticated

func (c *PluginContext) IsAuthenticated() bool

func (*PluginContext) SetConnection

func (c *PluginContext) SetConnection(authContext *Connection)

func (*PluginContext) SetResourceContext

func (c *PluginContext) SetResourceContext(resourceContext *ResourceContext)

func (*PluginContext) SetSettingsProvider

func (c *PluginContext) SetSettingsProvider(provider settings.Provider)

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

type PluginType int

PluginType is the legacy integer enum for plugin capabilities. Deprecated: Use Capability instead.

const (
	ExecutorPlugin PluginType = iota
	FilesystemPlugin
	LogPlugin
	MetricPlugin
	ReporterPlugin
	ResourcePlugin
	SettingsPlugin
	NetworkerPlugin
	UIPlugin
)

func (PluginType) MarshalText

func (pt PluginType) MarshalText() ([]byte, error)

func (PluginType) String

func (pt PluginType) String() string

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

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.

Jump to

Keyboard shortcuts

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