model

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2023 License: Apache-2.0, Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const ManagedFieldsOpts = "ManagedFields"

ManagedFieldsOpts tracks managed fields.

View Source
const MaxHistory = 20

MaxHistory tracks max command history.

Variables

View Source
var Registry = map[string]ResourceMeta{

	"references": {
		DAO:      &dao.Reference{},
		Renderer: &render.Reference{},
	},
	"dir": {
		DAO:      &dao.Dir{},
		Renderer: &render.Dir{},
	},
	"pulses": {
		DAO: &dao.Pulse{},
	},
	"helm": {
		DAO:      &dao.Helm{},
		Renderer: &render.Helm{},
	},

	"containers": {
		DAO:          &dao.Container{},
		Renderer:     &render.Container{},
		TreeRenderer: &xray.Container{},
	},
	"contexts": {
		DAO:      &dao.Context{},
		Renderer: &render.Context{},
	},
	"screendumps": {
		DAO:      &dao.ScreenDump{},
		Renderer: &render.ScreenDump{},
	},
	"rbac": {
		DAO:      &dao.Rbac{},
		Renderer: &render.Rbac{},
	},
	"policy": {
		DAO:      &dao.Policy{},
		Renderer: &render.Policy{},
	},
	"users": {
		DAO:      &dao.Subject{},
		Renderer: &render.Subject{},
	},
	"groups": {
		DAO:      &dao.Subject{},
		Renderer: &render.Subject{},
	},
	"portforwards": {
		DAO:      &dao.PortForward{},
		Renderer: &render.PortForward{},
	},
	"benchmarks": {
		DAO:      &dao.Benchmark{},
		Renderer: &render.Benchmark{},
	},
	"aliases": {
		DAO:      &dao.Alias{},
		Renderer: &render.Alias{},
	},
	"popeye": {
		DAO:      &dao.Popeye{},
		Renderer: &render.Popeye{},
	},
	"sanitizer": {
		DAO:          &dao.Popeye{},
		TreeRenderer: &xray.Section{},
	},

	"v1/endpoints": {
		Renderer: &render.Endpoints{},
	},
	"v1/pods": {
		DAO:          &dao.Pod{},
		Renderer:     &render.Pod{},
		TreeRenderer: &xray.Pod{},
	},
	"v1/namespaces": {
		Renderer: &render.Namespace{},
	},
	"v1/nodes": {
		DAO:      &dao.Node{},
		Renderer: &render.Node{},
	},
	"v1/services": {
		DAO:          &dao.Service{},
		Renderer:     &render.Service{},
		TreeRenderer: &xray.Service{},
	},
	"v1/serviceaccounts": {
		Renderer: &render.ServiceAccount{},
	},
	"v1/persistentvolumes": {
		Renderer: &render.PersistentVolume{},
	},
	"v1/persistentvolumeclaims": {
		Renderer: &render.PersistentVolumeClaim{},
	},
	"v1/events": {
		DAO:      &dao.Table{},
		Renderer: &render.Event{},
	},

	"apps/v1/deployments": {
		DAO:          &dao.Deployment{},
		Renderer:     &render.Deployment{},
		TreeRenderer: &xray.Deployment{},
	},
	"apps/v1/replicasets": {
		Renderer:     &render.ReplicaSet{},
		TreeRenderer: &xray.ReplicaSet{},
	},
	"apps/v1/statefulsets": {
		DAO:          &dao.StatefulSet{},
		Renderer:     &render.StatefulSet{},
		TreeRenderer: &xray.StatefulSet{},
	},
	"apps/v1/daemonsets": {
		DAO:          &dao.DaemonSet{},
		Renderer:     &render.DaemonSet{},
		TreeRenderer: &xray.DaemonSet{},
	},

	"networking.k8s.io/v1/networkpolicies": {
		Renderer: &render.NetworkPolicy{},
	},

	"batch/v1beta1/cronjobs": {
		DAO:      &dao.CronJob{},
		Renderer: &render.CronJob{},
	},
	"batch/v1/jobs": {
		DAO:      &dao.Job{},
		Renderer: &render.Job{},
	},

	"apiextensions.k8s.io/v1/customresourcedefinitions": {
		Renderer: &render.CustomResourceDefinition{},
	},

	"storage.k8s.io/v1/storageclasses": {
		Renderer: &render.StorageClass{},
	},

	"policy/v1beta1/poddisruptionbudgets": {
		Renderer: &render.PodDisruptionBudget{},
	},

	"rbac.authorization.k8s.io/v1/clusterroles": {
		DAO:      &dao.Rbac{},
		Renderer: &render.ClusterRole{},
	},
	"rbac.authorization.k8s.io/v1/clusterrolebindings": {
		Renderer: &render.ClusterRoleBinding{},
	},
	"rbac.authorization.k8s.io/v1/roles": {
		Renderer: &render.Role{},
	},
	"rbac.authorization.k8s.io/v1/rolebindings": {
		Renderer: &render.RoleBinding{},
	},
}

Registry tracks resources metadata. BOZO!! Break up deps and merge into single registrar.

Functions

func FQN

func FQN(ns, n string) string

FQN returns a fully qualified resource name.

func MetaFQN

func MetaFQN(m metav1.ObjectMeta) string

MetaFQN returns a fully qualified resource name.

func NewExpBackOff

func NewExpBackOff(ctx context.Context, start, max time.Duration) backoff.BackOffContext

NewExpBackOff returns a new exponential backoff timer.

func NormalizeVersion

func NormalizeVersion(version string) string

NormalizeVersion ensures the version starts with a v.

func Truncate

func Truncate(str string, width int) string

Truncate a string to the given l and suffix ellipsis if needed.

Types

type BuffWatcher

type BuffWatcher interface {
	// BufferCompleted indicates input was accepted.
	BufferCompleted(text, suggestion string)

	// BufferChanged indicates the buffer was changed.
	BufferChanged(text, suggestion string)

	// BufferActive indicates the buff activity changed.
	BufferActive(state bool, kind BufferKind)
}

BuffWatcher represents a command buffer listener.

type BufferKind

type BufferKind int8

BufferKind indicates a buffer type.

const (

	// CommandBuffer represents a command buffer.
	CommandBuffer BufferKind = 1 << iota
	// FilterBuffer represents a filter buffer.
	FilterBuffer
)

type Cluster

type Cluster struct {
	// contains filtered or unexported fields
}

Cluster represents a kubernetes resource.

func NewCluster

func NewCluster(f dao.Factory) *Cluster

NewCluster returns a new cluster info resource.

func (*Cluster) ClusterName

func (c *Cluster) ClusterName() string

ClusterName returns the cluster name.

func (*Cluster) ContextName

func (c *Cluster) ContextName() string

ContextName returns the context name.

func (*Cluster) Metrics

func (c *Cluster) Metrics(ctx context.Context, mx *client.ClusterMetrics) error

Metrics gathers node level metrics and compute utilization percentages.

func (*Cluster) UserName

func (c *Cluster) UserName() string

UserName returns the user name.

func (*Cluster) Version

func (c *Cluster) Version() string

Version returns the current K8s cluster version.

type ClusterInfo

type ClusterInfo struct {
	// contains filtered or unexported fields
}

ClusterInfo models cluster metadata.

func NewClusterInfo

func NewClusterInfo(f dao.Factory, v string) *ClusterInfo

NewClusterInfo returns a new instance.

func (*ClusterInfo) AddListener

func (c *ClusterInfo) AddListener(l ClusterInfoListener)

AddListener adds a new model listener.

func (*ClusterInfo) Refresh

func (c *ClusterInfo) Refresh()

Refresh fetches the latest cluster meta.

func (*ClusterInfo) RemoveListener

func (c *ClusterInfo) RemoveListener(l ClusterInfoListener)

RemoveListener delete a listener from the list.

func (*ClusterInfo) Reset

func (c *ClusterInfo) Reset(f dao.Factory)

Reset resets context and reload.

type ClusterInfoListener

type ClusterInfoListener interface {
	// ClusterInfoChanged notifies the cluster meta was changed.
	ClusterInfoChanged(prev, curr ClusterMeta)

	// ClusterInfoUpdated notifies the cluster meta was updated.
	ClusterInfoUpdated(ClusterMeta)
}

ClusterInfoListener registers a listener for model changes.

type ClusterMeta

type ClusterMeta struct {
	Context, Cluster    string
	User                string
	K9sVer, K9sLatest   string
	K8sVer              string
	Cpu, Mem, Ephemeral int
}

ClusterMeta represents cluster meta data.

func NewClusterMeta

func NewClusterMeta() ClusterMeta

NewClusterMeta returns a new instance.

func (ClusterMeta) Deltas

func (c ClusterMeta) Deltas(n ClusterMeta) bool

Deltas diffs cluster meta return true if different, false otherwise.

type CmdBuff

type CmdBuff struct {
	// contains filtered or unexported fields
}

CmdBuff represents user command input.

func NewCmdBuff

func NewCmdBuff(key rune, kind BufferKind) *CmdBuff

NewCmdBuff returns a new command buffer.

func (*CmdBuff) Add

func (c *CmdBuff) Add(r rune)

Add adds a new character to the buffer.

func (*CmdBuff) AddListener

func (c *CmdBuff) AddListener(w BuffWatcher)

AddListener registers a cmd buffer listener.

func (*CmdBuff) ClearText

func (c *CmdBuff) ClearText(fire bool)

ClearText clears out command buffer.

func (*CmdBuff) Delete

func (c *CmdBuff) Delete()

Delete removes the last character from the buffer.

func (*CmdBuff) Empty

func (c *CmdBuff) Empty() bool

Empty returns true if no cmd, false otherwise.

func (*CmdBuff) GetKind

func (c *CmdBuff) GetKind() BufferKind

GetKind returns the buffer kind.

func (*CmdBuff) GetSuggestion

func (c *CmdBuff) GetSuggestion() string

GetSuggestion returns the current suggestion.

func (*CmdBuff) GetText

func (c *CmdBuff) GetText() string

GetText returns the current text.

func (*CmdBuff) InCmdMode

func (c *CmdBuff) InCmdMode() bool

InCmdMode checks if a command exists and the buffer is active.

func (*CmdBuff) IsActive

func (c *CmdBuff) IsActive() bool

IsActive checks if command buffer is active.

func (*CmdBuff) RemoveListener

func (c *CmdBuff) RemoveListener(l BuffWatcher)

RemoveListener removes a listener.

func (*CmdBuff) Reset

func (c *CmdBuff) Reset()

Reset clears out the command buffer and deactivates it.

func (*CmdBuff) SetActive

func (c *CmdBuff) SetActive(b bool)

SetActive toggles cmd buffer active state.

func (*CmdBuff) SetText

func (c *CmdBuff) SetText(text, suggestion string)

SetText initializes the buffer with a command.

type Commander

type Commander interface {
	// InCmdMode checks if prompt is active.
	InCmdMode() bool
}

Commander tracks prompt status.

type Component

type Component interface {
	Primitive
	Igniter
	Hinter
	Commander
}

Component represents a ui component.

type Cruder

type Cruder interface {
	// List returns a collection of resources.
	List(ctx context.Context, ns string) ([]runtime.Object, error)

	// Get returns a resource instance.
	Get(ctx context.Context, path string) (runtime.Object, error)
}

Cruder performs crud operations.

type Describe

type Describe struct {
	// contains filtered or unexported fields
}

Describe tracks describable resources.

func NewDescribe

func NewDescribe(gvr client.GVR, path string) *Describe

NewDescribe returns a new describe resource model.

func (*Describe) AddListener

func (d *Describe) AddListener(l ResourceViewerListener)

AddListener adds a new model listener.

func (*Describe) ClearFilter

func (d *Describe) ClearFilter()

ClearFilter clear out the filter.

func (*Describe) Filter

func (d *Describe) Filter(q string)

Filter filters the model.

func (*Describe) GetPath

func (d *Describe) GetPath() string

GetPath returns the active resource path.

func (*Describe) Peek

func (d *Describe) Peek() []string

Peek returns current model state.

func (*Describe) Refresh

func (d *Describe) Refresh(ctx context.Context) error

Refresh updates model data.

func (*Describe) RemoveListener

func (d *Describe) RemoveListener(l ResourceViewerListener)

RemoveListener delete a listener from the list.

func (*Describe) SetOptions

func (d *Describe) SetOptions(context.Context, ViewerToggleOpts)

SetOptions toggle model options.

func (*Describe) Watch

func (d *Describe) Watch(ctx context.Context) error

Watch watches for describe data changes.

type Describer

type Describer interface {
	// ToYAML return resource yaml.
	ToYAML(ctx context.Context, path string) (string, error)

	// Describe returns a resource description.
	Describe(client client.Connection, gvr, path string) (string, error)
}

Describer represents a resource describer.

type Filterable

type Filterable interface {
	Filter(string)
	ClearFilter()
}

Filterable represents an entity that can be filtered.

type FishBuff

type FishBuff struct {
	*CmdBuff
	// contains filtered or unexported fields
}

FishBuff represents a suggestion buffer.

func NewFishBuff

func NewFishBuff(key rune, kind BufferKind) *FishBuff

NewFishBuff returns a new command buffer.

func (*FishBuff) Add

func (f *FishBuff) Add(r rune)

Add adds a new character to the buffer.

func (*FishBuff) AutoSuggests

func (f *FishBuff) AutoSuggests() bool

AutoSuggests returns true if model implements auto suggestions.

func (*FishBuff) ClearSuggestions

func (f *FishBuff) ClearSuggestions()

ClearSuggestions clear out all suggestions.

func (*FishBuff) CurrentSuggestion

func (f *FishBuff) CurrentSuggestion() (string, bool)

CurrentSuggestion returns the current suggestion.

func (*FishBuff) Delete

func (f *FishBuff) Delete()

Delete removes the last character from the buffer.

func (*FishBuff) NextSuggestion

func (f *FishBuff) NextSuggestion() (string, bool)

NextSuggestion returns the next suggestion.

func (*FishBuff) Notify

func (f *FishBuff) Notify(delete bool)

Notify publish suggestions to all listeners.

func (*FishBuff) PrevSuggestion

func (f *FishBuff) PrevSuggestion() (string, bool)

PrevSuggestion returns the prev suggestion.

func (*FishBuff) SetSuggestionFn

func (f *FishBuff) SetSuggestionFn(fn SuggestionFunc)

SetSuggestionFn sets up suggestions.

func (*FishBuff) Suggestions

func (f *FishBuff) Suggestions() []string

Suggestions returns suggestions.

type Flash

type Flash struct {
	// contains filtered or unexported fields
}

Flash represents a flash message model.

func NewFlash

func NewFlash(dur time.Duration) *Flash

NewFlash returns a new instance.

func (*Flash) Channel

func (f *Flash) Channel() FlashChan

Channel returns the flash channel.

func (*Flash) Clear

func (f *Flash) Clear()

Clear clears the flash message.

func (*Flash) Err

func (f *Flash) Err(err error)

Err displays an error flash message.

func (*Flash) Errf

func (f *Flash) Errf(fmat string, args ...interface{})

Errf displays a formatted error flash message.

func (*Flash) Info

func (f *Flash) Info(msg string)

Info displays an info flash message.

func (*Flash) Infof

func (f *Flash) Infof(fmat string, args ...interface{})

Infof displays a formatted info flash message.

func (*Flash) SetMessage

func (f *Flash) SetMessage(level FlashLevel, msg string)

SetMessage sets the flash level message.

func (*Flash) Warn

func (f *Flash) Warn(msg string)

Warn displays a warning flash message.

func (*Flash) Warnf

func (f *Flash) Warnf(fmat string, args ...interface{})

Warnf displays a formatted warning flash message.

type FlashChan

type FlashChan chan LevelMessage

FlashChan represents a flash event channel.

type FlashLevel

type FlashLevel int

FlashLevel represents flash message severity.

const (
	// DefaultFlashDelay sets the flash clear delay.
	DefaultFlashDelay = 3 * time.Second

	// FlashInfo represents an info message.
	FlashInfo FlashLevel = iota
	// FlashWarn represents an warning message.
	FlashWarn
	// FlashErr represents an error message.
	FlashErr
)

type FlashListener

type FlashListener interface {
	// FlashChanged notifies the model changed.
	FlashChanged(FlashLevel, string)

	// FlashCleared notifies when the filter changed.
	FlashCleared()
}

FlashListener represents a text model listener.

type Generic

type Generic interface {
	SetTable(*metav1beta1.Table)
	Header(string) render.Header
	Render(interface{}, string, *render.Row) error
}

type Hint

type Hint struct {
	// contains filtered or unexported fields
}

Hint represent a hint model.

func NewHint

func NewHint() *Hint

NewHint return new hint model.

func (*Hint) AddListener

func (h *Hint) AddListener(l HintListener)

AddListener adds a hint listener.

func (*Hint) Peek

func (h *Hint) Peek() MenuHints

Peek returns the model data.

func (*Hint) RemoveListener

func (h *Hint) RemoveListener(l HintListener)

RemoveListener deletes a listener.

func (*Hint) SetHints

func (h *Hint) SetHints(hh MenuHints)

SetHints set model hints.

type HintListener

type HintListener interface {
	HintsChanged(MenuHints)
}

HintListener represents a menu hints listener.

type Hinter

type Hinter interface {
	// Hints returns a collection of menu hints.
	Hints() MenuHints

	// ExtraHints returns additional hints.
	ExtraHints() map[string]string
}

Hinter represent a menu mnemonic provider.

type History

type History struct {
	// contains filtered or unexported fields
}

History represents a command history.

func NewHistory

func NewHistory(limit int) *History

NewHistory returns a new instance.

func (*History) Clear

func (h *History) Clear()

Clear clears out the stack.

func (*History) Empty

func (h *History) Empty() bool

Empty returns true if no history.

func (*History) List

func (h *History) List() []string

List returns the current command history.

func (*History) Push

func (h *History) Push(c string)

Push adds a new item.

type Igniter

type Igniter interface {
	// Start starts a component.
	Init(ctx context.Context) error

	// Start starts a component.
	Start()

	// Stop terminates a component.
	Stop()
}

Igniter represents a runnable view.

type LevelMessage

type LevelMessage struct {
	Level FlashLevel
	Text  string
}

LevelMessage tracks an message and severity.

func (LevelMessage) IsClear

func (l LevelMessage) IsClear() bool

IsClear returns true if message is empty.

type Lister

type Lister interface {
	Cruder

	// Init initializes a resource.
	Init(ns, gvr string, f dao.Factory)
}

Lister represents a resource lister.

type Log

type Log struct {
	// contains filtered or unexported fields
}

Log represents a resource logger.

func NewLog

func NewLog(gvr client.GVR, opts *dao.LogOptions, flushTimeout time.Duration) *Log

NewLog returns a new model.

func (*Log) AddListener

func (l *Log) AddListener(listener LogsListener)

AddListener adds a new model listener.

func (*Log) Append

func (l *Log) Append(line *dao.LogItem)

Append adds a log line.

func (*Log) Clear

func (l *Log) Clear()

Clear the logs.

func (*Log) ClearFilter

func (l *Log) ClearFilter()

ClearFilter resets the log filter if any.

func (*Log) Configure

func (l *Log) Configure(opts *config.Logger)

Configure sets logger configuration.

func (*Log) Filter

func (l *Log) Filter(q string)

Filter filters the model using either fuzzy or regexp.

func (*Log) GVR

func (l *Log) GVR() client.GVR

func (*Log) GetContainer

func (l *Log) GetContainer() string

GetContainer returns the resource container if any or "" otherwise.

func (*Log) GetPath

func (l *Log) GetPath() string

GetPath returns resource path.

func (*Log) HasDefaultContainer

func (l *Log) HasDefaultContainer() bool

HasDefaultContainer returns true if the pod has a default container, false otherwise.

func (*Log) Head

func (l *Log) Head(ctx context.Context)

func (*Log) Init

func (l *Log) Init(f dao.Factory)

Init initializes the model.

func (*Log) IsHead

func (l *Log) IsHead() bool

IsHead returns log head option.

func (*Log) LogOptions

func (l *Log) LogOptions() *dao.LogOptions

func (*Log) Notify

func (l *Log) Notify()

Notify fires of notifications to the listeners.

func (*Log) Refresh

func (l *Log) Refresh()

Refresh refreshes the logs.

func (*Log) RemoveListener

func (l *Log) RemoveListener(listener LogsListener)

RemoveListener delete a listener from the list.

func (*Log) Restart

func (l *Log) Restart(ctx context.Context)

Restart restarts the logger.

func (*Log) Set

func (l *Log) Set(lines *dao.LogItems)

Set sets the log lines (for testing only!)

func (*Log) SetSinceSeconds

func (l *Log) SetSinceSeconds(ctx context.Context, i int64)

SetSinceSeconds sets the logs retrieval time.

func (*Log) SinceSeconds

func (l *Log) SinceSeconds() int64

SinceSeconds returns since seconds option.

func (*Log) Start

func (l *Log) Start(ctx context.Context)

Start starts logging.

func (*Log) Stop

func (l *Log) Stop()

Stop terminates logging.

func (*Log) ToggleAllContainers

func (l *Log) ToggleAllContainers(ctx context.Context)

ToggleAllContainers toggles to show all containers logs.

func (*Log) ToggleShowTimestamp

func (l *Log) ToggleShowTimestamp(b bool)

ToggleShowTimestamp toggles to logs timestamps.

type LogsListener

type LogsListener interface {
	// LogChanged notifies the model changed.
	LogChanged([][]byte)

	// LogCleared indicates logs are cleared.
	LogCleared()

	// LogFailed indicates a log failure.
	LogFailed(error)

	// LogStop indicates logging was canceled.
	LogStop()

	// LogResume indicates loggings has resumed.
	LogResume()

	// LogCanceled indicates no more logs will come.
	LogCanceled()
}

LogsListener represents a log model listener.

type MenuHint struct {
	Mnemonic    string
	Description string
	Visible     bool
}

MenuHint represents keyboard mnemonic.

func (m MenuHint) IsBlank() bool

IsBlank checks if menu hint is a place holder.

func (m MenuHint) String() string

String returns a string representation.

type MenuHints []MenuHint

MenuHints represents a collection of hints.

func (h MenuHints) Len() int

Len returns the hints length.

func (h MenuHints) Less(i, j int) bool

Less returns true if first hint is less than second.

func (h MenuHints) Swap(i, j int)

Swap swaps to elements.

type MetricsServer

MetricsServer gather metrics information from pods and nodes.

type MetricsService

type MetricsService interface {
	HasMetrics() bool
	FetchNodesMetrics(ctx context.Context) (*mv1beta1.NodeMetricsList, error)
	FetchPodsMetrics(ctx context.Context, ns string) (*mv1beta1.PodMetricsList, error)
}

MetricsService calls the metrics server for metrics info.

type Primitive

type Primitive interface {
	tview.Primitive

	// Name returns the view name.
	Name() string
}

Primitive represents a UI primitive.

type Pulse

type Pulse struct {
	// contains filtered or unexported fields
}

Pulse tracks multiple resources health.

func NewPulse

func NewPulse(gvr string) *Pulse

NewPulse returns a new pulse.

func (*Pulse) AddListener

func (p *Pulse) AddListener(l PulseListener)

AddListener adds a listener.

func (*Pulse) GetNamespace

func (p *Pulse) GetNamespace() string

GetNamespace returns the model namespace.

func (*Pulse) Refresh

func (p *Pulse) Refresh(ctx context.Context)

Refresh update the model now.

func (*Pulse) RemoveListener

func (p *Pulse) RemoveListener(l PulseListener)

RemoveListener delete a listener.

func (*Pulse) SetNamespace

func (p *Pulse) SetNamespace(ns string)

SetNamespace sets up model namespace.

func (*Pulse) Watch

func (p *Pulse) Watch(ctx context.Context)

Watch monitors pulses.

type PulseHealth

type PulseHealth struct {
	// contains filtered or unexported fields
}

PulseHealth tracks resources health.

func NewPulseHealth

func NewPulseHealth(f dao.Factory) *PulseHealth

NewPulseHealth returns a new instance.

func (*PulseHealth) List

func (h *PulseHealth) List(ctx context.Context, ns string) ([]runtime.Object, error)

List returns a canned collection of resources health.

type PulseListener

type PulseListener interface {
	// PulseChanged notifies the model data changed.
	PulseChanged(*health.Check)

	// TreeFailed notifies the health check failed.
	PulseFailed(error)
}

PulseListener represents a health model listener.

type Renderer

type Renderer interface {
	// IsGeneric identifies a generic handler.
	IsGeneric() bool

	// Render converts raw resources to tabular data.
	Render(o interface{}, ns string, row *render.Row) error

	// Header returns the resource header.
	Header(ns string) render.Header

	// ColorerFunc returns a row colorer function.
	ColorerFunc() render.ColorerFunc
}

Renderer represents a resource renderer.

type ResourceMeta

type ResourceMeta struct {
	DAO          dao.Accessor
	Renderer     Renderer
	TreeRenderer TreeRenderer
}

ResourceMeta represents model info about a resource.

type ResourceViewer

type ResourceViewer interface {
	GetPath() string
	Filter(string)
	ClearFilter()
	Peek() []string
	SetOptions(context.Context, ViewerToggleOpts)
	Watch(context.Context) error
	Refresh(context.Context) error
	AddListener(ResourceViewerListener)
	RemoveListener(ResourceViewerListener)
}

ResourceViewer represents a viewed resource.

type ResourceViewerListener

type ResourceViewerListener interface {
	ResourceChanged(lines []string, matches fuzzy.Matches)
	ResourceFailed(error)
}

ResourceViewerListener listens to viewing resource events.

type SemVer

type SemVer struct {
	Major, Minor, Patch int
}

SemVer represents a semantic version.

func NewSemVer

func NewSemVer(version string) *SemVer

NewSemVer returns a new semantic version.

func (*SemVer) IsCurrent

func (v *SemVer) IsCurrent(latest *SemVer) bool

IsCurrent asserts if at latest release.

func (*SemVer) String

func (v *SemVer) String() string

String returns version as a string.

type Stack

type Stack struct {
	// contains filtered or unexported fields
}

Stack represents a stacks of components.

func NewStack

func NewStack() *Stack

NewStack returns a new initialized stack.

func (*Stack) AddListener

func (s *Stack) AddListener(l StackListener)

AddListener registers a stack listener.

func (*Stack) Clear

func (s *Stack) Clear()

Clear clear out the stack using pops.

func (*Stack) Dump

func (s *Stack) Dump()

Dump prints out the stack.

func (*Stack) Empty

func (s *Stack) Empty() bool

Empty returns true if the stack is empty.

func (*Stack) Flatten

func (s *Stack) Flatten() []string

Flatten returns a string representation of the component stack.

func (*Stack) IsLast

func (s *Stack) IsLast() bool

IsLast indicates if stack only has one item left.

func (*Stack) Peek

func (s *Stack) Peek() []Component

Peek returns stack state.

func (*Stack) Pop

func (s *Stack) Pop() (Component, bool)

Pop removed the top item and returns it.

func (*Stack) Previous

func (s *Stack) Previous() Component

Previous returns the previous component if any.

func (*Stack) Push

func (s *Stack) Push(c Component)

Push adds a new item.

func (*Stack) RemoveListener

func (s *Stack) RemoveListener(l StackListener)

RemoveListener removes a listener.

func (*Stack) Top

func (s *Stack) Top() Component

Top returns the top most item or nil if the stack is empty.

type StackAction

type StackAction int

StackAction represents an action on the stack.

const (
	// StackPush denotes an add on the stack.
	StackPush StackAction = 1 << iota

	// StackPop denotes a delete on the stack.
	StackPop
)

type StackEvent

type StackEvent struct {
	// Kind represents the event condition.
	Action StackAction

	// Item represents the targeted item.
	Component Component
}

StackEvent represents an operation on a view stack.

type StackListener

type StackListener interface {
	// StackPushed indicates a new item was added.
	StackPushed(Component)

	// StackPopped indicates an item was deleted
	StackPopped(old, new Component)

	// StackTop indicates the top of the stack
	StackTop(Component)
}

StackListener represents a stack listener.

type SuggestionFunc

type SuggestionFunc func(text string) sort.StringSlice

SuggestionFunc produces suggestions.

type SuggestionListener

type SuggestionListener interface {
	BuffWatcher

	// SuggestionChanged notifies suggestion changes.
	SuggestionChanged(text, sugg string)
}

SuggestionListener listens for suggestions.

type Table

type Table struct {
	// contains filtered or unexported fields
}

Table represents a table model.

func NewTable

func NewTable(gvr client.GVR) *Table

NewTable returns a new table model.

func (*Table) AddListener

func (t *Table) AddListener(l TableListener)

AddListener adds a new model listener.

func (*Table) ClusterWide

func (t *Table) ClusterWide() bool

ClusterWide checks if resource is scope for all namespaces.

func (*Table) Count

func (t *Table) Count() int

Count returns the row count.

func (*Table) Delete

func (t *Table) Delete(ctx context.Context, path string, propagation *metav1.DeletionPropagation, force bool) error

Delete deletes a resource.

func (*Table) Empty

func (t *Table) Empty() bool

Empty returns true if no model data.

func (*Table) Get

func (t *Table) Get(ctx context.Context, path string) (runtime.Object, error)

Get returns a resource instance if found, else an error.

func (*Table) GetNamespace

func (t *Table) GetNamespace() string

GetNamespace returns the model namespace.

func (*Table) InNamespace

func (t *Table) InNamespace(ns string) bool

InNamespace checks if current namespace matches desired namespace.

func (*Table) Peek

func (t *Table) Peek() *render.TableData

Peek returns model data.

func (*Table) Refresh

func (t *Table) Refresh(ctx context.Context) error

Refresh updates the table content.

func (*Table) RemoveListener

func (t *Table) RemoveListener(l TableListener)

RemoveListener delete a listener from the list.

func (*Table) SetInstance

func (t *Table) SetInstance(path string)

SetInstance sets a single entry table.

func (*Table) SetLabelFilter

func (t *Table) SetLabelFilter(f string)

SetLabelFilter sets the labels filter.

func (*Table) SetNamespace

func (t *Table) SetNamespace(ns string)

SetNamespace sets up model namespace.

func (*Table) SetRefreshRate

func (t *Table) SetRefreshRate(d time.Duration)

SetRefreshRate sets model refresh duration.

func (*Table) Watch

func (t *Table) Watch(ctx context.Context) error

Watch initiates model updates.

type TableListener

type TableListener interface {
	// TableDataChanged notifies the model data changed.
	TableDataChanged(*render.TableData)

	// TableLoadFailed notifies the load failed.
	TableLoadFailed(error)
}

TableListener represents a table model listener.

type Text

type Text struct {
	// contains filtered or unexported fields
}

Text represents a text model.

func NewText

func NewText() *Text

NewText returns a new model.

func (*Text) AddListener

func (t *Text) AddListener(listener TextListener)

AddListener adds a new model listener.

func (*Text) ClearFilter

func (t *Text) ClearFilter()

ClearFilter clear out filter.

func (*Text) Filter

func (t *Text) Filter(q string)

Filter filters out the text.

func (*Text) Peek

func (t *Text) Peek() []string

Peek returns the current model state.

func (*Text) RemoveListener

func (t *Text) RemoveListener(listener TextListener)

RemoveListener delete a listener from the list.

func (*Text) SetText

func (t *Text) SetText(buff string)

SetText sets the current model content.

type TextListener

type TextListener interface {
	// TextChanged notifies the model changed.
	TextChanged([]string)

	// TextFiltered notifies when the filter changed.
	TextFiltered([]string, fuzzy.Matches)
}

TextListener represents a text model listener.

type Textable

type Textable interface {
	Peek() []string
	SetText(string)
	AddListener(TextListener)
	RemoveListener(TextListener)
}

Textable represents a text resource.

type Tree

type Tree struct {
	// contains filtered or unexported fields
}

Tree represents a tree model.

func NewTree

func NewTree(gvr client.GVR) *Tree

NewTree returns a new model.

func (*Tree) AddListener

func (t *Tree) AddListener(l TreeListener)

AddListener adds a listener.

func (*Tree) ClearFilter

func (t *Tree) ClearFilter()

ClearFilter clears out active filter.

func (*Tree) ClusterWide

func (t *Tree) ClusterWide() bool

ClusterWide checks if resource is scope for all namespaces.

func (*Tree) Describe

func (t *Tree) Describe(ctx context.Context, gvr, path string) (string, error)

Describe describes a given resource.

func (*Tree) Empty

func (t *Tree) Empty() bool

Empty return true if no model data.

func (*Tree) GetNamespace

func (t *Tree) GetNamespace() string

GetNamespace returns the model namespace.

func (*Tree) InNamespace

func (t *Tree) InNamespace(ns string) bool

InNamespace checks if current namespace matches desired namespace.

func (*Tree) Peek

func (t *Tree) Peek() *xray.TreeNode

Peek returns model data.

func (*Tree) Refresh

func (t *Tree) Refresh(ctx context.Context)

Refresh update the model now.

func (*Tree) RemoveListener

func (t *Tree) RemoveListener(l TreeListener)

RemoveListener delete a listener.

func (*Tree) SetFilter

func (t *Tree) SetFilter(q string)

SetFilter sets the current filter.

func (*Tree) SetNamespace

func (t *Tree) SetNamespace(ns string)

SetNamespace sets up model namespace.

func (*Tree) SetRefreshRate

func (t *Tree) SetRefreshRate(d time.Duration)

SetRefreshRate sets model refresh duration.

func (*Tree) ToYAML

func (t *Tree) ToYAML(ctx context.Context, gvr, path string) (string, error)

ToYAML returns a resource yaml.

func (*Tree) Watch

func (t *Tree) Watch(ctx context.Context)

Watch initiates model updates.

type TreeListener

type TreeListener interface {
	// TreeChanged notifies the model data changed.
	TreeChanged(*xray.TreeNode)

	// TreeLoadFailed notifies the load failed.
	TreeLoadFailed(error)
}

TreeListener represents a tree model listener.

type TreeRenderer

type TreeRenderer interface {
	Render(ctx context.Context, ns string, o interface{}) error
}

TreeRenderer represents an xray node.

type Values

type Values struct {
	// contains filtered or unexported fields
}

Values tracks Helm values representations.

func NewValues

func NewValues(gvr client.GVR, path string) *Values

NewValues return a new Helm values resource model.

func (*Values) AddListener

func (v *Values) AddListener(l ResourceViewerListener)

AddListener adds a new model listener.

func (*Values) ClearFilter

func (v *Values) ClearFilter()

ClearFilter clear out the filter.

func (*Values) Filter

func (v *Values) Filter(q string)

Filter filters the model.

func (*Values) GetPath

func (v *Values) GetPath() string

GetPath returns the active resource path.

func (*Values) Peek

func (v *Values) Peek() []string

Peek returns the current model data.

func (*Values) Refresh

func (v *Values) Refresh(ctx context.Context) error

Refresh updates model data.

func (*Values) RemoveListener

func (v *Values) RemoveListener(l ResourceViewerListener)

RemoveListener delete a listener from the list.

func (*Values) SetOptions

func (v *Values) SetOptions(ctx context.Context, opts ViewerToggleOpts)

SetOptions toggle model options.

func (*Values) ToggleValues

func (v *Values) ToggleValues()

ToggleValues toggles between user supplied values and computed values.

func (*Values) Watch

func (v *Values) Watch(ctx context.Context) error

Watch watches for Values changes.

type ViewerToggleOpts

type ViewerToggleOpts map[string]bool

ViewerToggleOpts represents a collection of viewing options.

type YAML

type YAML struct {
	// contains filtered or unexported fields
}

YAML tracks yaml resource representations.

func NewYAML

func NewYAML(gvr client.GVR, path string) *YAML

NewYAML return a new yaml resource model.

func (*YAML) AddListener

func (y *YAML) AddListener(l ResourceViewerListener)

AddListener adds a new model listener.

func (*YAML) ClearFilter

func (y *YAML) ClearFilter()

ClearFilter clear out the filter.

func (*YAML) Filter

func (y *YAML) Filter(q string)

Filter filters the model.

func (*YAML) GetPath

func (y *YAML) GetPath() string

GetPath returns the active resource path.

func (*YAML) Peek

func (y *YAML) Peek() []string

Peek returns the current model data.

func (*YAML) Refresh

func (y *YAML) Refresh(ctx context.Context) error

Refresh updates model data.

func (*YAML) RemoveListener

func (y *YAML) RemoveListener(l ResourceViewerListener)

RemoveListener delete a listener from the list.

func (*YAML) SetOptions

func (y *YAML) SetOptions(ctx context.Context, opts ViewerToggleOpts)

SetOptions toggle model options.

func (*YAML) ToYAML

func (y *YAML) ToYAML(ctx context.Context, gvr client.GVR, path string, showManaged bool) (string, error)

ToYAML returns a resource yaml.

func (*YAML) Watch

func (y *YAML) Watch(ctx context.Context) error

Watch watches for YAML changes.

Jump to

Keyboard shortcuts

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