model

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Registry = map[string]ResourceMeta{
	internal.LowercaseEc2: {
		DAO:      &dao.EC2{},
		Renderer: &render.EC2{},
	},
	internal.LowercaseS3: {
		DAO:      &dao.S3{},
		Renderer: &render.S3{},
	},
	internal.LowercaseSg: {
		DAO:      &dao.SG{},
		Renderer: &render.SG{},
	},
	internal.Object: {
		DAO:      &dao.BObj{},
		Renderer: &render.BObj{},
	},
	internal.LowercaseIamUser: {
		DAO:      &dao.IAMU{},
		Renderer: &render.IAMU{},
	},
	internal.LowercaseIamGroup: {
		DAO:      &dao.IAMUG{},
		Renderer: &render.IAMUG{},
	},
	internal.LowercaseIamRole: {
		DAO:      &dao.IamRole{},
		Renderer: &render.IamRole{},
	},
	internal.UserPolicy: {
		DAO:      &dao.IAMUP{},
		Renderer: &render.IamUserPloicy{},
	},
	internal.LowercaseEBS: {
		DAO:      &dao.EBS{},
		Renderer: &render.EBS{},
	},
	internal.UserGroupPolicy: {
		DAO:      &dao.IAMUGP{},
		Renderer: &render.IamUserGroupPloicy{},
	},
	internal.RolePolicy: {
		DAO:      &dao.IamRolePloicy{},
		Renderer: &render.IamRolePloicy{},
	},
	internal.GroupUsers: {
		DAO:      &dao.IamGroupUser{},
		Renderer: &render.IamGroupUser{},
	},
	internal.LowercaseEc2Snapshot: {
		DAO:      &dao.EC2S{},
		Renderer: &render.EC2S{},
	},
	internal.LowercaseEc2Image: {
		DAO:      &dao.EC2I{},
		Renderer: &render.EC2I{},
	},
	internal.LowercaseSQS: {
		DAO:      &dao.SQS{},
		Renderer: &render.SQS{},
	},
	internal.LowercaseVPC: {
		DAO:      &dao.VPC{},
		Renderer: &render.VPC{},
	},
	internal.LowercaseSubnet: {
		DAO:      &dao.Subnet{},
		Renderer: &render.Subnet{},
	},
	internal.LowercaseLamda: {
		DAO:      &dao.Lambda{},
		Renderer: &render.Lambda{},
	},
}

Functions

func NewExpBackOff

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

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

type Component interface {
	Primitive
	Igniter
	Hinter
}

Component represents a ui component.

type Describe

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

Describe tracks describable resources.

func NewDescribe

func NewDescribe(res string, 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 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 = 2 * 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 Hinter

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

Hinter represent a menu mnemonic provider.

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

type Primitive interface {
	tview.Primitive

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

Primitive represents a UI primitive.

type Renderer

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

	// Header returns the resource header.
	Header() render.Header
}

Renderer represents a resource renderer.

type ResourceMeta

type ResourceMeta struct {
	DAO      dao.Accessor
	Renderer Renderer
}

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

type ResourceViewerListener

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

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(res string) *Table

NewTable returns a new table model.

func (*Table) AddListener

func (t *Table) AddListener(l TableListener)

AddListener adds a new model listener.

func (*Table) Count

func (t *Table) Count() int

Count returns the row count.

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) (dao.Object, error)

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

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

TableListener represents a table model listener.

type ViewerToggleOpts

type ViewerToggleOpts map[string]bool

Jump to

Keyboard shortcuts

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