monitor

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package monitor provides TUI rendering and exit-code logic for trustwatch.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExitCode

func ExitCode(snap store.Snapshot) int

ExitCode returns a process exit code based on the worst finding in a snapshot.

0 = no problems
1 = warnings exist
2 = critical problems
3 = discovery/probe errors

func FormatExpiresIn

func FormatExpiresIn(notAfter, now time.Time) string

FormatExpiresIn returns a human-readable relative time (plain text).

func PlainText

func PlainText(snap store.Snapshot) string

PlainText returns a non-interactive text representation for piped output.

func WriteJSON added in v0.1.3

func WriteJSON(w io.Writer, snap store.Snapshot, exitCode int) error

WriteJSON serializes a NowOutput envelope to w.

Types

type Model

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

Model is the BubbleTea model for the now TUI.

func NewModel

func NewModel(snap store.Snapshot, kubeContext string) *Model

NewModel creates a TUI model from a completed snapshot.

func (*Model) Init

func (m *Model) Init() tea.Cmd

Init satisfies tea.Model.

func (*Model) Update

func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles key events.

func (*Model) View

func (m *Model) View() string

View renders the full TUI.

type NowOutput added in v0.1.3

type NowOutput struct {
	Snapshot store.Snapshot `json:"snapshot"`
	ExitCode int            `json:"exitCode"`
}

NowOutput is the JSON envelope for `trustwatch now --output json`. Wraps the snapshot with exit-code metadata without polluting the Snapshot type used by the serve-mode /api/v1/snapshot endpoint.

Jump to

Keyboard shortcuts

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