describer

package
v0.0.0-...-389e7ce Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2019 License: Apache-2.0 Imports: 39 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)

func DeleteCRD

func DeleteCRD(ctx context.Context, crd *unstructured.Unstructured, pm *PathMatcher, crdSection *CRDSection, m module.Module, s store.Store)

func LoadObject

func LoadObject(ctx context.Context, objectStore store.Store, 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, namespace string, fields map[string]string, objectStoreKeys []store.Key) (*unstructured.UnstructuredList, error)

loadObjects loads objects from the object store sorted by their name.

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, objectStore store.Store) (*DefaultCRDWatcher, error)

NewDefaultCRDWatcher creates an instance of DefaultCRDWatcher.

func (*DefaultCRDWatcher) Watch

func (cw *DefaultCRDWatcher) Watch(ctx context.Context, watchConfig *config.CRDWatchConfig) 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
	IconName      string
	IconSource    string
}

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.

func (*Object) PathFilters

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

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
	DisableResourceViewer bool
	IconName              string
	IconSource            string
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL