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 ¶
- type Store
- func (s *Store) AddRevision(resourceUID string, rev resource.Revision)
- func (s *Store) AddWatchKind(rk resource.Kind) []*resource.Data
- func (s *Store) AllResources() []*resource.Data
- func (s *Store) FilterResources(expr string) []*resource.Data
- func (s *Store) FilterTimeline(expr string, starredOnly bool) []resource.TimelineEntry
- func (s *Store) ForEachResource(fn func(uid string, rd *resource.Data))
- func (s *Store) GenerateRevision(rd *resource.Data) resource.Revision
- func (s *Store) GetResource(uid string) *resource.Data
- func (s *Store) KindGroups() []*resource.KindGroup
- func (s *Store) RebuildKindGroups()
- func (s *Store) RemoveWatchKind(kind string)
- func (s *Store) ResourceCountByKind(kind string) int
- func (s *Store) RevisionCountByKind(kind string) int
- func (s *Store) ScheduleNextTick(epoch uint64) tea.Cmd
- func (s *Store) StarredResources() []*resource.Data
- func (s *Store) Timeline() []resource.TimelineEntry
- func (s *Store) ToggleStar(uid string) bool
- func (s *Store) TotalResourceCount() int
- func (s *Store) TotalRevisionCount() int
- func (s *Store) UnwatchedKinds() []resource.Kind
- func (s *Store) WatchedKinds() []string
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) AllResources ¶
func (*Store) FilterTimeline ¶
func (s *Store) FilterTimeline(expr string, starredOnly bool) []resource.TimelineEntry
func (*Store) ForEachResource ¶
func (*Store) GenerateRevision ¶
GenerateRevision creates a new revision for the given resource. It is tagged ADDED for a resource's first revision and MODIFIED thereafter.
func (*Store) KindGroups ¶
func (*Store) RebuildKindGroups ¶
func (s *Store) RebuildKindGroups()
func (*Store) RemoveWatchKind ¶
func (*Store) ResourceCountByKind ¶
func (*Store) RevisionCountByKind ¶
func (*Store) ScheduleNextTick ¶
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 (*Store) Timeline ¶
func (s *Store) Timeline() []resource.TimelineEntry