service

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2021 License: Apache-2.0 Imports: 14 Imported by: 56

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionRequest

type ActionRequest struct {
	DashboardClient Dashboard
	ActionName      string
	Payload         action.Payload
	ClientState     plugin.ClientState
	// contains filtered or unexported fields
}

ActionRequest is a request for actions.

func (*ActionRequest) Context

func (r *ActionRequest) Context() context.Context

func (*ActionRequest) GeneratePath

func (r *ActionRequest) GeneratePath(pathParts ...string) string

type Dashboard

type Dashboard interface {
	Close() error
	Create(ctx context.Context, object *unstructured.Unstructured) error
	List(ctx context.Context, key store.Key) (*unstructured.UnstructuredList, error)
	Get(ctx context.Context, key store.Key) (*unstructured.Unstructured, error)
	Update(ctx context.Context, object *unstructured.Unstructured) error
	Delete(ctx context.Context, key store.Key) error
	PortForward(ctx context.Context, req api.PortForwardRequest) (api.PortForwardResponse, error)
	CancelPortForward(ctx context.Context, id string)
	ListNamespaces(ctx context.Context) (api.NamespacesResponse, error)
	ForceFrontendUpdate(ctx context.Context) error
	SendAlert(ctx context.Context, clientID string, alert action.Alert) error
	CreateLink(ctx context.Context, key store.Key) (api.LinkResponse, error)
}

Dashboard is the client a plugin can use to interact with Octant.

func NewDashboardClient

func NewDashboardClient(dashboardAPIAddress string) (Dashboard, error)

NewDashboardClient creates a dashboard client.

type HandleFunc

type HandleFunc func(request Request) (component.ContentResponse, error)

HandleFunc is a function that generates a content response.

type Handler

type Handler struct {
	HandlerFuncs
	// contains filtered or unexported fields
}

Handler is the plugin service helper handler. Functions on this struct are called from Octant.

func (*Handler) Content

func (p *Handler) Content(ctx context.Context, contentPath string) (component.ContentResponse, error)

Content creates content for a given content path.

func (*Handler) HandleAction

func (p *Handler) HandleAction(ctx context.Context, actionName string, payload action.Payload) error

HandleAction handles actions given a payload.

func (*Handler) Navigation

func (p *Handler) Navigation(ctx context.Context) (navigation.Navigation, error)

Navigation creates navigation.

func (*Handler) ObjectStatus

func (p *Handler) ObjectStatus(ctx context.Context, object runtime.Object) (plugin.ObjectStatusResponse, error)

ObjectStatus creates status for an object.

func (*Handler) Print

func (p *Handler) Print(ctx context.Context, object runtime.Object) (plugin.PrintResponse, error)

Print prints components for an object.

func (*Handler) PrintTabs added in v0.18.0

func (p *Handler) PrintTabs(ctx context.Context, object runtime.Object) ([]plugin.TabResponse, error)

PrintTabs prints one or more tabs for an object.

func (*Handler) Register

func (p *Handler) Register(ctx context.Context, dashboardAPIAddress string) (plugin.Metadata, error)

Register registers a plugin with Octant.

func (*Handler) Validate

func (p *Handler) Validate() error

Validate validates Handler.

type HandlerActionFunc

type HandlerActionFunc func(request *ActionRequest) error

type HandlerFuncs

type HandlerFuncs struct {
	Print        HandlerPrinterFunc
	PrintTabs    []HandlerTabPrintFunc
	ObjectStatus HandlerObjectStatusFunc
	HandleAction HandlerActionFunc
	Navigation   HandlerNavigationFunc
	InitRoutes   HandlerInitRoutesFunc
}

HandlerFuncs are functions for configuring a plugin.

type HandlerInitRoutesFunc

type HandlerInitRoutesFunc func(router *Router)

type HandlerNavigationFunc

type HandlerNavigationFunc func(request *NavigationRequest) (navigation.Navigation, error)

type HandlerObjectStatusFunc

type HandlerObjectStatusFunc func(request *PrintRequest) (plugin.ObjectStatusResponse, error)

type HandlerPrinterFunc

type HandlerPrinterFunc func(request *PrintRequest) (plugin.PrintResponse, error)

type HandlerTabPrintFunc

type HandlerTabPrintFunc func(request *PrintRequest) (plugin.TabResponse, error)
type NavigationRequest struct {
	DashboardClient Dashboard
	ClientState     plugin.ClientState
	// contains filtered or unexported fields
}

NavigationRequest is a request for navigation.

func (r *NavigationRequest) Context() context.Context
func (r *NavigationRequest) GeneratePath(pathParts ...string) string

type Plugin

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

Plugin is a plugin service helper.

func Register

func Register(name, description string, capabilities *plugin.Capabilities, options ...PluginOption) (*Plugin, error)

Register registers a plugin with Octant.

func (*Plugin) Serve

func (p *Plugin) Serve()

Serve serves a plugin.

func (*Plugin) Validate

func (p *Plugin) Validate() error

Validate validates this helper.

type PluginOption

type PluginOption func(p *Plugin)

PluginOption is an option for configuring Plugin.

func WithActionHandler

func WithActionHandler(fn HandlerActionFunc) PluginOption

WithActionHandler configures the plugin to handle actions.

func WithNavigation

func WithNavigation(fn HandlerNavigationFunc, routerInit HandlerInitRoutesFunc) PluginOption

WithNavigation configures the plugin to handle navigation and routes.

func WithObjectStatus

func WithObjectStatus(fn HandlerObjectStatusFunc) PluginOption

WithObjectStatus configures the plugin to supply object status.

func WithPrinter

func WithPrinter(fn HandlerPrinterFunc) PluginOption

WithPrinter configures the plugin to have a printer.

func WithTabPrinter

func WithTabPrinter(funcs ...HandlerTabPrintFunc) PluginOption

WithTabPrinter configures the plugin to have a tab printer.

type PrintRequest

type PrintRequest struct {
	DashboardClient Dashboard
	Object          runtime.Object
	ClientState     plugin.ClientState
	// contains filtered or unexported fields
}

PrintRequest is a request for printing.

func (*PrintRequest) Context

func (r *PrintRequest) Context() context.Context

func (*PrintRequest) GeneratePath

func (r *PrintRequest) GeneratePath(pathParts ...string) string

type Request

type Request interface {
	Context() context.Context
	DashboardClient() Dashboard
	Path() string
	ClientState() plugin.ClientState
}

type Router

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

Router is a router for the plugin. A plugin can register a HandleFuncs to a path.

func NewRouter

func NewRouter() *Router

NewRouter creates a Router.

func (*Router) HandleFunc

func (r *Router) HandleFunc(routePath string, handleFunc HandleFunc)

HandleFunc registers a HandleFunc to a path. Paths can contain globs. e.g `/*` will match `/foo` if an explicit `/foo` path (or glob) has not already been registered. Routes are evaluated in the order they were added.

func (*Router) Match

func (r *Router) Match(contentPath string) (HandleFunc, bool)

Match matches a path against a exiting route. If no route is found, it will return false in the second return value.

Directories

Path Synopsis
Package fake is a generated GoMock package.
Package fake is a generated GoMock package.

Jump to

Keyboard shortcuts

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