describer

package
v0.25.1 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2022 License: Apache-2.0 Imports: 45 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResourceNameRegex = "(?P<name>.*?)"
)

Variables

View Source
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

func CreateErrorTab(name string, err error) component.Component

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

func LogsTab(_ context.Context, object runtime.Object, _ Options) (component.Component, error)

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.

func TerminalTab added in v0.12.0

func TerminalTab(ctx context.Context, object runtime.Object, options Options) (component.Component, error)

TerminalTab generates a terminal tab for a pod. If the object is not a pod, the returned component will be nil with a nil error.

func YAMLViewerTab added in v0.12.0

func YAMLViewerTab(_ context.Context, object runtime.Object, _ Options) (component.Component, error)

YAMLViewerTab generates a yaml viewer 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)

func (*CRDSection) Reset

func (csd *CRDSection) Reset(ctx context.Context) error

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.

func (*DefaultCRDWatcher) Watch

func (cw *DefaultCRDWatcher) Watch(ctx context.Context) error

Watch watches for CRDs given a configuration.

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 NewList

func NewList(c ListConfig) *List

NewList creates an instance of List.

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.

func (List) Reset

func (b List) Reset(ctx context.Context) error

type ListConfig

type ListConfig struct {
	Path          string
	Title         string
	StoreKey      store.Key
	ListType      func() interface{}
	ObjectType    func() interface{}
	IsClusterWide bool
}

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 NewObject

func NewObject(c ObjectConfig) *Object

NewObject creates an instance of 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.

func (Object) Reset

func (b Object) Reset(ctx context.Context) error

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

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

type PathMatcher struct {
	sync.Mutex
	// contains filtered or unexported fields
}

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) Describe

func (r *Resource) Describe(ctx context.Context, namespace string, options Options) (component.ContentResponse, error)

func (*Resource) List

func (r *Resource) List() *List

func (*Resource) Object

func (r *Resource) Object() *Object

func (*Resource) PathFilters

func (r *Resource) PathFilters() []PathFilter

func (Resource) Reset

func (b Resource) Reset(ctx context.Context) error

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 ResourceOptions struct {
	Path                  string
	ObjectStoreKey        store.Key
	ListType              interface{}
	ObjectType            interface{}
	Titles                ResourceTitle
	DisableResourceViewer bool
	ClusterWide           bool
	IconName              string
}

type ResourceTitle

type ResourceTitle struct {
	List   string
	Object string
}

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

func NewSection(p, title string, describers ...Describer) *Section

NewSection creates a Section.

func (*Section) Component

func (d *Section) Component(ctx context.Context, namespace string, options Options) (*component.List, error)

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.

func (*Section) Reset

func (d *Section) Reset(ctx context.Context) error

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

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 (*StubDescriber) PathFilters

func (d *StubDescriber) PathFilters() []PathFilter

func (*StubDescriber) Reset

func (d *StubDescriber) Reset(ctx context.Context) error

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

type TabsFactory func() ([]Tab, error)

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.

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