Documentation ¶
Index ¶
- Constants
- Variables
- func AddCRD(ctx context.Context, crd *unstructured.Unstructured, pm *PathMatcher, ...)
- func CreateErrorTab(name string, err error) component.Component
- func CustomResourceDefinition(ctx context.Context, name string, o store.Store) (*unstructured.Unstructured, error)
- func DeleteCRD(ctx context.Context, crd *unstructured.Unstructured, pm *PathMatcher, ...)
- func LoadObject(ctx context.Context, objectStore store.Store, errorStore oerrors.ErrorStore, ...) (*unstructured.Unstructured, error)
- func LoadObjects(ctx context.Context, objectStore store.Store, errorStore oerrors.ErrorStore, ...) (*unstructured.UnstructuredList, error)
- func LogsTab(_ context.Context, object runtime.Object, _ Options) (component.Component, error)
- func MetadataTab(_ context.Context, object runtime.Object, options Options) (component.Component, error)
- func ResourceViewerTab(ctx context.Context, object runtime.Object, options Options) (component.Component, error)
- func SummaryTab(ctx context.Context, object runtime.Object, options Options) (component.Component, error)
- func TerminalTab(ctx context.Context, object runtime.Object, options Options) (component.Component, error)
- func YAMLViewerTab(_ context.Context, object runtime.Object, _ Options) (component.Component, error)
- type CRDSection
- func (csd *CRDSection) Add(name string, describer Describer)
- func (csd *CRDSection) Describe(ctx context.Context, namespace string, options Options) (component.ContentResponse, error)
- func (csd *CRDSection) PathFilters() []PathFilter
- func (csd *CRDSection) Remove(name string)
- func (csd *CRDSection) Reset(ctx context.Context) error
- type DefaultCRDWatcher
- type Describer
- type List
- type ListConfig
- type LoaderFunc
- type Object
- type ObjectConfig
- type ObjectLoaderFactory
- type ObjectTabsGenerator
- type Options
- type PathFilter
- type PathMatcher
- type Resource
- type ResourceDescriptor
- type ResourceLoadResponse
- type ResourceLoader
- type ResourceOptions
- type ResourceTitle
- type Section
- func (d *Section) Component(ctx context.Context, namespace string, options Options) (*component.List, error)
- func (d *Section) Describe(ctx context.Context, namespace string, options Options) (component.ContentResponse, error)
- func (d *Section) PathFilters() []PathFilter
- func (d *Section) Reset(ctx context.Context) error
- type StoreResourceLoader
- type StubDescriber
- type Tab
- type TabFactory
- type TabsFactory
- type TabsGenerator
- type TabsGeneratorConfig
Constants ¶
const (
ResourceNameRegex = "(?P<name>.*?)"
)
Variables ¶
var (
ErrPathNotFound = errors.New("path not found")
)
Functions ¶
func AddCRD ¶
func AddCRD(ctx context.Context, crd *unstructured.Unstructured, pm *PathMatcher, crdSection *CRDSection, m module.Module, s store.Store)
func CreateErrorTab ¶ added in v0.12.0
CreateErrorTab creates an error tab given a name and an error.
func CustomResourceDefinition ¶
func CustomResourceDefinition(ctx context.Context, name string, o store.Store) (*unstructured.Unstructured, error)
func DeleteCRD ¶
func DeleteCRD(ctx context.Context, crd *unstructured.Unstructured, pm *PathMatcher, crdSection *CRDSection, m module.Module)
func LoadObject ¶
func LoadObject(ctx context.Context, objectStore store.Store, errorStore oerrors.ErrorStore, namespace string, fields map[string]string, objectStoreKey store.Key) (*unstructured.Unstructured, error)
LoadObject loads a single object from the object store.
func LoadObjects ¶
func LoadObjects(ctx context.Context, objectStore store.Store, errorStore oerrors.ErrorStore, namespace string, fields map[string]string, objectStoreKeys []store.Key) (*unstructured.UnstructuredList, error)
LoadObjects loads objects from the object store sorted by their name.
func LogsTab ¶ added in v0.12.0
LogsTab generates a logs tab for a pod. If the object is not a pod, the returned component will be nil with a nil error.
func MetadataTab ¶ added in v0.12.0
func MetadataTab(_ context.Context, object runtime.Object, options Options) (component.Component, error)
MetadataTab generates a metadata tab for an object.
func ResourceViewerTab ¶ added in v0.12.0
func ResourceViewerTab(ctx context.Context, object runtime.Object, options Options) (component.Component, error)
ResourceViewerTab generates a resource viewer tab for an object.
func SummaryTab ¶ added in v0.12.0
func SummaryTab(ctx context.Context, object runtime.Object, options Options) (component.Component, error)
SummaryTab generates a summary tab for an object.
Types ¶
type CRDSection ¶
type CRDSection struct {
// contains filtered or unexported fields
}
func NamespacedCRD ¶
func NamespacedCRD() *CRDSection
NamespacedCRD returns a describer for namespaces CRDs.
func NewCRDSection ¶
func NewCRDSection(p, title string) *CRDSection
func (*CRDSection) Add ¶
func (csd *CRDSection) Add(name string, describer Describer)
func (*CRDSection) Describe ¶
func (csd *CRDSection) Describe(ctx context.Context, namespace string, options Options) (component.ContentResponse, error)
func (*CRDSection) PathFilters ¶
func (csd *CRDSection) PathFilters() []PathFilter
func (*CRDSection) Remove ¶
func (csd *CRDSection) Remove(name string)
type DefaultCRDWatcher ¶
type DefaultCRDWatcher struct {
// contains filtered or unexported fields
}
DefaultCRDWatcher is the default CRD watcher.
func NewDefaultCRDWatcher ¶
func NewDefaultCRDWatcher(ctx context.Context, clusterClient cluster.ClientInterface, objectStore store.Store, errorStore oerrors.ErrorStore) (*DefaultCRDWatcher, error)
NewDefaultCRDWatcher creates an instance of DefaultCRDWatcher.
func (*DefaultCRDWatcher) AddConfig ¶ added in v0.10.0
func (cw *DefaultCRDWatcher) AddConfig(watchConfig *config.CRDWatchConfig) error
AddConfig adds watch config to the watcher.
type Describer ¶
type Describer interface { Describe(ctx context.Context, namespace string, options Options) (component.ContentResponse, error) PathFilters() []PathFilter Reset(ctx context.Context) error }
Describer creates content.
type List ¶
type List struct {
// contains filtered or unexported fields
}
List describes a list of objects.
func (*List) Describe ¶
func (d *List) Describe(ctx context.Context, namespace string, options Options) (component.ContentResponse, error)
Describe creates content.
func (*List) PathFilters ¶
func (d *List) PathFilters() []PathFilter
PathFilters returns path filters for this Describer.
type ListConfig ¶
type LoaderFunc ¶
type LoaderFunc func(ctx context.Context, o store.Store, namespace string, fields map[string]string) (*unstructured.Unstructured, error)
LoaderFunc loads an object from the object store.
type Object ¶
type Object struct {
// contains filtered or unexported fields
}
Object describes an object.
func (*Object) Describe ¶
func (d *Object) Describe(ctx context.Context, namespace string, options Options) (component.ContentResponse, error)
Describe describes an object. An object description is comprised of multiple tabs of content. By default, there will be the following tabs: summary, metadata, resource viewer, and yaml. If the object is a pod, there will also be a log and terminal tab. If plugins can contribute tabs to this object, those tabs will be included as well.
This function should always return a content response even if there is an error.
func (*Object) PathFilters ¶
func (d *Object) PathFilters() []PathFilter
PathFilters returns the path filters for this object.
type ObjectConfig ¶
type ObjectConfig struct { Path string BaseTitle string ObjectType func() interface{} StoreKey store.Key TabsGenerator TabsGenerator TabDescriptors []Tab }
ObjectConfig is configuration for Object.
type ObjectLoaderFactory ¶
type ObjectLoaderFactory struct {
// contains filtered or unexported fields
}
func NewObjectLoaderFactory ¶
func NewObjectLoaderFactory(dashConfig config.Dash) *ObjectLoaderFactory
func (*ObjectLoaderFactory) LoadObject ¶
func (f *ObjectLoaderFactory) LoadObject(ctx context.Context, namespace string, fields map[string]string, objectStoreKey store.Key) (*unstructured.Unstructured, error)
func (*ObjectLoaderFactory) LoadObjects ¶
func (f *ObjectLoaderFactory) LoadObjects(ctx context.Context, namespace string, fields map[string]string, objectStoreKeys []store.Key) (*unstructured.UnstructuredList, error)
type ObjectTabsGenerator ¶ added in v0.12.0
type ObjectTabsGenerator struct { }
ObjectTabsGenerator generates tabs for an object.
func NewObjectTabsGenerator ¶ added in v0.12.0
func NewObjectTabsGenerator() *ObjectTabsGenerator
NewObjectTabsGenerator creates an instance of ObjectTabsGenerator.
func (ObjectTabsGenerator) Generate ¶ added in v0.12.0
func (t ObjectTabsGenerator) Generate(ctx context.Context, config TabsGeneratorConfig) ([]component.Component, error)
Generate generates tabs for an object.
type Options ¶
type Options struct { config.Dash Queryer queryer.Queryer Fields map[string]string Printer printer.Printer LabelSet *kLabels.Set Link link.Interface LoadObjects func(ctx context.Context, namespace string, fields map[string]string, objectStoreKeys []store.Key) (*unstructured.UnstructuredList, error) LoadObject func(ctx context.Context, namespace string, fields map[string]string, objectStoreKey store.Key) (*unstructured.Unstructured, error) }
Options provides options to describers
type PathFilter ¶
type PathFilter struct { Describer Describer // contains filtered or unexported fields }
func NewPathFilter ¶
func NewPathFilter(filterPath string, describer Describer) *PathFilter
NewPathFilter creates a path filter.
func (*PathFilter) Fields ¶
func (pf *PathFilter) Fields(contentPath string) map[string]string
Fields extracts parameters from the request path. In practice, this finds the field "name" for an object request.
func (*PathFilter) Match ¶
func (pf *PathFilter) Match(contentPath string) bool
Match matches a contentPath against the filter.
content paths look like:
/foo/bar /namespace/default /namespace/default/foo/bar /
func (*PathFilter) String ¶
func (pf *PathFilter) String() string
type PathMatcher ¶
func NewPathMatcher ¶
func NewPathMatcher(name string) *PathMatcher
func (*PathMatcher) Deregister ¶
func (pm *PathMatcher) Deregister(ctx context.Context, paths ...string)
func (*PathMatcher) Find ¶
func (pm *PathMatcher) Find(path string) (PathFilter, error)
func (*PathMatcher) Register ¶
func (pm *PathMatcher) Register(ctx context.Context, pf PathFilter)
type Resource ¶
type Resource struct { ResourceOptions // contains filtered or unexported fields }
func NewResource ¶
func NewResource(options ResourceOptions) *Resource
func (*Resource) PathFilters ¶
func (r *Resource) PathFilters() []PathFilter
type ResourceDescriptor ¶ added in v0.15.0
type ResourceDescriptor struct { CustomResourceDefinitionName string Namespace string CustomResourceVersion string CustomResourceName string }
ResourceDescriptor describes a custom resource.
type ResourceLoadResponse ¶ added in v0.15.0
type ResourceLoadResponse struct { // CustomResource is the custom resource. CustomResource *unstructured.Unstructured // CustomResourceDefinition is the custom resource definition. CustomResourceDefinition *unstructured.Unstructured }
ResourceLoadResponse is a response from a from ResourceLoader.
type ResourceLoader ¶ added in v0.15.0
type ResourceLoader interface { // Load loads a custom resource given a ResourceDescriptor. Load(ctx context.Context, d ResourceDescriptor) (*ResourceLoadResponse, error) }
ResourceLoader is an interface which loads a custom resource.
type ResourceOptions ¶
type ResourceTitle ¶
type Section ¶
type Section struct {
// contains filtered or unexported fields
}
Section is a wrapper to combine content from multiple describers.
func NamespacedOverview ¶
func NamespacedOverview() *Section
NamespacedObjects returns a describer for a namespaced overview.
func NewSection ¶
NewSection creates a Section.
func (*Section) Describe ¶
func (d *Section) Describe(ctx context.Context, namespace string, options Options) (component.ContentResponse, error)
Describe generates content.
func (*Section) PathFilters ¶
func (d *Section) PathFilters() []PathFilter
PathFilters returns path filters for the section.
type StoreResourceLoader ¶ added in v0.15.0
type StoreResourceLoader struct {
// contains filtered or unexported fields
}
StoreResourceLoader is an interface which loads a custom resource using Octant's store.
func NewStoreResourceLoader ¶ added in v0.15.0
func NewStoreResourceLoader(s store.Store) *StoreResourceLoader
NewStoreResourceLoader creates an instance of StoreResourceLoader.
func (*StoreResourceLoader) Load ¶ added in v0.15.0
func (rl *StoreResourceLoader) Load(ctx context.Context, d ResourceDescriptor) (*ResourceLoadResponse, error)
Load loads a custom resource.
type StubDescriber ¶
type StubDescriber struct {
// contains filtered or unexported fields
}
func NewEmptyDescriber ¶
func NewEmptyDescriber(p string) *StubDescriber
func NewStubDescriber ¶
func NewStubDescriber(p string, components ...component.Component) *StubDescriber
func (*StubDescriber) Describe ¶
func (d *StubDescriber) Describe(context.Context, string, Options) (component.ContentResponse, error)
func (*StubDescriber) PathFilters ¶
func (d *StubDescriber) PathFilters() []PathFilter
type Tab ¶ added in v0.12.0
type Tab struct { // Name is the name of the tab. Name string // Factory is a function that generates the contents for a tab (as a component). Factory TabFactory }
Tab describes a tab. It contains the name and a factory function to generate the content for the tab.
type TabFactory ¶ added in v0.12.0
type TabFactory func( ctx context.Context, object runtime.Object, options Options) (component.Component, error)
TabFactory is a function that generates a component which describes an object as a component.
func CustomResourceSummaryTab ¶ added in v0.12.0
func CustomResourceSummaryTab(crdName string) TabFactory
CustomResourceSummaryTab generates a summary tab for a custom resource. This function returns a TabFactory since the crd name might not be available when this factory is invoked.
type TabsFactory ¶ added in v0.12.0
TabsFactory creates a list of tab descriptors.
type TabsGenerator ¶ added in v0.12.0
type TabsGenerator interface { // Generate generates tabs given a configuration and returns a list of components. Generate(ctx context.Context, config TabsGeneratorConfig) ([]component.Component, error) }
TabsGenerator generates tabs for an object.
type TabsGeneratorConfig ¶ added in v0.12.0
type TabsGeneratorConfig struct { Object runtime.Object TabsFactory TabsFactory Options Options }
TabsGeneratorConfig is configuration for TabsGenerator.