Documentation
¶
Index ¶
- func NewLoggerHelper() hclog.Logger
- func SetupPluginLogger(g GranularityLevel)
- type ActionRequest
- type Dashboard
- type GranularityLevel
- type HandleFunc
- type Handler
- func (p *Handler) Content(ctx context.Context, contentPath string) (component.ContentResponse, error)
- func (p *Handler) HandleAction(ctx context.Context, actionName string, payload action.Payload) error
- func (p *Handler) Navigation(ctx context.Context) (navigation.Navigation, error)
- func (p *Handler) ObjectStatus(ctx context.Context, object runtime.Object) (plugin.ObjectStatusResponse, error)
- func (p *Handler) Print(ctx context.Context, object runtime.Object) (plugin.PrintResponse, error)
- func (p *Handler) PrintTabs(ctx context.Context, object runtime.Object) ([]plugin.TabResponse, error)
- func (p *Handler) Register(ctx context.Context, dashboardAPIAddress string) (plugin.Metadata, error)
- func (p *Handler) Validate() error
- type HandlerActionFunc
- type HandlerFuncs
- type HandlerInitRoutesFunc
- type HandlerNavigationFunc
- type HandlerObjectStatusFunc
- type HandlerPrinterFunc
- type HandlerTabPrintFunc
- type NavigationRequest
- type Plugin
- type PluginOption
- func WithActionHandler(fn HandlerActionFunc) PluginOption
- func WithNavigation(fn HandlerNavigationFunc, routerInit HandlerInitRoutesFunc) PluginOption
- func WithObjectStatus(fn HandlerObjectStatusFunc) PluginOption
- func WithPrinter(fn HandlerPrinterFunc) PluginOption
- func WithTabPrinter(funcs ...HandlerTabPrintFunc) PluginOption
- type PrintRequest
- type Request
- type Router
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewLoggerHelper ¶ added in v0.24.0
func NewLoggerHelper() hclog.Logger
NewLoggerHelper Create a Logger with JSON format allowing user to have a more granular support for example NewLoggerHelper().Info("octant-sample-plugin is starting")
func SetupPluginLogger ¶ added in v0.24.0
func SetupPluginLogger(g GranularityLevel)
SetupPluginLogger Set prefix so go-plugin recognize the level of granularity and applied to the host process Unfortunately logs go through hclog and the through Zap, for this reason it looks like this "2021-08-23T11:35:02.714-0500 INFO octant-sample-plugin plugin/logger.go:43 [INFO] 2021/08/23 11:35:02 ..."
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) GeneratePath ¶
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 ApplyYAML(ctx context.Context, namespace, yaml string) ([]string, 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) SendEvent(ctx context.Context, clientID string, eventName event.EventType, payload action.Payload) error }
Dashboard is the client a plugin can use to interact with Octant.
func NewDashboardClient ¶
NewDashboardClient creates a dashboard client.
type GranularityLevel ¶ added in v0.24.0
type GranularityLevel string
const ( Trace GranularityLevel = "[TRACE] " Debug GranularityLevel = "[DEBUG] " Info GranularityLevel = "[INFO] " Warn GranularityLevel = "[WARN] " Error GranularityLevel = "[ERROR] " )
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) 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.
type HandlerActionFunc ¶
type HandlerActionFunc func(request *ActionRequest) error
type HandlerFuncs ¶
type HandlerFuncs struct { Print HandlerPrinterFunc PrintTabs []HandlerTabPrintFunc ObjectStatus HandlerObjectStatusFunc HandleAction HandlerActionFunc 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 ¶
type NavigationRequest struct { // contains filtered or unexported fields }
NavigationRequest is a request for navigation.
func (*NavigationRequest) GeneratePath ¶
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.
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) GeneratePath ¶
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 (*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.