output

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FormatPretty  = "pretty"
	FormatCompact = "compact"
	FormatJSON    = "json"
	FormatHTML    = "html"
)

Format constants for output mode.

View Source
const FormatSARIF = "sarif"

FormatSARIF is the SARIF output format constant.

Variables

View Source
var ColorEnabled = true

ColorEnabled controls whether ANSI colors are emitted. Respects NO_COLOR env var (https://no-color.org/) and --no-color flag.

Functions

func Bar

func Bar() string

Bar returns the styled separator bar.

func Dimmed

func Dimmed(text string) string

Dimmed returns dimmed text for secondary info.

func DisableColor

func DisableColor()

DisableColor turns off color output globally.

func FindingsSummaryLine added in v0.7.0

func FindingsSummaryLine(counts map[string]int, total int) string

FindingsSummaryLine returns "[TOTAL: N | CRITICAL: N | HIGH: N | ...]".

func Header(text string) string

Header returns bold text for section headers.

func Prefix

func Prefix() string

Prefix returns the styled [terraview] prefix in Terraform's signature purple.

func PrintFindingsTable added in v0.7.0

func PrintFindingsTable(findings []rules.Finding, br bool)

PrintFindingsTable renders findings as an Orca-style bordered table.

func PrintScoreDecomposition added in v0.7.0

func PrintScoreDecomposition(d *scoring.ScoreDecomposition, br bool)

PrintScoreDecomposition prints the full score decomposition to stdout. Exposed so commands like `terraview status --explain-scores` can reuse the same rendering used by `terraview scan`.

func Resource

func Resource(text string) string

Resource returns the styled resource name.

func ScanStatusLine added in v0.7.0

func ScanStatusLine(exitCode int, br bool) string

ScanStatusLine returns the "SCAN STATUS: FAILED/WARNING/PASSED — detail" line.

func ScoreColor

func ScoreColor(score float64) string

ScoreColor returns the score colored by value.

func SectionTitle added in v0.7.0

func SectionTitle(text string) string

SectionTitle returns a bold+underline cyan section title (Orca-style).

func SevColor

func SevColor(severity string) string

SevColor returns the colored severity label.

func SevCountLine

func SevCountLine(severity string, label string, count int) string

SevCountLine returns a colored severity label with count for the summary.

func SourceHeader

func SourceHeader(text string) string

SourceHeader returns the styled source group header.

func SpinWhile

func SpinWhile[T any](message string, fn func() (T, error)) (T, error)

SpinWhile is a convenience helper that runs fn while displaying a spinner. It returns the values returned by fn. The spinner is stopped automatically with the appropriate success/failure indicator.

Usage:

result, err := output.SpinWhile("Running terraform plan...", func() (string, error) {
    return e.runSilent("plan", "-out=tfplan")
})

func SpinWhileE

func SpinWhileE(message string, fn func() error) error

SpinWhileE is like SpinWhile but for functions that return only an error.

func VerdictSafe

func VerdictSafe(text string) string

VerdictSafe returns the styled SAFE verdict.

func VerdictUnsafe

func VerdictUnsafe(text string) string

VerdictUnsafe returns the styled NOT SAFE verdict.

Types

type SARIFArtifactLocation

type SARIFArtifactLocation struct {
	URI string `json:"uri"`
}

SARIFArtifactLocation is the file URI.

type SARIFDefaultConfig

type SARIFDefaultConfig struct {
	Level string `json:"level"`
}

SARIFDefaultConfig is the default severity config.

type SARIFDriver

type SARIFDriver struct {
	Name           string      `json:"name"`
	Version        string      `json:"version"`
	InformationURI string      `json:"informationUri"`
	Rules          []SARIFRule `json:"rules"`
}

SARIFDriver is the tool driver with rules.

type SARIFLocation

type SARIFLocation struct {
	PhysicalLocation SARIFPhysicalLocation `json:"physicalLocation"`
	Message          *SARIFMessage         `json:"message,omitempty"`
}

SARIFLocation is a finding location.

type SARIFMessage

type SARIFMessage struct {
	Text string `json:"text"`
}

SARIFMessage is a text message.

type SARIFMultiformatMessage added in v0.5.0

type SARIFMultiformatMessage struct {
	Text string `json:"text"`
}

SARIFMultiformatMessage supports text (and optionally markdown) content.

type SARIFPhysicalLocation

type SARIFPhysicalLocation struct {
	ArtifactLocation SARIFArtifactLocation `json:"artifactLocation"`
}

SARIFPhysicalLocation points to a specific file.

type SARIFReport

type SARIFReport struct {
	Schema  string     `json:"$schema"`
	Version string     `json:"version"`
	Runs    []SARIFRun `json:"runs"`
}

SARIFReport is the top-level SARIF 2.1.0 structure.

type SARIFResult

type SARIFResult struct {
	RuleID    string          `json:"ruleId"`
	RuleIndex int             `json:"ruleIndex"`
	Level     string          `json:"level"`
	Message   SARIFMessage    `json:"message"`
	Locations []SARIFLocation `json:"locations,omitempty"`
}

SARIFResult is a single finding result.

type SARIFRule

type SARIFRule struct {
	ID               string                   `json:"id"`
	Name             string                   `json:"name"`
	ShortDescription SARIFMessage             `json:"shortDescription"`
	DefaultConfig    SARIFDefaultConfig       `json:"defaultConfiguration"`
	Help             *SARIFMultiformatMessage `json:"help,omitempty"`
	Properties       SARIFRuleProps           `json:"properties,omitempty"`
}

SARIFRule is a rule definition in SARIF.

type SARIFRuleProps

type SARIFRuleProps struct {
	Category string `json:"category,omitempty"`
}

SARIFRuleProps holds extra rule properties.

type SARIFRun

type SARIFRun struct {
	Tool    SARIFTool     `json:"tool"`
	Results []SARIFResult `json:"results"`
}

SARIFRun represents a single analysis run.

type SARIFTool

type SARIFTool struct {
	Driver SARIFDriver `json:"driver"`
}

SARIFTool describes the analysis tool.

type Spinner

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

Spinner displays an animated spinner in the terminal while a long-running operation is executing. It respects the global ColorEnabled flag.

func NewSpinner

func NewSpinner(message string) *Spinner

NewSpinner creates a Spinner with the given status message. When stderr is not a terminal (CI, pipe, 2>&1), the spinner is created in noop mode: Start() prints a single log line and Stop() prints the result — no animation frames are emitted.

func (*Spinner) SetMessage added in v0.10.0

func (s *Spinner) SetMessage(msg string)

SetMessage atomically swaps the status text shown next to the animated frame. Safe to call concurrently from any goroutine while the spinner is running.

In noop mode (non-TTY/CI), prints a fresh log line so the user still gets progress feedback — without this, long-running ops in CI look hung.

func (*Spinner) Start

func (s *Spinner) Start()

Start begins the spinner animation in a background goroutine. In noop mode (non-TTY), prints a single status line instead.

func (*Spinner) Stop

func (s *Spinner) Stop(success bool)

Stop halts the spinner and prints a final status line.

type Writer

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

Writer generates output files from review results.

func NewWriterWithConfig

func NewWriterWithConfig(config WriterConfig) *Writer

NewWriterWithConfig creates a Writer with the given config.

func (*Writer) PrintSummary

func (w *Writer) PrintSummary(result aggregator.ReviewResult)

PrintSummary prints the review summary to stdout.

func (*Writer) WriteHTML added in v0.7.0

func (w *Writer) WriteHTML(result aggregator.ReviewResult, path string) error

WriteHTML writes the review result as a self-contained HTML report.

func (*Writer) WriteJSON

func (w *Writer) WriteJSON(result aggregator.ReviewResult, path string) error

WriteJSON writes the review result as structured JSON to the given file path. The parent directory is created automatically if it does not exist.

func (*Writer) WriteJSONWriter added in v0.9.0

func (w *Writer) WriteJSONWriter(result aggregator.ReviewResult, dst io.Writer) error

WriteJSONWriter serializes the review result as JSON to an arbitrary io.Writer. Used when --format json is requested without an explicit -o directory (stdout).

func (*Writer) WriteMarkdown

func (w *Writer) WriteMarkdown(result aggregator.ReviewResult, path string) error

WriteMarkdown writes the review result as a formatted Markdown report.

func (*Writer) WriteSARIF

func (w *Writer) WriteSARIF(result aggregator.ReviewResult, path string) error

WriteSARIF writes the review result as a SARIF 2.1.0 report to the given file path. The parent directory is created automatically if it does not exist.

func (*Writer) WriteSARIFWriter added in v0.9.0

func (w *Writer) WriteSARIFWriter(result aggregator.ReviewResult, dst io.Writer) error

WriteSARIFWriter serializes the review result as SARIF to an arbitrary io.Writer. Used when --format sarif is requested without an explicit -o directory (stdout).

type WriterConfig

type WriterConfig struct {
	Format        string // "pretty", "compact", "json"
	Lang          string // "pt-BR" for Brazilian Portuguese
	Version       string // application version for SARIF reports
	ExplainScores bool   // show detailed score decomposition
}

WriterConfig configures output behavior.

func (WriterConfig) IsBR

func (c WriterConfig) IsBR() bool

IsBR returns true if output should be in Brazilian Portuguese.

func (WriterConfig) IsCompact

func (c WriterConfig) IsCompact() bool

IsCompact returns true if format is compact.

func (WriterConfig) IsJSON

func (c WriterConfig) IsJSON() bool

IsJSON returns true if format is json-only.

Jump to

Keyboard shortcuts

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