Documentation ¶
Index ¶
- Constants
- func CreateAlertUpdate(alert action.Alert) octant.Event
- func CreateContentEvent(contentResponse component.ContentResponse, namespace, contentPath string, ...) octant.Event
- func CreateEvent(eventType octant.EventType, fields action.Payload) octant.Event
- func CreateFiltersUpdate(filters []octant.Filter) octant.Event
- func CreateNamespacesEvent(namespaces []string) octant.Event
- func CreateNavigationEvent(sections []navigation.Navigation, defaultPath string) octant.Event
- func FilterFromPayload(in action.Payload) (octant.Filter, bool)
- func FiltersFromQueryParams(in interface{}) ([]octant.Filter, error)
- func FiltersToLabelSet(filters []octant.Filter) *labels.Set
- func ListenerAddr() string
- func NamespacesGenerator(_ context.Context, config NamespaceManagerConfig) ([]string, error)
- func NavigationGenerator(ctx context.Context, state octant.State, config NavigationManagerConfig) ([]navigation.Navigation, error)
- func ParseFilterQueryParam(in string) (octant.Filter, error)
- func RespondWithError(w http.ResponseWriter, code int, message string, logger log.Logger)
- type API
- type ActionDispatcher
- type ActionRequestManager
- type ClientManager
- type ContentGenerateFunc
- type ContentManager
- func (cm *ContentManager) Handlers() []octant.ClientRequestHandler
- func (cm *ContentManager) SetContentPath(state octant.State, payload action.Payload) error
- func (cm *ContentManager) SetNamespace(state octant.State, payload action.Payload) error
- func (cm *ContentManager) SetQueryParams(state octant.State, payload action.Payload) error
- func (cm *ContentManager) Start(ctx context.Context, state octant.State, s OctantClient)
- type ContentManagerOption
- type ContextGenerateFunc
- type ContextManager
- type ContextManagerOption
- type FilterManager
- func (fm *FilterManager) AddFilter(state octant.State, payload action.Payload) error
- func (fm *FilterManager) ClearFilters(state octant.State, payload action.Payload) error
- func (fm *FilterManager) Handlers() []octant.ClientRequestHandler
- func (fm *FilterManager) RemoveFilter(state octant.State, payload action.Payload) error
- func (fm *FilterManager) Start(ctx context.Context, state octant.State, s OctantClient)
- type InterruptiblePoller
- type NamespaceManagerConfig
- type NamespacesGenerateFunc
- type NamespacesManager
- type NamespacesManagerOption
- type NavigationGeneratorFunc
- type NavigationManager
- type NavigationManagerConfig
- type NavigationManagerOption
- type NotFoundError
- type OctantClient
- type Poller
- type PollerFunc
- type Service
- type SingleRunPoller
- type StateManager
- type WebsocketClient
- type WebsocketClientManager
- type WebsocketState
- func (c *WebsocketState) AddFilter(filter octant.Filter)
- func (c *WebsocketState) Dispatch(ctx context.Context, actionName string, payload action.Payload) error
- func (c *WebsocketState) GetContentPath() string
- func (c *WebsocketState) GetFilters() []octant.Filter
- func (c *WebsocketState) GetNamespace() string
- func (c *WebsocketState) GetQueryParams() map[string][]string
- func (c *WebsocketState) Handlers() []octant.ClientRequestHandler
- func (c *WebsocketState) OnContentPathUpdate(fn octant.ContentPathUpdateFunc) octant.UpdateCancelFunc
- func (c *WebsocketState) OnNamespaceUpdate(fn octant.NamespaceUpdateFunc) octant.UpdateCancelFunc
- func (c *WebsocketState) RemoveFilter(filter octant.Filter)
- func (c *WebsocketState) SendAlert(alert action.Alert)
- func (c *WebsocketState) SetContentPath(contentPath string)
- func (c *WebsocketState) SetContext(requestedContext string)
- func (c *WebsocketState) SetFilters(filters []octant.Filter)
- func (c *WebsocketState) SetNamespace(namespace string)
- func (c *WebsocketState) Start(ctx context.Context)
- type WebsocketStateOption
Constants ¶
const ( // ListenerAddrKey is the environment variable for the Octant listener address. ListenerAddrKey = "OCTANT_LISTENER_ADDR" AcceptedHostsKey = "OCTANT_ACCEPTED_HOSTS" // PathPrefix is a string for the api path prefix. PathPrefix = "/api/v1" )
const ( RequestSetContentPath = "setContentPath" RequestSetNamespace = "setNamespace" )
const ( RequestAddFilter = "addFilter" RequestClearFilters = "clearFilters" RequestRemoveFilter = "removeFilter" )
const (
RequestPerformAction = "performAction"
)
const (
RequestSetContext = "setContext"
)
Variables ¶
This section is empty.
Functions ¶
func CreateAlertUpdate ¶ added in v0.7.0
CreateAlertUpdate creates an alert update event.
func CreateContentEvent ¶ added in v0.7.0
func CreateContentEvent(contentResponse component.ContentResponse, namespace, contentPath string, queryParams map[string][]string) octant.Event
CreateContentEvent creates a content event.
func CreateEvent ¶ added in v0.7.0
func CreateFiltersUpdate ¶ added in v0.7.0
CreateFiltersUpdate creates a filters update event.
func CreateNamespacesEvent ¶ added in v0.7.0
CreateNamespacesEvent creates a namespaces event.
func CreateNavigationEvent ¶ added in v0.7.0
func CreateNavigationEvent(sections []navigation.Navigation, defaultPath string) octant.Event
CreateNavigationEvent creates a namespaces event.
func FilterFromPayload ¶ added in v0.7.0
FilterFromPayload creates a filter from a payload. Returns false if the payload is invalid.
func FiltersFromQueryParams ¶ added in v0.7.0
FiltersFromQueryParams converts query params to filters. Can handle one or multiple query params.
func FiltersToLabelSet ¶ added in v0.7.0
FiltersToLabelSet converts a slice of filters to a label set.
func ListenerAddr ¶ added in v0.6.0
func ListenerAddr() string
ListenerAddr returns the default listener address if OCTANT_LISTENER_ADDR is not set.
func NamespacesGenerator ¶ added in v0.7.0
func NamespacesGenerator(_ context.Context, config NamespaceManagerConfig) ([]string, error)
NamespacesGenerator generates a list of namespaces.
func NavigationGenerator ¶ added in v0.7.0
func NavigationGenerator(ctx context.Context, state octant.State, config NavigationManagerConfig) ([]navigation.Navigation, error)
NavigationGenerator generates a navigation tree given a set of modules and a namespace.
func ParseFilterQueryParam ¶ added in v0.7.0
ParseFilterQueryParam parsers a single filter from a query param in the format `key:value`.
func RespondWithError ¶
RespondWithError responds with an error message.
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API is the API for the dashboard client
func New ¶
func New(ctx context.Context, prefix string, actionDispatcher ActionDispatcher, dashConfig config.Dash) *API
New creates an instance of API.
func (*API) ForceUpdate ¶
type ActionDispatcher ¶
type ActionDispatcher interface {
Dispatch(ctx context.Context, alerter action.Alerter, actionName string, payload action.Payload) error
}
ActionDispatcher dispatches actions.
type ActionRequestManager ¶ added in v0.7.0
type ActionRequestManager struct { }
ActionRequestManager manages action requests. Action requests allow a generic interface for supporting dynamic requests from clients.
func NewActionRequestManager ¶ added in v0.7.0
func NewActionRequestManager() *ActionRequestManager
NewActionRequestManager creates an instance of ActionRequestManager.
func (*ActionRequestManager) Handlers ¶ added in v0.7.0
func (a *ActionRequestManager) Handlers() []octant.ClientRequestHandler
Handlers returns the handlers this manager supports.
func (*ActionRequestManager) PerformAction ¶ added in v0.7.0
PerformAction is a handler than runs an action.
func (ActionRequestManager) Start ¶ added in v0.7.0
func (a ActionRequestManager) Start(ctx context.Context, state octant.State, s OctantClient)
type ClientManager ¶ added in v0.7.0
type ClientManager interface { Run(ctx context.Context) ClientFromRequest(dashConfig config.Dash, w http.ResponseWriter, r *http.Request) (*WebsocketClient, error) }
ClientManager is an interface for managing clients.
type ContentGenerateFunc ¶ added in v0.7.0
type ContentGenerateFunc func(ctx context.Context, state octant.State) (component.ContentResponse, bool, error)
ContentGenerateFunc is a function that generates content. It returns `rerun=true` if the action should be be immediately rerun.
type ContentManager ¶ added in v0.7.0
type ContentManager struct {
// contains filtered or unexported fields
}
ContentManager manages content for websockets.
func NewContentManager ¶ added in v0.7.0
func NewContentManager(moduleManager module.ManagerInterface, logger log.Logger, options ...ContentManagerOption) *ContentManager
NewContentManager creates an instance of ContentManager.
func (*ContentManager) Handlers ¶ added in v0.7.0
func (cm *ContentManager) Handlers() []octant.ClientRequestHandler
Handlers returns a slice of client request handlers.
func (*ContentManager) SetContentPath ¶ added in v0.7.0
SetContentPath sets the current content path.
func (*ContentManager) SetNamespace ¶ added in v0.7.0
SetNamespace sets the current namespace.
func (*ContentManager) SetQueryParams ¶ added in v0.7.0
SetQueryParams sets the current query params.
func (*ContentManager) Start ¶ added in v0.7.0
func (cm *ContentManager) Start(ctx context.Context, state octant.State, s OctantClient)
Start starts the manager.
type ContentManagerOption ¶ added in v0.7.0
type ContentManagerOption func(manager *ContentManager)
ContentManagerOption is an option for configuring ContentManager.
func WithContentGenerator ¶ added in v0.7.0
func WithContentGenerator(fn ContentGenerateFunc) ContentManagerOption
WithContentGenerator configures the content generate function.
func WithContentGeneratorPoller ¶ added in v0.7.0
func WithContentGeneratorPoller(poller Poller) ContentManagerOption
WithContentGeneratorPoller configures the poller.
type ContextGenerateFunc ¶ added in v0.7.0
ContextGenerateFunc is a function which generates a context event.
type ContextManager ¶ added in v0.7.0
type ContextManager struct {
// contains filtered or unexported fields
}
ContextManager manages context.
func NewContextManager ¶ added in v0.7.0
func NewContextManager(dashConfig config.Dash, options ...ContextManagerOption) *ContextManager
NewContextManager creates an instances of ContextManager.
func (*ContextManager) Handlers ¶ added in v0.7.0
func (c *ContextManager) Handlers() []octant.ClientRequestHandler
Handlers returns a slice of handlers.
func (*ContextManager) SetContext ¶ added in v0.7.0
SetContext sets the current context.
func (*ContextManager) Start ¶ added in v0.7.0
func (c *ContextManager) Start(ctx context.Context, state octant.State, s OctantClient)
Start starts the manager.
type ContextManagerOption ¶ added in v0.7.0
type ContextManagerOption func(manager *ContextManager)
ContextManagerOption is an option for configuring ContextManager.
func WithContextGenerator ¶ added in v0.7.0
func WithContextGenerator(fn ContextGenerateFunc) ContextManagerOption
WithContextGenerator sets the context generator.
func WithContextGeneratorPoll ¶ added in v0.7.0
func WithContextGeneratorPoll(poller Poller) ContextManagerOption
WithContextGeneratorPoll generates the poller.
type FilterManager ¶ added in v0.7.0
type FilterManager struct { }
FilterManager manages filters.
func NewFilterManager ¶ added in v0.7.0
func NewFilterManager() *FilterManager
NewFilterManager creates an instance of FilterManager.
func (*FilterManager) ClearFilters ¶ added in v0.7.0
ClearFilters clears all filters.
func (*FilterManager) Handlers ¶ added in v0.7.0
func (fm *FilterManager) Handlers() []octant.ClientRequestHandler
Handlers returns a slice of handlers.
func (*FilterManager) RemoveFilter ¶ added in v0.7.0
RemoveFilters removes a filter.
func (*FilterManager) Start ¶ added in v0.7.0
func (fm *FilterManager) Start(ctx context.Context, state octant.State, s OctantClient)
Start starts the manager. Current is a no-op.
type InterruptiblePoller ¶ added in v0.7.0
type InterruptiblePoller struct {
// contains filtered or unexported fields
}
InterruptiblePoller is a poller than runs an action and allows for interrupts.
func NewInterruptiblePoller ¶ added in v0.7.0
func NewInterruptiblePoller(name string) *InterruptiblePoller
NewInterruptiblePoller creates an instance of InterruptiblePoller.
func (*InterruptiblePoller) Run ¶ added in v0.7.0
func (ip *InterruptiblePoller) Run(ctx context.Context, ch <-chan struct{}, action PollerFunc, resetDuration time.Duration)
Run runs the poller.
type NamespaceManagerConfig ¶ added in v0.7.0
type NamespaceManagerConfig interface {
ClusterClient() cluster.ClientInterface
}
NamespaceManagerConfig is configuration for NamespacesManager.
type NamespacesGenerateFunc ¶ added in v0.7.0
type NamespacesGenerateFunc func(ctx context.Context, config NamespaceManagerConfig) ([]string, error)
NamespacesGenerateFunc is a function that generates a list of namespaces.
type NamespacesManager ¶ added in v0.7.0
type NamespacesManager struct {
// contains filtered or unexported fields
}
NamespacesManager manages namespaces.
func NewNamespacesManager ¶ added in v0.7.0
func NewNamespacesManager(config NamespaceManagerConfig, options ...NamespacesManagerOption) *NamespacesManager
NewNamespacesManager creates an instance of NamespacesManager.
func (NamespacesManager) Handlers ¶ added in v0.7.0
func (n NamespacesManager) Handlers() []octant.ClientRequestHandler
Handlers returns nil.
func (*NamespacesManager) Start ¶ added in v0.7.0
func (n *NamespacesManager) Start(ctx context.Context, state octant.State, s OctantClient)
Start starts the manager. It periodically generates a list of namespaces.
type NamespacesManagerOption ¶ added in v0.7.0
type NamespacesManagerOption func(n *NamespacesManager)
NamespacesManagerOption is an option for configuring NamespacesManager.
func WithNamespacesGenerator ¶ added in v0.7.0
func WithNamespacesGenerator(fn NamespacesGenerateFunc) NamespacesManagerOption
WithNamespacesGenerator configures the namespaces generator function.
func WithNamespacesGeneratorPoller ¶ added in v0.7.0
func WithNamespacesGeneratorPoller(poller Poller) NamespacesManagerOption
WithNamespacesGeneratorPoller configures the poller.
type NavigationGeneratorFunc ¶ added in v0.7.0
type NavigationGeneratorFunc func(ctx context.Context, state octant.State, config NavigationManagerConfig) ([]navigation.Navigation, error)
NavigationGeneratorFunc is a function that generates a navigation tree.
type NavigationManager ¶ added in v0.7.0
type NavigationManager struct {
// contains filtered or unexported fields
}
NavigationManager manages the navigation tree.
func NewNavigationManager ¶ added in v0.7.0
func NewNavigationManager(config NavigationManagerConfig, options ...NavigationManagerOption) *NavigationManager
NewNavigationManager creates an instance of NavigationManager.
func (NavigationManager) Handlers ¶ added in v0.7.0
func (n NavigationManager) Handlers() []octant.ClientRequestHandler
Handlers returns nil.
func (*NavigationManager) Start ¶ added in v0.7.0
func (n *NavigationManager) Start(ctx context.Context, state octant.State, s OctantClient)
Start starts the manager. It periodically generates navigation updates.
type NavigationManagerConfig ¶ added in v0.7.0
type NavigationManagerConfig interface {
}NavigationManagerConfig is configuration of NavigationManager.
type NavigationManagerOption ¶ added in v0.7.0
type NavigationManagerOption func(n *NavigationManager)
NavigationManagerConfig is an option for configuration NavigationManager.
func WithNavigationGenerator ¶ added in v0.7.0
func WithNavigationGenerator(fn NavigationGeneratorFunc) NavigationManagerOption
WithNavigationGenerator configures the navigation generator function.
func WithNavigationGeneratorPoller ¶ added in v0.7.0
func WithNavigationGeneratorPoller(poller Poller) NavigationManagerOption
WithNavigationGeneratorPoller configures the poller.
type NotFoundError ¶
type NotFoundError struct {
// contains filtered or unexported fields
}
NotFoundError is a not found error.
func NewNotFoundError ¶
func NewNotFoundError(path string) *NotFoundError
NewNotFoundError creates an instance of NotFoundError
func (*NotFoundError) Error ¶
func (e *NotFoundError) Error() string
Error returns the error string.
func (*NotFoundError) NotFound ¶
func (e *NotFoundError) NotFound() bool
NotFound returns true to signify this is a not found error.
type OctantClient ¶ added in v0.7.0
OctantClient is an OctantClient.
type Poller ¶ added in v0.7.0
type Poller interface {
Run(ctx context.Context, ch <-chan struct{}, action PollerFunc, resetDuration time.Duration)
}
Poller is a poller. It runs an action.
type PollerFunc ¶ added in v0.7.0
PollerFunc is a function run by the poller.
type SingleRunPoller ¶ added in v0.7.0
type SingleRunPoller struct{}
SingleRunPoller is a a poller runs the supplied action once. It is useful for testing.
func NewSingleRunPoller ¶ added in v0.7.0
func NewSingleRunPoller() *SingleRunPoller
NewSingleRunPoller creates an instance of SingleRunPoller.
func (SingleRunPoller) Run ¶ added in v0.7.0
func (a SingleRunPoller) Run(ctx context.Context, ch <-chan struct{}, action PollerFunc, resetDuration time.Duration)
Run runs the poller.
type StateManager ¶ added in v0.7.0
type StateManager interface { Handlers() []octant.ClientRequestHandler Start(ctx context.Context, state octant.State, s OctantClient) }
StateManager manages states for WebsocketState.
type WebsocketClient ¶ added in v0.7.0
type WebsocketClient struct {
// contains filtered or unexported fields
}
WebsocketClient manages websocket clients.
func NewWebsocketClient ¶ added in v0.7.0
func NewWebsocketClient(ctx context.Context, conn *websocket.Conn, dashConfig config.Dash, actionDispatcher ActionDispatcher, id uuid.UUID) *WebsocketClient
NewWebsocketClient creates an instance of WebsocketClient.
func (*WebsocketClient) ID ¶ added in v0.7.0
func (c *WebsocketClient) ID() string
ID returns the ID of the websocket client.
func (*WebsocketClient) RegisterHandler ¶ added in v0.7.0
func (c *WebsocketClient) RegisterHandler(handler octant.ClientRequestHandler)
func (*WebsocketClient) Send ¶ added in v0.7.0
func (c *WebsocketClient) Send(ev octant.Event)
type WebsocketClientManager ¶ added in v0.7.0
type WebsocketClientManager struct {
// contains filtered or unexported fields
}
WebsocketClientManager is a client manager for websockets.
func NewWebsocketClientManager ¶ added in v0.7.0
func NewWebsocketClientManager(ctx context.Context, dispatcher ActionDispatcher) *WebsocketClientManager
NewWebsocketClientManager creates an instance of WebsocketClientManager.
func (*WebsocketClientManager) ClientFromRequest ¶ added in v0.7.0
func (m *WebsocketClientManager) ClientFromRequest(dashConfig config.Dash, w http.ResponseWriter, r *http.Request) (*WebsocketClient, error)
ClientFromRequest creates a websocket client from a http request.
func (*WebsocketClientManager) Run ¶ added in v0.7.0
func (m *WebsocketClientManager) Run(ctx context.Context)
Run runs the manager. It manages multiple websocket clients.
type WebsocketState ¶ added in v0.7.0
type WebsocketState struct {
// contains filtered or unexported fields
}
WebsocketState manages state for a websocket client.
func NewWebsocketState ¶ added in v0.7.0
func NewWebsocketState(dashConfig config.Dash, actionDispatcher ActionDispatcher, wsClient OctantClient, options ...WebsocketStateOption) *WebsocketState
NewWebsocketState creates an instance of WebsocketState.
func (*WebsocketState) AddFilter ¶ added in v0.7.0
func (c *WebsocketState) AddFilter(filter octant.Filter)
AddFilter adds a content filter.
func (*WebsocketState) Dispatch ¶ added in v0.7.0
func (c *WebsocketState) Dispatch(ctx context.Context, actionName string, payload action.Payload) error
Dispatch dispatches a message.
func (*WebsocketState) GetContentPath ¶ added in v0.7.0
func (c *WebsocketState) GetContentPath() string
GetContentPath returns the content path.
func (*WebsocketState) GetFilters ¶ added in v0.7.0
func (c *WebsocketState) GetFilters() []octant.Filter
GetFilters returns all filters.
func (*WebsocketState) GetNamespace ¶ added in v0.7.0
func (c *WebsocketState) GetNamespace() string
GetNamespace gets the namespace.
func (*WebsocketState) GetQueryParams ¶ added in v0.7.0
func (c *WebsocketState) GetQueryParams() map[string][]string
func (*WebsocketState) Handlers ¶ added in v0.7.0
func (c *WebsocketState) Handlers() []octant.ClientRequestHandler
Handlers returns all the handlers for WebsocketState.
func (*WebsocketState) OnContentPathUpdate ¶ added in v0.7.0
func (c *WebsocketState) OnContentPathUpdate(fn octant.ContentPathUpdateFunc) octant.UpdateCancelFunc
OnContentPathUpdate registers a function that will be called when the content path changes.
func (*WebsocketState) OnNamespaceUpdate ¶ added in v0.7.0
func (c *WebsocketState) OnNamespaceUpdate(fn octant.NamespaceUpdateFunc) octant.UpdateCancelFunc
OnNamespaceUpdate registers a function that will be run when the namespace changes.
func (*WebsocketState) RemoveFilter ¶ added in v0.7.0
func (c *WebsocketState) RemoveFilter(filter octant.Filter)
RemoveFilter removes a content filter.
func (*WebsocketState) SendAlert ¶ added in v0.7.0
func (c *WebsocketState) SendAlert(alert action.Alert)
SendAlert sends an alert to the websocket client.
func (*WebsocketState) SetContentPath ¶ added in v0.7.0
func (c *WebsocketState) SetContentPath(contentPath string)
SetContentPath sets the content path.
func (*WebsocketState) SetContext ¶ added in v0.7.0
func (c *WebsocketState) SetContext(requestedContext string)
SetContext sets the Kubernetes context.
func (*WebsocketState) SetFilters ¶ added in v0.7.0
func (c *WebsocketState) SetFilters(filters []octant.Filter)
func (*WebsocketState) SetNamespace ¶ added in v0.7.0
func (c *WebsocketState) SetNamespace(namespace string)
SetNamespace sets the namespace.
func (*WebsocketState) Start ¶ added in v0.7.0
func (c *WebsocketState) Start(ctx context.Context)
Start starts WebsocketState by starting all associated StateManagers.
type WebsocketStateOption ¶ added in v0.7.0
type WebsocketStateOption func(w *WebsocketState)
WebsocketStateOption is an option for configuring WebsocketState.
func WebsocketStateManagers ¶ added in v0.7.0
func WebsocketStateManagers(managers []StateManager) WebsocketStateOption
WebsocketStateManagers configures WebsocketState's state managers.