Documentation
¶
Overview ¶
Package outpututil provides shared utilities for rendering resource outputs (computed fields from spec data) across different UI components.
Index ¶
- func ConvertSpecPathToLookupPath(fieldPath string) string
- func CountNonComputedFields(specData *core.MappingNode, computedFields []string) int
- func FormatDuration(milliseconds float64) string
- func IsValidOutputValue(value string) bool
- func RenderOutputFields(fields []OutputField, width int, s *styles.Styles) string
- func RenderOutputFieldsWithLabel(fields []OutputField, label string, width int, s *styles.Styles) string
- func RenderOutputsFromState(resourceState *state.ResourceState, width int, s *styles.Styles) string
- func RenderSpecFields(specData *core.MappingNode, computedFields []string, width int, ...) string
- func RenderSpecHint(specData *core.MappingNode, computedFields []string, s *styles.Styles) string
- func WrapText(text string, width int) string
- func WrapTextLines(text string, width int) []string
- type ExportField
- type OutputField
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertSpecPathToLookupPath ¶
ConvertSpecPathToLookupPath converts a spec field path (e.g., "spec.id") to a lookup path for core.GetPathValue (e.g., "$.id").
func CountNonComputedFields ¶
func CountNonComputedFields(specData *core.MappingNode, computedFields []string) int
CountNonComputedFields counts the number of non-computed fields in spec data.
func FormatDuration ¶
FormatDuration formats a duration in milliseconds to a human-friendly string. - < 1000ms: "XXXms" - < 60s: "X.XXs" - >= 60s: "Xm Ys"
func IsValidOutputValue ¶
IsValidOutputValue checks if a formatted value should be displayed.
func RenderOutputFields ¶
func RenderOutputFields(fields []OutputField, width int, s *styles.Styles) string
RenderOutputFields renders a sorted list of output fields with wrapping support. Uses "Current Outputs:" as the default label.
func RenderOutputFieldsWithLabel ¶
func RenderOutputFieldsWithLabel(fields []OutputField, label string, width int, s *styles.Styles) string
RenderOutputFieldsWithLabel renders a sorted list of output fields with a custom label.
func RenderOutputsFromState ¶
func RenderOutputsFromState( resourceState *state.ResourceState, width int, s *styles.Styles, ) string
RenderOutputsFromState renders outputs from ResourceState. Uses ResourceState.ComputedFields to determine which fields to display.
func RenderSpecFields ¶
func RenderSpecFields(specData *core.MappingNode, computedFields []string, width int, s *styles.Styles) string
RenderSpecFields renders non-computed spec fields with a label.
func RenderSpecHint ¶
RenderSpecHint renders a hint line showing the spec field count and keyboard shortcut.
func WrapTextLines ¶
WrapTextLines wraps text to fit within the specified width, returning lines as a slice. Uses word-boundary wrapping: breaks at spaces when possible, otherwise at width.
Types ¶
type ExportField ¶
ExportField holds export data for rendering, including metadata about the export.
func CollectExportFields ¶
func CollectExportFields(exports map[string]*state.ExportState) []ExportField
CollectExportFields extracts exports from instance state, sorted alphabetically by name.
func CollectExportFieldsPretty ¶
func CollectExportFieldsPretty(exports map[string]*state.ExportState) []ExportField
CollectExportFieldsPretty extracts exports with pretty-printed JSON values.
type OutputField ¶
OutputField holds a name-value pair for output rendering.
func CollectNonComputedFields ¶
func CollectNonComputedFields(specData *core.MappingNode, computedFields []string) []OutputField
CollectNonComputedFields extracts all fields from spec data excluding computed fields. This is used to show the user-provided spec without the computed outputs. Fields are returned sorted alphabetically by name for consistent display.
func CollectNonComputedFieldsPretty ¶
func CollectNonComputedFieldsPretty(specData *core.MappingNode, computedFields []string) []OutputField
CollectNonComputedFieldsPretty extracts all fields from spec data excluding computed fields, using pretty-printed JSON for complex nested structures. Fields are returned sorted alphabetically by name for consistent display.
func CollectOutputFields ¶
func CollectOutputFields(specData *core.MappingNode, computedFields []string) []OutputField
CollectOutputFields extracts field entries from spec data. Uses computedFields paths if provided, otherwise extracts all top-level fields.