Documentation
¶
Index ¶
- Variables
- type Action
- type ActionDescriptor
- type ActionEvent
- type ActionInput
- type ActionResourcer
- type ActionResult
- type ActionScope
- type ActionTarget
- type ActionTargetBuilder
- type ActionVariant
- type CellAccessorPriority
- type CellAlignment
- type CellComponent
- type CellComponentStatusesParams
- type CellValueFormatter
- type ColorVariant
- type ColumnDef
- type ConnectionControllerEvent
- type CreateInformerHandleFunc
- type CreateInput
- type CreateResult
- type DeleteInput
- type DeleteResult
- type DiscoveryProvider
- type EditorSchema
- type FindInput
- type FindResult
- type GetInput
- type GetResult
- type InformerAddPayload
- type InformerConnectionSummary
- type InformerDeletePayload
- type InformerHandle
- type InformerResourceState
- type InformerStateEvent
- type InformerSyncPolicy
- type InformerUpdatePayload
- type LayoutItem
- type LayoutOpts
- type ListInput
- type ListResult
- type NoOpActionProvider
- func (n NoOpActionProvider) ExecuteAction(_ *pkgtypes.PluginContext, _ string, _ string, _ ActionInput) (*ActionResult, error)
- func (n NoOpActionProvider) GetActions(_ *pkgtypes.PluginContext, _ string) ([]ActionDescriptor, error)
- func (n NoOpActionProvider) StreamAction(_ *pkgtypes.PluginContext, _ string, _ string, _ ActionInput, ...) error
- type OperationInput
- type OperationResult
- type OperationType
- type OrderParams
- type PaginationParams
- type PaginationResult
- type PostHook
- type PostHookFunc
- type PostHookType
- type PreHook
- type PreHookFunc
- type PreHookType
- type ResourceActionProvider
- type ResourceConnectionProvider
- type ResourceDefinition
- type ResourceErrorClassifier
- type ResourceGroup
- type ResourceInformerProvider
- type ResourceLayoutProvider
- type ResourceLink
- type ResourceMeta
- type ResourceOperationError
- type ResourceOperationProvider
- type ResourceProvider
- type ResourceSchemaProvider
- type ResourceTypeProvider
- type Resourcer
- type SchemaResourcer
- type UpdateInput
- type UpdateResult
Constants ¶
This section is empty.
Variables ¶
var ErrResourceSkipped = errors.New("resource skipped")
ErrResourceSkipped is returned by InformerHandle.RegisterResource when the resource should not be watched (e.g. ephemeral request-based resources). The InformerManager will mark such resources as Cancelled instead of Pending.
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action struct {
// Selectors are used to pass parameters to the action. If the ListBuilder
// is provided, these will be merged with the list actions, with the list
// action selectors taking precedence.
Selectors map[string]string `json:"selectors"`
// If the action can have multiple targets, this should be provided to signal
// to the ui to build a submenu for the action.
//
// An example of this could be executing a command on a Kubernetes pod, where
// the action needs to know which container (target) to execute the command on.
TargetBuilder []ActionTargetBuilder `json:"target_builders"`
ID string `json:"id"`
Icon string `json:"icon"`
Label string `json:"label"`
Description string `json:"description"`
Variant ActionVariant `json:"variant"`
Targets []ActionTarget `json:"targets"`
}
Action represents an action item that can be performed on a resource.
func ActionFromProto ¶
func ActionFromProto(p *proto.ResourceAction) Action
func (Action) ToProto ¶
func (a Action) ToProto() *proto.ResourceAction
type ActionDescriptor ¶
type ActionDescriptor struct {
ID string `json:"id"`
Label string `json:"label"`
Description string `json:"description"`
Icon string `json:"icon"`
Scope ActionScope `json:"scope"`
Streaming bool `json:"streaming"`
}
ActionDescriptor describes an available action on a resource type.
type ActionEvent ¶
type ActionEvent struct {
Type string `json:"type"` // "progress", "output", "error", "complete"
Data map[string]interface{} `json:"data"`
}
ActionEvent represents a streaming event from a long-running action.
type ActionInput ¶
type ActionInput struct {
ID string `json:"id"`
Namespace string `json:"namespace"`
Params map[string]interface{} `json:"params"`
}
ActionInput contains the parameters for executing an action.
type ActionResourcer ¶
type ActionResourcer[ClientT any] interface { GetActions(ctx *pkgtypes.PluginContext, client *ClientT, meta ResourceMeta) ([]ActionDescriptor, error) ExecuteAction(ctx *pkgtypes.PluginContext, client *ClientT, meta ResourceMeta, actionID string, input ActionInput) (*ActionResult, error) StreamAction(ctx *pkgtypes.PluginContext, client *ClientT, meta ResourceMeta, actionID string, input ActionInput, stream chan ActionEvent) error }
ActionResourcer is an optional interface that Resourcer implementations can satisfy to support custom actions beyond CRUD. The resourceController will type-assert to this interface when dispatching action requests.
type ActionResult ¶
type ActionResult struct {
Success bool `json:"success"`
Data map[string]interface{} `json:"data"`
Message string `json:"message"`
}
ActionResult contains the result of executing an action.
type ActionScope ¶
type ActionScope string
ActionScope defines whether an action operates on a specific resource instance or on the resource type as a whole.
const ( ActionScopeInstance ActionScope = "instance" ActionScopeType ActionScope = "type" )
type ActionTarget ¶
type ActionTarget struct {
// Selectors are used to pass parameters to the action.
// +optional
Selectors map[string]string `json:"selectors"`
// Label is the human-readable name of the target
Label string `json:"label"`
// Description is a short description of the target
// +optional
Description string `json:"description"`
// Icon is the icon to display for the target
// +optional
Icon string `json:"icon"`
}
ActionTarget represents static target for an action. This is used when an action can be performed on multiple targets, and the targets are known ahead of time, such as a reporting plugin that can perform multiple kinds of reports on a single resource.
func ActionTargetFromProto ¶
func ActionTargetFromProto(p *proto.ResourceActionTarget) ActionTarget
func (ActionTarget) String ¶
func (a ActionTarget) String() string
func (ActionTarget) ToProto ¶
func (a ActionTarget) ToProto() *proto.ResourceActionTarget
type ActionTargetBuilder ¶
type ActionTargetBuilder struct {
// Selectors are json path selectors to use on each item returned by Paths
// to get the parameters required for executing the action. Selectors
// should return a single string value.
//
// The selectors will be passed to the action via the parameters map.
Selectors map[string]string `json:"selectors"`
// LabelSelector represents which of the selectors should be used for the label
// displayed for the action. Overrides the static Label parameter if provided.
LabelSelector string `json:"label_selector"`
// Label respresents a static label for the action. If the label should be determined
// based on information about the target, use the LabelSelector instead.
Label string `json:"label"`
// Paths represents a json path selector to build the list of targets.
Paths []string `json:"paths"`
}
ActionTargetBuilder is used to build a list of targets for an action. This is used when an action can be performed on multiple targets, and the targets need to be built dynamically.
func ActionTargetBuilderFromProto ¶
func ActionTargetBuilderFromProto(p *proto.ResourceActionTargetBuilder) ActionTargetBuilder
func (ActionTargetBuilder) String ¶
func (a ActionTargetBuilder) String() string
func (ActionTargetBuilder) ToProto ¶
func (a ActionTargetBuilder) ToProto() *proto.ResourceActionTargetBuilder
type ActionVariant ¶
type ActionVariant string
const ( ActionVariantExec ActionVariant = "exec" ActionVariantLogs ActionVariant = "logs" ActionVariantCustom ActionVariant = "custom" )
func (ActionVariant) String ¶
func (a ActionVariant) String() string
func (ActionVariant) ToProto ¶
func (a ActionVariant) ToProto() proto.ResourceAction_Variant
type CellAccessorPriority ¶
type CellAccessorPriority string
const ( CellAccessorPriorityAll CellAccessorPriority = "ALL" CellAccessorPriorityFirst CellAccessorPriority = "FIRST" CellAccessorPriorityLast CellAccessorPriority = "LAST" )
func CellAccessorPriorityFromProto ¶
func CellAccessorPriorityFromProto(c proto.ColumnDef_AccessorPriority) CellAccessorPriority
func (CellAccessorPriority) ToProto ¶
func (c CellAccessorPriority) ToProto() *proto.ColumnDef_AccessorPriority
type CellAlignment ¶
type CellAlignment string
const ( CellAlignmentLeft CellAlignment = "LEFT" CellAlignmentCenter CellAlignment = "CENTER" CellAlignmentRight CellAlignment = "RIGHT" )
func (CellAlignment) ToProto ¶
func (c CellAlignment) ToProto() *proto.ColumnDef_Alignment
type CellComponent ¶
type CellComponent string
const ( CellComponentText CellComponent = "TEXT" CellComponentBadges CellComponent = "BADGES" CellComponentStatuses CellComponent = "STATUSES" )
type CellComponentStatusesParams ¶
type CellComponentStatusesParams struct {
// StatusAccessor
StatusAccessor string `json:"statusAccessor"`
// StatusMap
StatusMap map[string]ColorVariant `json:"statusMap"`
// HoverMenuComponent is an optional hover menu custom component that can be displayed
HoverMenuComponent string `json:"hoverMenuComponent"`
}
type CellValueFormatter ¶
type CellValueFormatter string
const ( CellValueFormatterNone CellValueFormatter = "NONE" CellValueFormatterBytes CellValueFormatter = "BYTES" CellValueFormatterDuration CellValueFormatter = "DURATION" CellValueFormatterPercent CellValueFormatter = "PERCENT" CellValueFormatterTime CellValueFormatter = "TIME" CellValueFormatterAge CellValueFormatter = "AGE" CellValueFormatterSum CellValueFormatter = "SUM" CellValueFormatterCount CellValueFormatter = "COUNT" CellValueFormatterAvg CellValueFormatter = "AVG" CellValueFormatterMax CellValueFormatter = "MAX" CellValueFormatterMin CellValueFormatter = "MIN" )
func (CellValueFormatter) ToProto ¶
func (c CellValueFormatter) ToProto() *proto.ColumnDef_Formatter
type ColorVariant ¶
type ColorVariant string
const ( ColorVariantPrimary ColorVariant = "primary" ColorVariantSecondary ColorVariant = "neutral" ColorVariantSuccess ColorVariant = "success" ColorVariantWarning ColorVariant = "warning" ColorVariantDanger ColorVariant = "danger" )
type ColumnDef ¶
type ColumnDef struct {
// ID defines the ID for the column
ID string `json:"id"`
// Header defines the header for the column
Header string `json:"header"`
// Accessors defines the accessors for the column. If multiple values must be
// displayed, they must be separated by a comma
Accessors string `json:"accessor"`
// AccessorPriority defines which value to return if multiple accessors are given, and there are multiple matches. If none is provided,
// all values will be returned as an array.
AccessorPriority CellAccessorPriority `json:"accessorPriority,omitempty"`
// Map defines the map for the cell contents to a color variant based on a value
ColorMap map[string]string `json:"colorMap,omitempty"`
// Color defines the color for the cell contents
Color ColorVariant `json:"color,omitempty"`
// Align defines the alignment for the column
// Default: left
Alignment CellAlignment `json:"align,omitempty"`
// Hidden defines whether the column is visible or not
Hidden bool `json:"hidden,omitempty"`
// Width defines the width for the column. If not provided, the column will
// be auto-sized.
Width int `json:"width,omitempty"`
// Formatter defines an optional value formatter to use for the column
Formatter CellValueFormatter `json:"formatter,omitempty"`
// Component defines an optional component to use for the cell. You can use one
// of the preset components or define your own.
//
// If not provided, the default 'text' component will be used.
Component string `json:"component,omitempty"`
// Component Params are used to pass additional parameters to the component
ComponentParams interface{} `json:"componentParams,omitempty"`
// ResourceLinks are used to create links to other resources.
ResourceLink *ResourceLink `json:"resourceLink,omitempty"`
// ValueMap is used to map a value to another value. The key should be a regular expression
// to run against the value to check if should be replaced by a static value.
//
// NOTE: Use this sparingly as it can be expensive to run regular expressions on every cell.
ValueMap map[string]string `json:"valueMap,omitempty"`
}
func ColumnDefFromProto ¶
type ConnectionControllerEvent ¶
type ConnectionControllerEvent struct {
PluginID string `json:"plugin_id"`
Connections []plugin.Connection `json:"connections"`
}
type CreateInformerHandleFunc ¶
type CreateInformerHandleFunc[ClientT any] func( ctx *pkgtypes.PluginContext, client *ClientT, ) (InformerHandle, error)
CreateInformerHandleFunc creates an InformerHandle for a given connection client.
type CreateInput ¶
type CreateInput struct {
// Params is used as an injectable field for any operations that require extra data
Params interface{} `json:"params"`
// Input is the input to the create operation.
Input map[string]interface{} `json:"input"`
// Namespace is an optional identifier to use when a resource backend supports
// a concept of partitioning resources (like with corev1.Namespace in Kubernetes)
Namespace string `json:"namespace"`
}
type CreateResult ¶
type DeleteInput ¶
type DeleteInput struct {
// Options is a set of arbitrary options to the delete operation that must be
// resolved by the Resourcer.
Input map[string]interface{} `json:"input"`
// Params is used as an injectable field for any operations that require extra data
Params map[string]interface{} `json:"params"`
// ID is the unique identifier of the resource to get.
ID string `json:"id"`
// Namespace is an optional identifier to use when a resource backend supports
// a concept of partitioning resources (like with corev1.Namespace in Kubernetes)
Namespace string `json:"namespace"`
}
type DeleteResult ¶
type DiscoveryProvider ¶
type DiscoveryProvider interface {
// Discover discovers the available resource types for the given connection.
Discover(ctx *pkgtypes.PluginContext, connection *pkgtypes.Connection) ([]ResourceMeta, error)
// RemoveConnection removes and cleans up any resources associated with the connection.
RemoveConnection(ctx *pkgtypes.PluginContext, connection *pkgtypes.Connection) error
}
DiscoveryProvider encapsulates the discovery client lifecycle and discovery logic. Implementations manage per-connection client creation, caching, and cleanup internally.
type EditorSchema ¶
type FindInput ¶
type FindInput struct {
// Params is used as an injectable field for any operations that require extra data
Params map[string]interface{} `json:"params"`
// Conditions is a an object of conditions to filter the list of resources by, specific
// to the resource backend.
//
// Implementations should support a set of common conditions, such as
// "name", "label", etc.
Conditions map[string]interface{} `json:"conditions"`
// Namespaces is an optional list of namespace identifiers to use when a resource backend
// supports a concept of partitioning resources (like with corev1.Namespace in Kubernetes).
//
// For consisitency, the implemented behavior when this is not specified should be to
// list all resources in all partitions.
Namespaces []string `json:"namespaces"`
// Order is the order parameters for the list operation.
Order OrderParams `json:"order"`
// Pagination is the pagination parameters for the list operation.
Pagination PaginationParams `json:"pagination"`
}
type FindResult ¶
type FindResult struct {
// Result is the result of the operation, as a map of resources from the
// operation by their ID.
//
// Due to limitations with method bindings with Wails v2, this needs to
// be a map of resources by their ID instead of an array.
Result []map[string]interface{} `json:"result"`
// Success is a flag that indicates if the operation was successful.
Success bool `json:"success"`
// Pagination is the pagination result of the list operation.
Pagination PaginationResult `json:"pagination"`
}
type GetInput ¶
type GetInput struct {
// Params is used as an injectable field for any operations that require extra data
Params map[string]interface{} `json:"params"`
// ID is the unique identifier of the resource to get.
ID string `json:"id"`
// Namespace is an optional identifier to use when a resource backend supports
// a concept of partitioning resources (like with corev1.Namespace in Kubernetes)
Namespace string `json:"namespace"`
}
ResourcerGetInput is the input to the Get operation of a Resourcer.
type InformerAddPayload ¶
type InformerConnectionSummary ¶
type InformerConnectionSummary struct {
Connection string `json:"connection"`
Resources map[string]InformerResourceState `json:"resources"`
ResourceCounts map[string]int `json:"resourceCounts"`
TotalResources int `json:"totalResources"`
SyncedCount int `json:"syncedCount"`
ErrorCount int `json:"errorCount"`
}
InformerConnectionSummary provides an aggregate view of all informer states for a connection.
type InformerDeletePayload ¶
type InformerHandle ¶
type InformerHandle interface {
// RegisterResource registers a resource with the informer, setting up event handlers
// that push events to the provided channels. syncPolicy tells the handle whether
// this resource should start immediately on Start() or be deferred.
RegisterResource(
ctx *pkgtypes.PluginContext,
resource ResourceMeta,
syncPolicy InformerSyncPolicy,
addChan chan InformerAddPayload,
updateChan chan InformerUpdatePayload,
deleteChan chan InformerDeletePayload,
) error
// Start starts all OnConnect informers. Reports state changes via stateChan.
// Blocks until stopCh is closed or context is cancelled.
Start(
ctx context.Context,
stopCh chan struct{},
stateChan chan<- InformerStateEvent,
) error
// StartResource starts the informer for a specific resource (used for OnFirstQuery policy).
StartResource(
ctx context.Context,
resource ResourceMeta,
stateChan chan<- InformerStateEvent,
) error
// Stop gracefully stops all informers.
Stop()
}
InformerHandle is a non-generic interface that encapsulates an informer instance. Implementations manage resource registration and running the informer loop internally.
type InformerResourceState ¶
type InformerResourceState int
InformerResourceState represents the sync state of a single resource type's informer.
const ( // InformerStatePending means the resource is registered but informer not started. InformerStatePending InformerResourceState = iota // InformerStateSyncing means the informer is running but cache not yet populated. InformerStateSyncing // InformerStateSynced means the cache is fully populated. InformerStateSynced // InformerStateError means an error occurred during sync. InformerStateError // InformerStateCancelled means the informer was cancelled by context or user. InformerStateCancelled )
type InformerStateEvent ¶
type InformerStateEvent struct {
PluginID string `json:"pluginId"`
Connection string `json:"connection"`
ResourceKey string `json:"resourceKey"`
State InformerResourceState `json:"state"`
ResourceCount int `json:"resourceCount"`
TotalCount int `json:"totalCount"` // -1 if unknown
Error *ResourceOperationError `json:"error,omitempty"`
}
InformerStateEvent is emitted when a resource's informer state changes.
type InformerSyncPolicy ¶
type InformerSyncPolicy int
InformerSyncPolicy controls when an informer starts for a resource type.
const ( // SyncOnConnect starts the informer when the connection opens (default). SyncOnConnect InformerSyncPolicy = iota // SyncOnFirstQuery starts the informer on the first Get/List/Find for this resource. SyncOnFirstQuery // SyncNever never starts an informer; always uses direct queries. SyncNever )
type InformerUpdatePayload ¶
type LayoutItem ¶
type LayoutItem struct {
// Unique identifier for the layout item. If this does not have children,
// this will be the ID of the layout item.
ID string `json:"id"`
// Display label for the layout item
Label string `json:"title"`
// Optional icon for the layout item
Icon string `json:"icon"`
// Optional description for the layout item
Description string `json:"description"`
// Optional nested children for the layout items
Items []LayoutItem `json:"items"`
}
type LayoutOpts ¶
type LayoutOpts struct {
Layouts map[string][]LayoutItem
DefaultLayout string
}
type ListInput ¶
type ListInput struct {
// Params is used as an injectable field for any operations that require extra data
Params map[string]interface{} `json:"params"`
// Namespaces is an optional list of namespace identifiers to use when a resource backend
// supports a concept of partitioning resources (like with corev1.Namespace in Kubernetes).
//
// For consisitency, the implemented behavior when this is not specified should be to
// list all resources in all partitions.
Namespaces []string `json:"namespaces"`
// Order is the order parameters for the list operation.
Order OrderParams `json:"order"`
// Pagination is the pagination parameters for the list operation.
Pagination PaginationParams `json:"pagination"`
}
ResourcerListInput is the input to the List operation of a Resourcer.
type ListResult ¶
type ListResult struct {
// Result is the result of the operation, as a map of resources from the
// operation by their ID.
//
// Due to limitations with method bindings with Wails v2, this needs to
// be a map of resources by their ID instead of an array.
Result []map[string]interface{} `json:"result"`
// Success is a flag that indicates if the operation was successful.
Success bool `json:"success"`
// Pagination is the pagination result of the list operation.
Pagination PaginationResult `json:"pagination"`
}
type NoOpActionProvider ¶
type NoOpActionProvider struct{}
NoOpActionProvider provides a default no-op implementation of ResourceActionProvider for plugins that don't support actions.
func (NoOpActionProvider) ExecuteAction ¶
func (n NoOpActionProvider) ExecuteAction(_ *pkgtypes.PluginContext, _ string, _ string, _ ActionInput) (*ActionResult, error)
func (NoOpActionProvider) GetActions ¶
func (n NoOpActionProvider) GetActions(_ *pkgtypes.PluginContext, _ string) ([]ActionDescriptor, error)
func (NoOpActionProvider) StreamAction ¶
func (n NoOpActionProvider) StreamAction(_ *pkgtypes.PluginContext, _ string, _ string, _ ActionInput, _ chan ActionEvent) error
type OperationInput ¶
type OperationInput interface {
GetInput | ListInput | FindInput | CreateInput | UpdateInput | DeleteInput
}
type OperationResult ¶
type OperationResult interface {
GetResult | ListResult | FindResult | CreateResult | UpdateResult | DeleteResult
}
type OperationType ¶
type OperationType int
const ( // GetOperation is the operation type for a get operation. OperationTypeGet OperationType = iota OperationTypeList OperationTypeFind OperationTypeCreate OperationTypeUpdate OperationTypeDelete )
type OrderParams ¶
type PaginationParams ¶
type PaginationResult ¶
type PaginationResult struct {
PaginationParams
// Total is the total number of resources in the list.
Total int `json:"total"`
// TotalPages is the total number of pages in the list.
Pages int `json:"pages"`
}
type PostHook ¶
type PostHook[R OperationResult] struct { // Execute is the function that should be run when the hook is executed. The input to the // function will always be an interface representing a pointer to the output of the operation. Execute PostHookFunc[R] // ID is the unique identifier of the operation. ID string // Owner represents the resource type that the hook is associated with. This will be the name // of the plugin that registered the hook. Owner string // Selectors is a list of resource selectors that should define for which resources a hook // should run. Selectors should be defined in the following format: // <resource-type>.<resource-name>.<resource-namespace> Selectors []string // HookType is the type of hook that this is. HookType PostHookType }
PostHook is a hook that runs on output lifecycle events of a resource operation.
type PostHookFunc ¶
type PostHookFunc[I OperationResult] func(*I) error
PostHookFunc is a function that runs on output lifecycle events of a resource operation, and is provided an interface representing a pointer to the output of the operation.
type PostHookType ¶
type PostHookType int
PostHookType defines a hook that runs on output lifecycle events of a resource operation.
const ( // AfterOperation runs after the operation is sent to the backend. It runs after the // operation is sent to the backend, and before the PostValidation and PostMutation hooks. AfterOperation PostHookType = iota // PostValidation runs a validation on the output after it is sent back from the backend. // It runs after the AfterOperation hook, and before the PostMutation hook. PostValidation // PostMutation runs a mutation on the output after it is sent back from the backend. It runs // as the last hook in the lifecycle. PostMutation )
type PreHook ¶
type PreHook[I OperationInput] struct { // Execute is the function that should be run when the hook is executed. The input to the // function will always be an interface representing a pointer to the input of the operation. Execute PreHookFunc[I] // ID is the unique identifier of the operation. ID string // Owner represents the resource type that the hook is associated with. This will be the name // of the plugin that registered the hook. Owner string // Selectors is a list of resource selectors that should define for which resources a hook // should run. Selectors should be defined in the following format: // <resource-type>.<resource-name>.<resource-namespace> // // While wildcard selectors were considered, they were not implemented due to the potential // for abuse and the requirements of needed to use reflectors Selectors []string // HookType is the type of hook that this is. HookType PreHookType }
PreHook is a hook that runs on input lifecycle events of a resource operation.
type PreHookFunc ¶
type PreHookFunc[I OperationInput] func(*I) error
PreHookFunc is a function that runs on input lifecycle events of a resource operation, and is provided an interface representing a pointer to the input of the operation.
type PreHookType ¶
type PreHookType int
PreHookType defines a hook that runs on input lifecycle events of a resource operation.
const ( // PreMutatation runs a mutation on the input before it is sent to the backend. It runs // as the first hook in the lifecycle. PreMutatation PreHookType = iota // PreValidation runs a validation on the input before it is sent to the backend. It runs // after the PreMutation hook, and before the BeforeOperation hook. PreValidation // BeforeOperation runs before the operation is sent to the backend. It runs after the // PreMutation and PreValidation hooks. BeforeOperation )
type ResourceActionProvider ¶
type ResourceActionProvider interface {
// GetActions returns available actions for a resource type
GetActions(ctx *types.PluginContext, key string) ([]ActionDescriptor, error)
// ExecuteAction executes a named action and returns result
ExecuteAction(ctx *types.PluginContext, key string, actionID string, input ActionInput) (*ActionResult, error)
// StreamAction executes a streaming action, sending events on the channel
StreamAction(ctx *types.PluginContext, key string, actionID string, input ActionInput, stream chan ActionEvent) error
}
type ResourceConnectionProvider ¶
type ResourceConnectionProvider interface {
// StartConnection starts a connection for the resource provider and begins signalling
// the resource provider to start syncing resources
StartConnection(ctx *types.PluginContext, connectionID string) (types.ConnectionStatus, error)
// StopConnection stops a connection for the resource provider and stops signalling
// the resource provider to stop syncing resources
StopConnection(ctx *types.PluginContext, connectionID string) (types.Connection, error)
// LoadConnections loads the connections for the resource provider
LoadConnections(ctx *types.PluginContext) ([]types.Connection, error)
// ListConnections lists the connections for the resource provider
ListConnections(ctx *types.PluginContext) ([]types.Connection, error)
// GetConnection gets a connection for the resource provider
GetConnection(ctx *types.PluginContext, id string) (types.Connection, error)
// GetConnectionNamespaces gets a list of namespaces within the connection (if the resource provider supports namespaces)
GetConnectionNamespaces(ctx *types.PluginContext, id string) ([]string, error)
// UpdateConnection updates the connection for the resource provider
UpdateConnection(
ctx *types.PluginContext,
connection types.Connection,
) (types.Connection, error)
// DeleteConnection deletes the connection for the resource provider
DeleteConnection(ctx *types.PluginContext, id string) error
// WatchConnections will call the watcher function if it exists, returning the list of connections as things change
WatchConnections(ctx *types.PluginContext, stream chan []types.Connection) error
}
type ResourceDefinition ¶
type ResourceDefinition struct {
IDAccessor string `json:"id_accessor"`
NamespaceAccessor string `json:"namespace_accessor"`
MemoizerAccessor string `json:"memoizer_accessor"`
ColumnDefs []ColumnDef `json:"columnDefs"`
SupportedOperations []OperationType `json:"supportedOperations,omitempty"`
}
type ResourceErrorClassifier ¶
ResourceErrorClassifier is an optional interface that ResourceProvider implementations can satisfy to classify raw errors into structured ResourceOperationError values. The gRPC server checks for this interface before falling back to a generic INTERNAL error.
type ResourceGroup ¶
type ResourceGroup struct {
// ID is the unique identifier of the resource group
ID string `json:"id"`
// Name is the name of the resource group
Name string `json:"name"`
// Description is the description of the resource group
Description string `json:"description"`
// Icon is an optional icon for the resource group. This can be either an icon name from the react-icons package,
// a data uri string, or a URL to the icon.
Icon string `json:"icon"`
// Resources is a map of resource versions to the resources in that version.
Resources map[string][]ResourceMeta `json:"resources"`
}
ResourceGroup is a categorization of resources within a plugin. The only property required is the ID, but it is highly recommended to provide a name and description for the UI.
type ResourceInformerProvider ¶
type ResourceInformerProvider interface {
// StartConnectionInformer signals the resource provider to start an informer for the given resource backend context
StartConnectionInformer(ctx *types.PluginContext, connectionID string) error
// StopConnectionInformer signals the resource provider to stop an informer for the given resource backend context
StopConnectionInformer(ctx *types.PluginContext, connectionID string) error
// ListenForEvents registers a listener for resource events including state changes
ListenForEvents(
ctx *types.PluginContext,
addStream chan InformerAddPayload,
updateStream chan InformerUpdatePayload,
deleteStream chan InformerDeletePayload,
stateStream chan InformerStateEvent,
) error
// HasInformer checks to see if the informer manager has an informer for the given connection.
HasInformer(ctx *types.PluginContext, connectionID string) bool
// GetInformerState returns a snapshot of all resource informer states for a connection.
GetInformerState(ctx *types.PluginContext, connectionID string) (*InformerConnectionSummary, error)
// EnsureInformerForResource triggers lazy start for SyncOnFirstQuery resources.
EnsureInformerForResource(ctx *types.PluginContext, connectionID string, resourceKey string) error
}
type ResourceLayoutProvider ¶
type ResourceLayoutProvider interface {
GetLayout(id string) ([]LayoutItem, error)
SetLayout(id string, layout []LayoutItem) error
GetDefaultLayout() ([]LayoutItem, error)
}
type ResourceLink ¶
type ResourceLink struct {
// Accessor to extract the ID of the linked resource.
IDAccessor string `json:"idAccessor"`
// NamespaceAccessor is the accessor for determining which resource namespace the resource is in.
// If not specified, defaults to the same namespace (if the backend supports it)
NamespaceAccessor string `json:"namespaceAccessor"`
// Namespaced is used to determine if the resource is namespaced or not. If not specified, defaults to true.
Namespaced bool `json:"namespaced"`
// Key can be supplied if the key is already known ahead of time, and doesn't need to derived from an accessor
Key string `json:"resourceKey"`
// KeyAccessor is the accessor for determining the key of the resource.
KeyAccessor string `json:"keyAccessor"`
// KeyMap is an optional map that can be used with the key accessor to determine the resource
// ID based on what is returned from the accessor
KeyMap map[string]string `json:"keyMap"`
// DetailExtractors is an optional map of accessors that can extract information about a resource link
// into a popout modal. Each key should be a direct object accessor or a jsonpath expression.
DetailExtractors map[string]string `json:"detailExtractors"`
// DisplayID will display the ID instead of the kind if enabled
DisplayID bool `json:"displayId"`
}
ResourceLink is used to create links to other resources.
func ResourceLinkFromProto ¶
func ResourceLinkFromProto(rl *proto.ResourceLink) *ResourceLink
func (*ResourceLink) ToProto ¶
func (rl *ResourceLink) ToProto() *proto.ResourceLink
type ResourceMeta ¶
type ResourceMeta struct {
// Group is the group of the resource. This is required for all resources.
//
// Some examples for groups include:
// - Kubernetes Plugin: "core", "apps", "batch", "extensions"
// - AWS Plugin: "ec2", "s3", "rds"
// - GCP Plugin: "compute", "storage", "sql"
// - Azure Plugin: "compute", "storage", "sql"
Group string `json:"group"`
// Version is the version of the resource. This is required for all resources.
// If the resource does not have a version, use "v1".
//
// Some examples for versions include:
// - Kubernetes Plugin: "v1", "v1beta1", "v1beta2"
// - AWS Plugin: "2012-12-01", "2016-11-15"
Version string `json:"version"`
// Kind is the kind of the resource. This is required for all resources.
//
// Some examples for kinds include:
// - Kubernetes Plugin: "Pod", "Service", "Deployment"
// - AWS Plugin: "EC2Instance", "S3Bucket", "RDSInstance"
// - GCP Plugin: "ComputeEngineInstance", "StorageBucket", "SQLInstance"
// - Azure Plugin: "VirtualMachine", "StorageAccount", "SQLDatabase"
Kind string `json:"kind"`
// Label is a human-readable label of the resource. This is optional, and if not provided, the label will
// be set to the kind of the resource.
Label string `json:"label"`
// Icon is an optional icon for the resource. This can be either an icon name from the react-icons package,
// a data uri string, or a URL to the icon.
Icon string `json:"icon"`
// Description is a human-readable description of the resource. This is required for all resources.
//
// Some examples for descriptions include:
// - Kubernetes Plugin: "A pod represents a set of running containers in your cluster"
// - AWS Plugin: "An EC2 instance is a virtual server in the AWS cloud"
// - GCP Plugin: "A Compute Engine instance is a virtual machine that runs on Google's infrastructure"
// - Azure Plugin: "A virtual machine is a computer that runs on Microsoft's infrastructure"
Description string `json:"description"`
// Category is the category of the resource. This is optional, and if not provided, the category will
// be set to "Uncategorized". It is highly recommended to provide a category for your resources, so that
// they can be easily found by other plugin developers.
//
// Some examples for categories include:
// - Kubernetes Plugin: "Workloads", "Networking", "Storage"
// - AWS Plugin: "Compute", "Storage", "Database"
// - GCP Plugin: "Compute", "Storage", "Database"
// - Azure Plugin: "Compute", "Storage", "Database"
Category string `json:"category"`
}
ResourceMeta contains information about the categorization of a resource within a specific plugin. This information is used to categorize resources within the IDE and provide a consistent interface for plugins and the core IDE to interact with resources of different types. Coming from different plugins.
Each resource plugin must implement the resource manager interface, which uses the ResourceMeta to determine which resourcer to use for a given resource. As such, you should use the ResourceMeta to categorize resources in a way that both makes sense to the manager, as well as to other plugin developers who may want to use your plugin.
func ResourceMetaFromString ¶
func ResourceMetaFromString(s string) ResourceMeta
func (ResourceMeta) GetCategory ¶
func (r ResourceMeta) GetCategory() string
GetCategory returns the category of the resource.
func (ResourceMeta) GetDescription ¶
func (r ResourceMeta) GetDescription() string
GetDescription returns the description of the resource.
func (ResourceMeta) GetGroup ¶
func (r ResourceMeta) GetGroup() string
GetGroup returns the group of the resource For example, "core" or "ec2".
func (ResourceMeta) GetKind ¶
func (r ResourceMeta) GetKind() string
GetKind returns the kind of the resource.
func (ResourceMeta) GetVersion ¶
func (r ResourceMeta) GetVersion() string
GetVersion returns the version of the resource For example, "v1" or "2012-12-01".
func (ResourceMeta) String ¶
func (r ResourceMeta) String() string
String returns the string representation of the ResourceMeta in the format "group::version::kind" For example, "core::v1::Pod" or "ec2::2012-12-01::EC2Instance".
type ResourceOperationError ¶
type ResourceOperationError struct {
Err error `json:"-"` // underlying error (not serialized)
Code string `json:"code"` // standard code: NOT_FOUND, FORBIDDEN, etc.
Title string `json:"title"` // human-readable title
Message string `json:"message"` // detailed error message
Suggestions []string `json:"suggestions,omitempty"` // user-facing suggestions
}
ResourceOperationError is a structured error for resource CRUD operations. Its Error() method returns a JSON string so that the error survives the Wails boundary (which flattens Go errors to plain JS strings) and can be parsed by the frontend into structured fields for generic rendering.
func (*ResourceOperationError) Error ¶
func (e *ResourceOperationError) Error() string
Error returns a JSON-encoded representation so the structured fields survive the Wails IPC boundary (Wails calls .Error() and sends the string).
func (*ResourceOperationError) Unwrap ¶
func (e *ResourceOperationError) Unwrap() error
Unwrap returns the underlying error for use with errors.Is / errors.As.
type ResourceOperationProvider ¶
type ResourceOperationProvider interface {
// Get returns a single resource in the given resource namespace.
Get(ctx *types.PluginContext, key string, input GetInput) (*GetResult, error)
// Get returns a single resource in the given resource namespace.
List(ctx *types.PluginContext, key string, input ListInput) (*ListResult, error)
// FindResources returns a list of resources in the given resource namespace that
// match a set of given options.
Find(ctx *types.PluginContext, key string, input FindInput) (*FindResult, error)
// Create creates a new resource in the given resource namespace.
Create(
ctx *types.PluginContext,
key string,
input CreateInput,
) (*CreateResult, error)
// Update updates an existing resource in the given resource namespace.
Update(
ctx *types.PluginContext,
key string,
input UpdateInput,
) (*UpdateResult, error)
// Delete deletes an existing resource in the given resource namespace.
Delete(
ctx *types.PluginContext,
key string,
input DeleteInput,
) (*DeleteResult, error)
}
type ResourceProvider ¶
type ResourceProvider interface {
ResourceTypeProvider
ResourceConnectionProvider
ResourceInformerProvider
ResourceLayoutProvider
ResourceOperationProvider
ResourceActionProvider
ResourceSchemaProvider
}
ResourceProvider provides an interface for performing operations against a resource backend given a resource namespace and a resource identifier.
type ResourceSchemaProvider ¶
type ResourceSchemaProvider interface {
GetEditorSchemas(ctx *types.PluginContext, connectionID string) ([]EditorSchema, error)
}
type ResourceTypeProvider ¶
type ResourceTypeProvider interface {
// GetResourceGroups returns the available groups
GetResourceGroups(conn string) map[string]ResourceGroup
// GetResourceGroup returns a group by name
GetResourceGroup(string) (ResourceGroup, error)
// GetResourceTypes returns the all of the available resource types for the resource manager
GetResourceTypes(conn string) map[string]ResourceMeta
// GetResourceType returns the resource type information by it's string representation
// For example, "core::v1::Pod" or "ec2::2012-12-01::EC2Instance"
GetResourceType(string) (*ResourceMeta, error)
// HasResourceType checks to see if the resource type exists
HasResourceType(string) bool
// GetResourceDefinition returns the resource definitions for the resource provider
// based on the resource type
GetResourceDefinition(string) (ResourceDefinition, error)
}
type Resourcer ¶
type Resourcer[ClientT any] interface { // Get returns a single resource in the given resource namespace. Get(ctx *plugin.PluginContext, client *ClientT, meta ResourceMeta, input GetInput) (*GetResult, error) // List returns a list of resources in the given resource namespace. List(ctx *plugin.PluginContext, client *ClientT, meta ResourceMeta, input ListInput) (*ListResult, error) // FindResources returns a list of resources in the given resource namespace that // match a set of given options. // // Due to the dynamic nature of the options, the options are passed as an interface // and the Resourcer is responsible for casting the options to the correct type. Find(ctx *plugin.PluginContext, client *ClientT, meta ResourceMeta, input FindInput) (*FindResult, error) // Create creates a new resource in the given resource namespace. Create(ctx *plugin.PluginContext, client *ClientT, meta ResourceMeta, input CreateInput) (*CreateResult, error) // Update updates an existing resource in the given resource namespace. Update(ctx *plugin.PluginContext, client *ClientT, meta ResourceMeta, input UpdateInput) (*UpdateResult, error) // Delete deletes an existing resource in the given resource namespace. Delete(ctx *plugin.PluginContext, client *ClientT, meta ResourceMeta, input DeleteInput) (*DeleteResult, error) }
Resourcer is an interface that all resources must implement in order to be registered with the plugin system and the resource manager.
Resourcers are responsibile for for the business logic of listing, creating, updating, and deleting resources in a resource backend. Each resource type should have its own Resourcer implementation that knows how to interact with the backend for that resource type. Operations here are resource-namespace agnostic, and will be provided a client scoped to a resource namesspace from the resource manager when they are invoked.
Some resources may have additional functionality, such as with the Kubernetes client, which allows the setup of an informer (also used in the informer) of which the Resourcer uses a shared client. As such, Resourcers should be written agnostic of the underlying resource client, and should be able to be used with any resource client that implements the ResourceClient interface.
For example, the Kubernetes plugin defines a Resourcer for each GroupVersionKind that it supports, such as core.v1.Pod, core.v1.Service, etc. Each of these Resourcers knows how to interact with the Kubernetes API server for that resource type.
Static resourcers (bound to one type at registration) may ignore the ResourceMeta parameter. Pattern resourcers (registered with wildcard patterns) use it to determine the concrete resource being operated on.
type SchemaResourcer ¶
type SchemaResourcer[ClientT any] interface { GetEditorSchemas(ctx *types.PluginContext, client *ClientT, meta ResourceMeta) ([]EditorSchema, error) }
SchemaResourcer is an optional interface that Resourcer implementations can satisfy to provide JSON/YAML schemas for their resource types. The resourceController will type-assert to this interface when fetching schemas for a connection.
type UpdateInput ¶
type UpdateInput struct {
// Options is a set of arbitrary options to the delete operation that must be
// resolved by the Resourcer.
Input map[string]interface{} `json:"input"`
// Params is used as an injectable field for any operations that require extra data
Params map[string]interface{} `json:"params"`
// ID is the unique identifier of the resource to update.
ID string `json:"id"`
// Namespace is an optional identifier to use when a resource backend supports
// a concept of partitioning resources (like with corev1.Namespace in Kubernetes)
Namespace string `json:"namespace"`
}