simulation

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package simulation provides simulated Kubernetes resource data for the TUI. It creates realistic resource histories with various scenarios (rollouts, CrashLoopBackOff, operator reconcile bursts, reconcile loops, configuration drift) and provides live simulation via tea.Cmd that generates new revisions at random intervals.

The package provides a Store (implementing tui.Store) and a Simulator (implementing tui.Simulator). Use New() to create a fully-populated Store, then pass it to tui.NewApp() with tui.WithSimulator().

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store is an in-memory tui.Store implementation for simulation and testing. It also implements tui.Simulator so it can generate live data.

func New

func New() *Store

New creates a realistic set of Kubernetes resources with revision histories for the --simulate mode. The returned Store implements tui.Store and tui.Simulator.

func NewStore

func NewStore(
	resources map[string]*resource.Data,
	timeline []resource.TimelineEntry,
	kindGroups []*resource.KindGroup,
	clusterResourceTypes []resource.Kind,
) *Store

NewStore creates a Store from pre-built data.

func (*Store) AddRevision

func (s *Store) AddRevision(resourceUID string, rev resource.Revision)

func (*Store) AddWatchKind

func (s *Store) AddWatchKind(rk resource.Kind) []*resource.Data

func (*Store) AllResources

func (s *Store) AllResources() []*resource.Data

func (*Store) FilterResources

func (s *Store) FilterResources(expr string) []*resource.Data

func (*Store) FilterTimeline

func (s *Store) FilterTimeline(expr string, starredOnly bool) []resource.TimelineEntry

func (*Store) ForEachResource

func (s *Store) ForEachResource(fn func(uid string, rd *resource.Data))

func (*Store) GenerateRevision

func (s *Store) GenerateRevision(rd *resource.Data) resource.Revision

GenerateRevision creates a new revision for the given resource. It is tagged ADDED for a resource's first revision and MODIFIED thereafter.

func (*Store) GetResource

func (s *Store) GetResource(uid string) *resource.Data

func (*Store) KindGroups

func (s *Store) KindGroups() []*resource.KindGroup

func (*Store) RebuildKindGroups

func (s *Store) RebuildKindGroups()

func (*Store) RemoveWatchKind

func (s *Store) RemoveWatchKind(kind string)

func (*Store) ResourceCountByKind

func (s *Store) ResourceCountByKind(kind string) int

func (*Store) RevisionCountByKind

func (s *Store) RevisionCountByKind(kind string) int

func (*Store) ScheduleNextTick

func (s *Store) ScheduleNextTick(epoch uint64) tea.Cmd

ScheduleNextTick returns a tea.Cmd that generates a SimulationTickMsg for a random resource after a 3-5 second delay. The epoch is echoed back in the message so the App can discard ticks from a superseded chain.

func (*Store) StarredResources

func (s *Store) StarredResources() []*resource.Data

func (*Store) Timeline

func (s *Store) Timeline() []resource.TimelineEntry

func (*Store) ToggleStar

func (s *Store) ToggleStar(uid string) bool

func (*Store) TotalResourceCount

func (s *Store) TotalResourceCount() int

func (*Store) TotalRevisionCount

func (s *Store) TotalRevisionCount() int

func (*Store) UnwatchedKinds

func (s *Store) UnwatchedKinds() []resource.Kind

func (*Store) WatchedKinds

func (s *Store) WatchedKinds() []string

Jump to

Keyboard shortcuts

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