controldisplay

package
v0.14.0-alpha.20 Latest Latest
Warning

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

Go to latest
Published: May 4, 2022 License: AGPL-3.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const MaxColumns = 200

Variables

View Source
var ColorSchemes = map[string]*ControlColorSchemaDefinition{
	"dark": {
		GroupTitle:           "bold-bright-white",
		Severity:             "bold-bright-yellow",
		CountZeroFail:        "gray1",
		CountZeroFailDivider: "gray1",
		CountDivider:         "gray2",
		CountFail:            "bold-bright-red",
		CountTotal:           "bright-white",
		CountTotalAllPassed:  "bold-bright-green",
		CountGraphFail:       "bright-red",
		CountGraphPass:       "bright-green",
		CountGraphAlarm:      "bright-red",
		CountGraphError:      "bright-red",
		CountGraphInfo:       "bright-cyan",
		CountGraphOK:         "bright-green",
		CountGraphSkip:       "gray3",
		CountGraphBracket:    "gray2",
		StatusAlarm:          "bold-bright-red",
		StatusError:          "bold-bright-red",
		StatusSkip:           "gray3",
		StatusInfo:           "bright-cyan",
		StatusOK:             "bright-green",
		StatusColon:          "gray1",
		ReasonAlarm:          "bright-red",
		ReasonError:          "bright-red",
		ReasonSkip:           "gray3",
		ReasonInfo:           "bright-cyan",
		ReasonOK:             "gray4",
		Spacer:               "gray1",
		Indent:               "gray1",
		UseColor:             true,
	},
	"light": {
		GroupTitle:           "bold-bright-black",
		Severity:             "bold-bright-yellow",
		CountZeroFail:        "gray5",
		CountZeroFailDivider: "gray5",
		CountDivider:         "gray4",
		CountFail:            "bold-bright-red",
		CountTotal:           "bright-black",
		CountTotalAllPassed:  "bold-bright-green",
		CountGraphFail:       "bright-red",
		CountGraphPass:       "bright-green",
		CountGraphAlarm:      "bright-red",
		CountGraphError:      "bright-red",
		CountGraphInfo:       "bright-cyan",
		CountGraphOK:         "bright-green",
		CountGraphSkip:       "gray3",
		CountGraphBracket:    "gray4",
		StatusAlarm:          "bold-bright-red",
		StatusError:          "bold-bright-red",
		StatusSkip:           "gray3",
		StatusInfo:           "bright-cyan",
		StatusOK:             "bright-green",
		StatusColon:          "gray5",
		ReasonAlarm:          "bright-red",
		ReasonError:          "bright-red",
		ReasonSkip:           "gray3",
		ReasonInfo:           "bright-cyan",
		ReasonOK:             "gray2",
		Spacer:               "gray5",
		Indent:               "gray5",
		UseColor:             true,
	},
	"plain": {UseColor: false},
}
View Source
var ErrFormatterNotFound = errors.New("Formatter not found")

Functions

func CounterRendererMinWidth added in v0.9.1

func CounterRendererMinWidth() int

func EnsureTemplates added in v0.12.0

func EnsureTemplates() error

EnsureTemplates scans the '$STEAMPIPE_INSTALL_DIR/templates' directory and copies over any missing templates as defined in the 'templates' package

The name of the folder in the 'templates' package is used to identify templates in '$STEAMPIPE_INSTALL_DIR/templates' - where it is expected that a directory with the same name will exist. If said directory does not exist, it is copied over from 'templates'

func MapRange added in v0.9.1

func MapRange(value int, valueRange RangeConstraint, desiredRange RangeConstraint) int

MapRange Re-maps a number from one range to another.

func TruncateString

func TruncateString(str string, length int) string

Types

type CSVRenderer added in v0.6.0

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

func (CSVRenderer) Render added in v0.6.0

func (r CSVRenderer) Render(tree *controlexecute.ExecutionTree) [][]string

type CheckExportTarget added in v0.6.0

type CheckExportTarget struct {
	Formatter Formatter
	File      string
}

func NewCheckExportTarget added in v0.6.0

func NewCheckExportTarget(formatter Formatter, file string) CheckExportTarget

type ControlColorSchemaDefinition

type ControlColorSchemaDefinition struct {
	// group
	GroupTitle           string
	Severity             string
	CountZeroFail        string
	CountZeroFailDivider string
	CountDivider         string
	CountFail            string
	CountTotal           string
	CountTotalAllPassed  string
	CountGraphFail       string
	CountGraphPass       string
	CountGraphAlarm      string
	CountGraphError      string
	CountGraphInfo       string
	CountGraphOK         string
	CountGraphSkip       string
	CountGraphBracket    string

	// results
	StatusAlarm string
	StatusError string
	StatusSkip  string
	StatusInfo  string
	StatusOK    string
	StatusColon string
	ReasonAlarm string
	ReasonError string
	ReasonSkip  string
	ReasonInfo  string
	ReasonOK    string

	Spacer   string
	Indent   string
	UseColor bool
}

type ControlColorScheme

type ControlColorScheme struct {
	GroupTitle           colorFunc
	Severity             colorFunc
	CountZeroFail        colorFunc
	CountZeroFailDivider colorFunc
	CountDivider         colorFunc
	CountFail            colorFunc
	CountTotal           colorFunc
	CountTotalAllPassed  colorFunc
	CountGraphFail       colorFunc
	CountGraphPass       colorFunc
	CountGraphAlarm      colorFunc
	CountGraphError      colorFunc
	CountGraphInfo       colorFunc
	CountGraphOK         colorFunc
	CountGraphSkip       colorFunc
	CountGraphBracket    colorFunc
	StatusAlarm          colorFunc
	StatusError          colorFunc
	StatusSkip           colorFunc
	StatusInfo           colorFunc
	StatusOK             colorFunc
	StatusColon          colorFunc
	ReasonAlarm          colorFunc
	ReasonError          colorFunc
	ReasonSkip           colorFunc
	ReasonInfo           colorFunc
	ReasonOK             colorFunc
	Spacer               colorFunc
	Indent               colorFunc

	ReasonColors map[string]colorFunc
	StatusColors map[string]colorFunc
	GraphColors  map[string]colorFunc
	UseColor     bool
}
var ControlColors *ControlColorScheme

ControlColors is a global variable containing the current control color scheme

func (*ControlColorScheme) Initialise

type ControlRenderer

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

func NewControlRenderer

func NewControlRenderer(run *controlexecute.ControlRun, parent *GroupRenderer) *ControlRenderer

func (ControlRenderer) Render

func (r ControlRenderer) Render() string

type CounterGraphRenderer

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

func NewCounterGraphRenderer

func NewCounterGraphRenderer(failedControls, totalControls, maxTotalControls int, options CounterGraphRendererOptions) *CounterGraphRenderer

func (CounterGraphRenderer) Render

func (r CounterGraphRenderer) Render() string

type CounterGraphRendererOptions added in v0.9.0

type CounterGraphRendererOptions struct {
	FailedColorFunc colorFunc
}

type CounterRenderer

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

func NewCounterRenderer

func NewCounterRenderer(failedControls, totalControls, maxFailedControls, maxTotalControls int, options CounterRendererOptions) *CounterRenderer

func (CounterRenderer) Render

func (r CounterRenderer) Render() string

type CounterRendererOptions added in v0.9.0

type CounterRendererOptions struct {
	AddLeadingSpace bool
}

type CsvColumnPair added in v0.6.0

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

type DimensionsRenderer

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

func NewDimensionsRenderer

func NewDimensionsRenderer(dimensions []controlexecute.Dimension, colorGenerator *controlexecute.DimensionColorGenerator, width int) *DimensionsRenderer

func (DimensionsRenderer) Render

func (r DimensionsRenderer) Render() string

Render returns the reason, truncated to the max length if necessary

type ErrorRenderer

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

func NewErrorRenderer

func NewErrorRenderer(err error, width int, indent string) *ErrorRenderer

func (ErrorRenderer) Render

func (r ErrorRenderer) Render() string

type ExportTemplate added in v0.12.0

type ExportTemplate struct {
	TemplatePath                string
	FormatName                  string
	OutputExtension             string
	FormatFullName              string
	DefaultTemplateForExtension bool
}

func NewExportTemplate added in v0.12.0

func NewExportTemplate(directory string) *ExportTemplate

func ResolveExportTemplate added in v0.12.0

func ResolveExportTemplate(export string, allowFilenameEvaluation bool) (format *ExportTemplate, targetFilename string, err error)

ResolveExportTemplate accepts the export argument and resolves the template to use. If an exact match to the available templates is not found, and if 'allowFilenameEvaluation' is true then the 'export' value is parsed as a filename and the suffix is used to match to available templates returns - the export template to use - the path of the file to write to - error (if any)

func (ExportTemplate) String added in v0.12.0

func (ft ExportTemplate) String() string

type Formatter added in v0.6.0

type Formatter interface {
	Format(ctx context.Context, tree *controlexecute.ExecutionTree) (io.Reader, error)
	FileExtension() string
}

func GetDefinedOutputFormatter added in v0.12.0

func GetDefinedOutputFormatter(outputFormat string) (Formatter, bool)

func GetTemplateExportFormatter added in v0.12.0

func GetTemplateExportFormatter(arg string, allowFilenameEvaluation bool) (Formatter, string, error)

type FormatterMap added in v0.9.0

type FormatterMap map[string]Formatter

type GroupHeadingRenderer

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

func NewGroupHeadingRenderer

func NewGroupHeadingRenderer(title string, failed, total, maxFailed, maxTotal, width int, indent string) *GroupHeadingRenderer

func (GroupHeadingRenderer) Render

func (r GroupHeadingRenderer) Render() string

type GroupRenderer

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

func NewGroupRenderer

func NewGroupRenderer(group *controlexecute.ResultGroup, parent *GroupRenderer, maxFailedControls, maxTotalControls int, resultTree *controlexecute.ExecutionTree, width int) *GroupRenderer

func (GroupRenderer) Render

func (r GroupRenderer) Render() string

type GroupTitleRenderer

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

func NewGroupTitleRenderer

func NewGroupTitleRenderer(title string, width int) *GroupTitleRenderer

func (GroupTitleRenderer) Render

func (r GroupTitleRenderer) Render() string

Render returns the title, truncated to the max length if necessary NOTE: adds a trailing space

type JSONFormatter added in v0.6.0

type JSONFormatter struct{}

func (JSONFormatter) FileExtension added in v0.9.0

func (j JSONFormatter) FileExtension() string

func (JSONFormatter) Format added in v0.6.0

type NullFormatter added in v0.6.0

type NullFormatter struct{}

NullFormatter is to be used when no output is expected. It always returns a `io.Reader` which reads an empty string

func (*NullFormatter) FileExtension added in v0.9.0

func (j *NullFormatter) FileExtension() string

func (*NullFormatter) Format added in v0.6.0

type RangeConstraint added in v0.9.1

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

func NewRangeConstraint added in v0.9.1

func NewRangeConstraint(minimum int, maximum int) RangeConstraint

func (*RangeConstraint) Constrain added in v0.9.1

func (r *RangeConstraint) Constrain(value int) int

Constrain a number to be within a range.

type ResultColumns added in v0.6.0

type ResultColumns struct {
	AllColumns       []string
	GroupColumns     []CsvColumnPair
	ResultColumns    []CsvColumnPair
	DimensionColumns []string
	TagColumns       []string
}

type ResultReasonRenderer

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

func NewResultReasonRenderer

func NewResultReasonRenderer(status, reason string, width int) *ResultReasonRenderer

func (ResultReasonRenderer) Render

func (r ResultReasonRenderer) Render() string

Render returns the reason, truncated to the max length if necessary NOTE: adds a trailing space

type ResultRenderer

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

func NewResultRenderer

func NewResultRenderer(status, reason string, dimensions []controlexecute.Dimension, colorGenerator *controlexecute.DimensionColorGenerator, width int, indent string) *ResultRenderer

func (ResultRenderer) Render

func (r ResultRenderer) Render() string

type ResultStatusRenderer

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

func NewResultStatusRenderer

func NewResultStatusRenderer(status string) *ResultStatusRenderer

func (ResultStatusRenderer) Render

func (r ResultStatusRenderer) Render() string

Render returns the status

type SeverityRenderer

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

func NewSeverityRenderer

func NewSeverityRenderer(severity string) *SeverityRenderer

func (SeverityRenderer) Render

func (r SeverityRenderer) Render() string

Render returns ther severity oin upper case, got 'critical' and 'high' severities for all other values an empty string is returned NOTE: adds a trailing space

type SpacerRenderer

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

func NewSpacerRenderer

func NewSpacerRenderer(width int) *SpacerRenderer

func (SpacerRenderer) Render

func (r SpacerRenderer) Render() string

Render returns a divider string of format: "....... " NOTE: adds a trailing space

type SummaryRenderer added in v0.9.0

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

func NewSummaryRenderer added in v0.9.0

func NewSummaryRenderer(resultTree *controlexecute.ExecutionTree, width int) *SummaryRenderer

func (SummaryRenderer) Render added in v0.9.0

func (r SummaryRenderer) Render() string

type SummarySeverityRenderer added in v0.9.0

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

func NewSummarySeverityRenderer added in v0.9.0

func NewSummarySeverityRenderer(resultTree *controlexecute.ExecutionTree, width int) *SummarySeverityRenderer

func (*SummarySeverityRenderer) Render added in v0.9.0

func (r *SummarySeverityRenderer) Render() []string

type SummarySeverityRowRenderer added in v0.9.0

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

func NewSummarySeverityRowRenderer added in v0.9.0

func NewSummarySeverityRowRenderer(resultTree *controlexecute.ExecutionTree, width int, severity string) *SummarySeverityRowRenderer

func (*SummarySeverityRowRenderer) Render added in v0.9.0

func (r *SummarySeverityRowRenderer) Render() string

type SummaryStatusRowRenderer added in v0.9.0

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

func NewSummaryStatusRowRenderer added in v0.9.0

func NewSummaryStatusRowRenderer(resultTree *controlexecute.ExecutionTree, width int, status string) *SummaryStatusRowRenderer

func (*SummaryStatusRowRenderer) Render added in v0.9.0

func (r *SummaryStatusRowRenderer) Render() string

type SummaryTotalRowRenderer added in v0.9.0

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

func NewSummaryTotalRowRenderer added in v0.9.0

func NewSummaryTotalRowRenderer(resultTree *controlexecute.ExecutionTree, width int) *SummaryTotalRowRenderer

func (*SummaryTotalRowRenderer) Render added in v0.9.0

func (r *SummaryTotalRowRenderer) Render() string

type TableRenderer

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

func NewTableRenderer

func NewTableRenderer(resultTree *controlexecute.ExecutionTree) *TableRenderer

func (TableRenderer) MinimumWidth added in v0.9.1

func (r TableRenderer) MinimumWidth() int

MinimumWidth is the width we require It is determined by the left indent, title, severity, counter and counter graph

func (TableRenderer) Render

func (r TableRenderer) Render(width int) string

type TemplateFormatter added in v0.12.0

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

TemplateFormatter implements the 'Formatter' interface and exposes a generic template based output mechanism for 'check' execution trees

func NewTemplateFormatter added in v0.12.0

func NewTemplateFormatter(input ExportTemplate) (*TemplateFormatter, error)

func (TemplateFormatter) FileExtension added in v0.12.0

func (tf TemplateFormatter) FileExtension() string

func (TemplateFormatter) Format added in v0.12.0

type TemplateRenderConfig added in v0.12.0

type TemplateRenderConfig struct {
	RenderHeader bool
}

type TemplateRenderConstants added in v0.12.0

type TemplateRenderConstants struct {
	SteampipeVersion string
	WorkingDir       string
}

type TemplateRenderContext added in v0.12.0

type TemplateRenderContext struct {
	Constants TemplateRenderConstants
	Config    TemplateRenderConfig
	Data      *controlexecute.ExecutionTree
}

type TextFormatter added in v0.6.0

type TextFormatter struct{}

func (*TextFormatter) FileExtension added in v0.9.0

func (j *TextFormatter) FileExtension() string

func (*TextFormatter) Format added in v0.6.0

Jump to

Keyboard shortcuts

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