resource

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StoreName  = "connections"
	PluginName = "resource"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

I HATE THIS. WHY CAN'T I JUST USE THE SAME INSTANCE?????

func NewClient

func NewClient(controller Controller) *Client

func (*Client) AddConnection

func (c *Client) AddConnection(pluginID string, connection types.Connection) error

func (*Client) Create

func (c *Client) Create(
	pluginID, connectionID, key string,
	input rt.CreateInput,
) (*rt.CreateResult, error)

func (*Client) Delete

func (c *Client) Delete(
	pluginID, connectionID, key string,
	input rt.DeleteInput,
) (*rt.DeleteResult, error)

func (*Client) EnsureInformerForResource

func (c *Client) EnsureInformerForResource(pluginID, connectionID, resourceKey string) error

func (*Client) ExecuteAction

func (c *Client) ExecuteAction(
	pluginID, connectionID, key, actionID string,
	input rt.ActionInput,
) (*rt.ActionResult, error)

func (*Client) Find

func (c *Client) Find(
	pluginID, connectionID, key string,
	input rt.FindInput,
) (*rt.FindResult, error)

func (*Client) Get

func (c *Client) Get(
	pluginID, connectionID, key string,
	input rt.GetInput,
) (*rt.GetResult, error)

func (*Client) GetActions

func (c *Client) GetActions(pluginID, connectionID, key string) ([]rt.ActionDescriptor, error)

func (*Client) GetConnection

func (c *Client) GetConnection(pluginID, connectionID string) (types.Connection, error)

func (*Client) GetConnectionNamespaces

func (c *Client) GetConnectionNamespaces(pluginID, connectionID string) ([]string, error)

func (*Client) GetDefaultLayout

func (c *Client) GetDefaultLayout(pluginID string) ([]rt.LayoutItem, error)

func (*Client) GetEditorSchemas

func (c *Client) GetEditorSchemas(pluginID, connectionID string) ([]rt.EditorSchema, error)

func (*Client) GetInformerState

func (c *Client) GetInformerState(pluginID, connectionID string) (*rt.InformerConnectionSummary, error)

func (*Client) GetLayout

func (c *Client) GetLayout(pluginID string, layoutID string) ([]rt.LayoutItem, error)

func (*Client) GetResourceDefinition

func (c *Client) GetResourceDefinition(pluginID, typeID string) (rt.ResourceDefinition, error)

func (*Client) GetResourceGroup

func (c *Client) GetResourceGroup(pluginID, groupID string) (rt.ResourceGroup, error)

func (*Client) GetResourceGroups

func (c *Client) GetResourceGroups(pluginID, connectionID string) map[string]rt.ResourceGroup

func (*Client) GetResourceType

func (c *Client) GetResourceType(pluginID, typeID string) (*rt.ResourceMeta, error)

func (*Client) GetResourceTypes

func (c *Client) GetResourceTypes(pluginID, connectionID string) map[string]rt.ResourceMeta

func (*Client) HasResourceType

func (c *Client) HasResourceType(pluginID, typeID string) bool

func (*Client) List

func (c *Client) List(
	pluginID, connectionID, key string,
	input rt.ListInput,
) (*rt.ListResult, error)

func (*Client) ListAllConnections

func (c *Client) ListAllConnections() (map[string][]types.Connection, error)

func (*Client) ListConnections

func (c *Client) ListConnections(pluginID string) ([]types.Connection, error)

func (*Client) ListPlugins

func (c *Client) ListPlugins() ([]string, error)

func (*Client) LoadConnections

func (c *Client) LoadConnections(pluginID string) ([]types.Connection, error)

func (*Client) RemoveConnection

func (c *Client) RemoveConnection(pluginID, connectionID string) error

func (*Client) SetLayout

func (c *Client) SetLayout(pluginID string, layoutID string, layout []rt.LayoutItem) error

func (*Client) StartConnection

func (c *Client) StartConnection(pluginID, connectionID string) (types.ConnectionStatus, error)

func (*Client) StartConnectionInformer

func (c *Client) StartConnectionInformer(pluginID, connectionID string) error

func (*Client) StopConnection

func (c *Client) StopConnection(pluginID, connectionID string) (types.Connection, error)

func (*Client) StopConnectionInformer

func (c *Client) StopConnectionInformer(pluginID, connectionID string) error

func (*Client) StreamAction

func (c *Client) StreamAction(
	pluginID, connectionID, key, actionID string,
	input rt.ActionInput,
) (string, error)

func (*Client) Update

func (c *Client) Update(
	pluginID, connectionID, key string,
	input rt.UpdateInput,
) (*rt.UpdateResult, error)

func (*Client) UpdateConnection

func (c *Client) UpdateConnection(
	pluginID string,
	connection types.Connection,
) (types.Connection, error)

type Controller

type Controller interface {
	internaltypes.ConnectedController
	IClient
	// SetCrashCallback sets the function called when a plugin crash is detected.
	SetCrashCallback(cb func(pluginID string))
}

Controller is a controller that manages the lifecycle of resource plugins. Resource plugins interact with a backend that supplies various entities that can be read, created, updated, and deleted.

Has to satisfy both the internal connected controller type, as well as the external client type.

func NewController

func NewController(logger *zap.SugaredLogger, sp pkgsettings.Provider) Controller

NewController returns a new Controller instance.

type IClient

type IClient interface {
	// ListPlugins returns a list of all the plugins that are registered with the resource controller
	ListPlugins() ([]string, error)

	// Get performs a get requests for a resource against a resource backend plugin.
	// The pluginID should match the name of the plugin in the plugin metadata.
	Get(pluginID, connectionID, key string, input rt.GetInput) (*rt.GetResult, error)

	// List performs a list requests for a resource against a resource backend plugin.
	// The pluginID should match the name of the plugin in the plugin metadata.
	List(pluginID, connectionID, key string, input rt.ListInput) (*rt.ListResult, error)

	// Find performs a find requests for a resource against a resource backend plugin.
	// The pluginID should match the name of the plugin in the plugin metadata.
	Find(pluginID, connectionID, key string, input rt.FindInput) (*rt.FindResult, error)

	// Create performs a create requests for a resource against a resource backend plugin.
	// The pluginID should match the name of the plugin in the plugin metadata.
	Create(pluginID, connectionID, key string, input rt.CreateInput) (*rt.CreateResult, error)

	// Update performs a update requests for a resource against a resource backend plugin.
	// The pluginID should match the name of the plugin in the plugin metadata.
	Update(pluginID, connectionID, key string, input rt.UpdateInput) (*rt.UpdateResult, error)

	// Delete performs a delete requests for a resource against a resource backend plugin.
	// The pluginID should match the name of the plugin in the plugin metadata.
	Delete(pluginID, connectionID, key string, input rt.DeleteInput) (*rt.DeleteResult, error)

	// StartConnection starts a connection for a plugin
	StartConnection(pluginID, connectionID string) (types.ConnectionStatus, error)

	// StopConnection stops a connection for a plugin
	StopConnection(pluginID, connectionID string) (types.Connection, error)

	// LoadConnections loads the connections for the resource provider
	LoadConnections(pluginID string) ([]types.Connection, error)

	// ListConnections returns a list of connections for the plugin.
	// The pluginID should match the name of the plugin in the plugin metadata.
	ListConnections(pluginID string) ([]types.Connection, error)

	// GetConnection returns a connection for the plugin.
	// The pluginID should match the name of the plugin in the plugin metadata.
	GetConnection(pluginID, connectionID string) (types.Connection, error)

	// GetConnectionNamespaces returns a list of connection namespaces for a plugin.
	GetConnectionNamespaces(pluginID, connectionID string) ([]string, error)

	// AddConnection adds a new connection for the plugin.
	// The pluginID should match the name of the plugin in the plugin metadata.
	AddConnection(pluginID string, connection types.Connection) error

	// UpdateConnection updates an existing connection for a plugin
	// The pluginID should match the name of the plugin in the plugin metadata.
	UpdateConnection(pluginID string, connection types.Connection) (types.Connection, error)

	// RemoveConnection removes a connection for a plugin
	// The pluginID should match the name of the plugin in the plugin metadata.
	RemoveConnection(pluginID, connectionID string) error

	// StartConnectionInformer starts an informer for the given connection
	StartConnectionInformer(pluginID, connectionID string) error

	// StopConnectionInformer stops an informer for the given connection
	StopConnectionInformer(pluginID, connectionID string) error

	// GetResourceGroups
	GetResourceGroups(pluginID, connectionID string) map[string]rt.ResourceGroup

	// GetResourceGroup
	GetResourceGroup(pluginID, groupID string) (rt.ResourceGroup, error)

	// GetResourceTypes returns a map of all the resource types that are available to the resource controller
	GetResourceTypes(pluginID, connectionID string) map[string]rt.ResourceMeta

	// GetResourceType returns the resource type information by it's string representation
	// For example, "core::v1::Pod" or "ec2::2012-12-01::EC2Instance"
	GetResourceType(pluginID, typeID string) (*rt.ResourceMeta, error)

	// HasResourceType checks to see if the resource type exists
	HasResourceType(pluginID, typeID string) bool

	// GetResourceDefinition returns the resource definition for a given resource
	GetResourceDefinition(pluginID, typeID string) (rt.ResourceDefinition, error)

	// GetActions returns available actions for a resource type
	GetActions(pluginID, connectionID, key string) ([]rt.ActionDescriptor, error)

	// ExecuteAction executes a named action on a resource
	ExecuteAction(pluginID, connectionID, key, actionID string, input rt.ActionInput) (*rt.ActionResult, error)

	// StreamAction executes a streaming action, returning an operation ID for event subscription
	StreamAction(pluginID, connectionID, key, actionID string, input rt.ActionInput) (string, error)

	// GetLayout returns the layout for the plugin
	GetLayout(pluginID string, layoutID string) ([]rt.LayoutItem, error)

	// GetDefaultLayout returns the default layout for the plugin
	GetDefaultLayout(pluginID string) ([]rt.LayoutItem, error)

	// SetLayout sets a single layout for a plugin
	SetLayout(pluginID string, layoutID string, layout []rt.LayoutItem) error

	// GetEditorSchemas returns editor schemas for the given plugin and connection
	GetEditorSchemas(pluginID, connectionID string) ([]rt.EditorSchema, error)

	// GetInformerState returns the current informer state summary for a connection
	GetInformerState(pluginID, connectionID string) (*rt.InformerConnectionSummary, error)

	// EnsureInformerForResource ensures an informer is running for a specific resource type
	EnsureInformerForResource(pluginID, connectionID, resourceKey string) error

	// ListAllConnections returns all connections across all plugins
	ListAllConnections() (map[string][]types.Connection, error)
}

Client is the system/UI facing client for making resource requests to the resource controller. We don't really want to expose the other methods of the controller to the outside world, so only methods that should exist here are the ones that the UI/other controllers need to interact with.

Jump to

Keyboard shortcuts

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