117 lines
2.4 KiB
Go
117 lines
2.4 KiB
Go
package view
|
|
|
|
import (
|
|
"github.com/derailed/k9s/internal/dao"
|
|
"github.com/derailed/k9s/internal/model"
|
|
"github.com/derailed/k9s/internal/resource"
|
|
"github.com/derailed/k9s/internal/ui"
|
|
)
|
|
|
|
type (
|
|
// EnvFunc represent the current view exposed environment.
|
|
EnvFunc func() K9sEnv
|
|
|
|
// BoostActionFunc extends viewer keyboard actions.
|
|
BoostActionsFunc func(ui.KeyActions)
|
|
|
|
// ViewFunc represents a new resource viewer.
|
|
ViewFunc func(title, gvr string, list resource.List) ResourceViewer
|
|
|
|
// ListFunc represents a new resource list.
|
|
ListFunc func(c resource.Connection, ns string) resource.List
|
|
|
|
// EnterFunc represents an enter key action.
|
|
EnterFunc func(app *App, ns, resource, selection string)
|
|
|
|
// ContainerFunc returns the active container name.
|
|
ContainerFunc func() string
|
|
)
|
|
|
|
// ActionExtender enhances a given viewer by adding new menu actions.
|
|
type ActionExtender interface {
|
|
// BindKeys injects new menu actions.
|
|
BindKeys(ResourceViewer)
|
|
}
|
|
|
|
// Hinter represents a view that can produce menu hints.
|
|
type Hinter interface {
|
|
// Hints returns a collection of hints.
|
|
Hints() model.MenuHints
|
|
}
|
|
|
|
// Viewer represents a component viewer.
|
|
type Viewer interface {
|
|
model.Component
|
|
|
|
// Actions returns active menu bindings.
|
|
Actions() ui.KeyActions
|
|
|
|
// App returns an app handle.
|
|
App() *App
|
|
|
|
// Refresh updates the viewer
|
|
Refresh()
|
|
}
|
|
|
|
// ResourceViewer represents a generic resource viewer.
|
|
type ResourceViewer interface {
|
|
TableViewer
|
|
|
|
// List returns a resource List.
|
|
List() resource.List
|
|
|
|
// SetEnvFn sets a function to pull viewer env vars for plugins.
|
|
SetEnvFn(EnvFunc)
|
|
|
|
// SetPath set parents selector.
|
|
SetPath(p string)
|
|
|
|
// GVR returns a resource descriptor.
|
|
GVR() string
|
|
|
|
SetContextFn(ContextFunc)
|
|
}
|
|
|
|
// TableViewer represents a tabular viewer.
|
|
type TableViewer interface {
|
|
Viewer
|
|
|
|
// Table returns a table component.
|
|
GetTable() *Table
|
|
}
|
|
|
|
type LogViewer interface {
|
|
ResourceViewer
|
|
|
|
ShowLogs(prev bool)
|
|
}
|
|
|
|
type RestartableViewer interface {
|
|
LogViewer
|
|
}
|
|
|
|
type ScalableViewer interface {
|
|
LogViewer
|
|
}
|
|
|
|
// SubjectViewer represents a policy viewer.
|
|
type SubjectViewer interface {
|
|
ResourceViewer
|
|
|
|
// SetSubject sets the active subject.
|
|
SetSubject(s string)
|
|
}
|
|
|
|
type ViewerFunc func(dao.GVR) ResourceViewer
|
|
|
|
// MetaViewer represents a registered meta viewer.
|
|
type MetaViewer struct {
|
|
viewerFn ViewerFunc
|
|
viewFn ViewFunc
|
|
listFn ListFunc
|
|
enterFn EnterFunc
|
|
}
|
|
|
|
// MetaViewers represents a collection of meta viewers.
|
|
type MetaViewers map[dao.GVR]MetaViewer
|