column

package
v1.201.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildColumnFuncMap

func BuildColumnFuncMap() template.FuncMap

BuildColumnFuncMap returns template functions for column templates. These functions are safe for use in column value extraction.

Types

type Config

type Config struct {
	Name  string `yaml:"name" json:"name" mapstructure:"name"`    // Display header
	Value string `yaml:"value" json:"value" mapstructure:"value"` // Go template string
	Width int    `yaml:"width" json:"width" mapstructure:"width"` // Optional width override
}

Config defines a column with name, Go template for value extraction, and optional width.

type Selector

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

Selector manages column extraction with template evaluation. Templates are evaluated during Extract(), not at config load time.

func NewSelector

func NewSelector(configs []Config, funcMap template.FuncMap) (*Selector, error)

NewSelector creates a selector with Go template support. Templates are pre-parsed for performance but NOT evaluated until Extract(). FuncMap should include functions like atmos.Component, toString, get, etc.

func (*Selector) Extract

func (s *Selector) Extract(data []map[string]any) (headers []string, rows [][]string, err error)

Extract evaluates templates against data and returns table rows. ⚠️ CRITICAL: This is where Go template evaluation happens (NOT at config load). Each row is processed with its full data as template context.

func (*Selector) Headers

func (s *Selector) Headers() []string

Headers returns the header row based on selected columns.

func (*Selector) Select

func (s *Selector) Select(columnNames []string) error

Select restricts which columns to display. Pass nil or empty slice to display all columns.

type TemplateContext

type TemplateContext struct {
	// Standard fields available in all templates
	AtmosComponent     string `json:"atmos_component"`
	AtmosStack         string `json:"atmos_stack"`
	AtmosComponentType string `json:"atmos_component_type"`

	// Component configuration
	Vars     map[string]any `json:"vars"`
	Settings map[string]any `json:"settings"`
	Metadata map[string]any `json:"metadata"`
	Env      map[string]any `json:"env"`

	// Flags
	Enabled  bool `json:"enabled"`
	Locked   bool `json:"locked"`
	Abstract bool `json:"abstract"`

	// Full raw data for advanced templates
	Raw map[string]any `json:"raw"`
}

TemplateContext provides data available to column templates during evaluation.

Jump to

Keyboard shortcuts

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