Documentation
¶
Index ¶
- type Action
- type ActionTarget
- type ActionTargetBuilder
- type ActionVariant
- type CellAccessorPriority
- type CellAlignment
- type CellComponent
- type CellComponentStatusesParams
- type CellValueFormatter
- type ColorVariant
- type ColumnDef
- type CreateInformerFunc
- type CreateInput
- type CreateResult
- type DeleteInput
- type DeleteResult
- type DynamicResourcer
- type FindInput
- type FindResult
- type GetInput
- type GetResult
- type InformerAction
- type InformerAddPayload
- type InformerControllerAddPayload
- type InformerControllerDeletePayload
- type InformerControllerUpdatePayload
- type InformerDeletePayload
- type InformerOptions
- type InformerPayload
- type InformerUpdatePayload
- type LayoutItem
- type LayoutOpts
- type ListInput
- type ListResult
- 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 RegisterResourceInformerFunc
- type ResourceConnectionProvider
- type ResourceDefinition
- type ResourceGroup
- type ResourceInformerProvider
- type ResourceLayoutProvider
- type ResourceLink
- type ResourceMeta
- type ResourceOperationProvider
- type ResourceProvider
- type ResourceTypeProvider
- type Resourcer
- type RunInformerFunc
- type UpdateInput
- type UpdateResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
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 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 CreateInformerFunc ¶
type CreateInformerFunc[ClientT, InformerT any] func( ctx *pkgtypes.PluginContext, client *ClientT, ) (InformerT, error)
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 DynamicResourcer ¶
type DynamicResourcer[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) // Find 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) }
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"`
}
TODO - we should combine list and find results into a single action
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 InformerAction ¶
type InformerAction int
const ( // InformerTypeAdd is used to inform the IDE that a resource has been created. InformerActionAdd InformerAction = iota // InformerTypeUpdate is used to inform the IDE that a resource has been updated. InformerActionUpdate // InformerTypeDelete is used to inform the IDE that a resource has been deleted. InformerActionDelete )
type InformerAddPayload ¶
type InformerDeletePayload ¶
type InformerOptions ¶
type InformerOptions[ClientT, InformerT any] struct { // CreateInformerFunc is a function that should create a new informer base for a given resource connection. CreateInformerFunc CreateInformerFunc[ClientT, InformerT] // RegisterResourceInformerFunc is a function that should register an informer with a resource RegisterResourceFunc RegisterResourceInformerFunc[InformerT] // RunInformerFunc is a function that should run the informer, submitting events to the three // channels, and blocking until the stop channel is closed. RunInformerFunc RunInformerFunc[InformerT] }
InformerOptions defines the behavior for the integrating informers into a resource plugin..
type InformerPayload ¶
type InformerPayload interface {
InformerAddPayload | InformerUpdatePayload | InformerDeletePayload
}
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 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 RegisterResourceInformerFunc ¶
type RegisterResourceInformerFunc[InformerT any] func( ctx *pkgtypes.PluginContext, resource ResourceMeta, informer InformerT, addChan chan InformerAddPayload, updateChan chan InformerUpdatePayload, deleteChan chan InformerDeletePayload, ) 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
}
type ResourceDefinition ¶
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 {
// StartContextInformer signals the resource provider to start an informer for the given resource backend context
StartConnectionInformer(ctx *types.PluginContext, connectionID string) error
// StopContextInformer 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
ListenForEvents(
ctx *types.PluginContext,
addStream chan InformerAddPayload,
updateStream chan InformerUpdatePayload,
deleteStream chan InformerDeletePayload,
) error
// HasInformer checks to see if the informer manager has an informer for the given connection.
HasInformer(ctx *types.PluginContext, connectionID string) bool
}
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 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
}
ResourceProvider provides an interface for performing operations against a resource backend given a resource namespace and a resource identifier.
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, input GetInput) (*GetResult, error) // List returns a list of resources in the given resource namespace. List(ctx *plugin.PluginContext, client *ClientT, 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, input FindInput) (*FindResult, error) // Create creates a new resource in the given resource namespace. Create(ctx *plugin.PluginContext, client *ClientT, input CreateInput) (*CreateResult, error) // Update updates an existing resource in the given resource namespace. Update(ctx *plugin.PluginContext, client *ClientT, input UpdateInput) (*UpdateResult, error) // Delete deletes an existing resource in the given resource namespace. Delete(ctx *plugin.PluginContext, client *ClientT, 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.
type RunInformerFunc ¶
type RunInformerFunc[InformerT any] func( informer InformerT, stopCh chan struct{}, addChan chan InformerAddPayload, updateChan chan InformerUpdatePayload, deleteChan chan InformerDeletePayload, ) error
RunInformerFunc is a function that should run the informer, submitting events to the three channels, and blocking until the stop channel is closed.
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"`
}