Documentation ¶
Index ¶
- Constants
- Variables
- func InferFormatFromExportFileName(filename string) (string, error)
- func TruncateString(str string, length int) string
- type CSVFormatter
- type CSVRenderer
- type CheckExportTarget
- type ControlColorSchemaDefinition
- type ControlColorScheme
- type ControlRenderer
- type CounterGraphRenderer
- type CounterRenderer
- type CsvColumnPair
- type DimensionsRenderer
- type ErrorRenderer
- type Formatter
- type GroupHeadingRenderer
- type GroupRenderer
- type GroupTitleRenderer
- type JSONFormatter
- type NullFormatter
- type ResultColumns
- type ResultReasonRenderer
- type ResultRenderer
- type ResultStatusRenderer
- type SeverityRenderer
- type SpacerRenderer
- type TableRenderer
- type TextFormatter
Constants ¶
const ( OutputFormatNone = "none" OutputFormatText = "text" OutputFormatBrief = "brief" OutputFormatCSV = "csv" OutputFormatJSON = "json" )
Variables ¶
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", 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", 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}, }
Functions ¶
func InferFormatFromExportFileName ¶ added in v0.6.0
func TruncateString ¶
Types ¶
type CSVFormatter ¶ added in v0.6.0
type CSVFormatter struct {
// contains filtered or unexported fields
}
func (*CSVFormatter) Format ¶ added in v0.6.0
func (j *CSVFormatter) Format(_ context.Context, tree *controlexecute.ExecutionTree) (io.Reader, error)
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
func NewCheckExportTarget ¶ added in v0.6.0
func NewCheckExportTarget(format string, file string, err error) 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 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 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 UseColor bool }
var ControlColors *ControlColorScheme
ControlColors is a global variable containing the current control color scheme
func NewControlColorScheme ¶
func NewControlColorScheme(def *ControlColorSchemaDefinition) (*ControlColorScheme, error)
func (*ControlColorScheme) Initialise ¶
func (c *ControlColorScheme) Initialise(def *ControlColorSchemaDefinition) error
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) *CounterGraphRenderer
func (CounterGraphRenderer) Render ¶
func (r CounterGraphRenderer) Render() string
type CounterRenderer ¶
type CounterRenderer struct {
// contains filtered or unexported fields
}
func NewCounterRenderer ¶
func NewCounterRenderer(failedControls, totalControls, maxFailedControls, maxTotalControls int) *CounterRenderer
func (CounterRenderer) Render ¶
func (r CounterRenderer) Render() string
Render returns the counter string in format "<failed> / <total>.
The alignment depends on the maximum failed and maximum total parameters, as the counters are aligned as follows: " 3 / 123" " 13 / 23" "111 / 123" " 1 / 4" " 1 / 1,020"
// NOTE: adds a trailing space
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 Formatter ¶ added in v0.6.0
type Formatter interface {
Format(ctx context.Context, tree *controlexecute.ExecutionTree) (io.Reader, error)
}
func GetExportFormatter ¶ added in v0.6.0
func GetOutputFormatter ¶ added in v0.6.0
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) Format ¶ added in v0.6.0
func (j *JSONFormatter) Format(ctx context.Context, tree *controlexecute.ExecutionTree) (io.Reader, error)
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) Format ¶ added in v0.6.0
func (j *NullFormatter) Format(ctx context.Context, tree *controlexecute.ExecutionTree) (io.Reader, error)
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 TableRenderer ¶
type TableRenderer struct {
// contains filtered or unexported fields
}
func NewTableRenderer ¶
func NewTableRenderer(resultTree *controlexecute.ExecutionTree, width int) *TableRenderer
func (TableRenderer) Render ¶
func (r TableRenderer) Render() string
type TextFormatter ¶ added in v0.6.0
type TextFormatter struct{}
func (*TextFormatter) Format ¶ added in v0.6.0
func (j *TextFormatter) Format(ctx context.Context, tree *controlexecute.ExecutionTree) (io.Reader, error)
Source Files ¶
- color_scheme.go
- control.go
- csv.go
- dimensions.go
- error.go
- formatter.go
- formatter_csv.go
- formatter_json.go
- formatter_text.go
- group.go
- group_counter.go
- group_counter_graph.go
- group_heading.go
- group_title.go
- result.go
- result_columns.go
- result_reason.go
- result_status.go
- severity.go
- spacer.go
- table.go
- truncate.go