Documentation
¶
Index ¶
- type Formatter
- func (f *Formatter) PrintAllRulesets(rulesets []models.Ruleset)
- func (f *Formatter) PrintError(suffix, msg string)
- func (f *Formatter) PrintFinalError(msg string)
- func (f *Formatter) PrintFinalSuccess(msg string)
- func (f *Formatter) PrintLintError(details LintErrorDetails)
- func (f *Formatter) PrintMsg(msg string)
- func (f *Formatter) PrintRuleset(ruleset models.Ruleset)
- func (f *Formatter) PrintStandaloneMsg(msg string)
- func (f *Formatter) PrintSuccess(msg string)
- func (f *Formatter) UpdateSuffix(text string)
- type LintErrorDetails
- type Mode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Formatter ¶
type Formatter struct {
// contains filtered or unexported fields
}
Formatter represents the data structure which controls how output is handled
func New ¶
New provides a formatter with output format determined by the mode.
If the formatter detects that it is within a TTY and in pretty mode, it will switch to plain mode. This avoids any mistaken garbaled output for none terminal destinations.
The suffix parameter is only applicable to pretty mode. Suffix is the string of text printed right after the spinner. (Hence the name, despite there being other text after it.)
func (*Formatter) PrintAllRulesets ¶
PrintAllRulesets formats and outputs all currently installed rulesets
func (*Formatter) PrintError ¶
PrintError outputs an error. In pretty mode it will cause it to print the message replacing the current suffix and immediately start a new spinner.
func (*Formatter) PrintFinalError ¶
PrintFinalError prints an error; usually to end the program on. In pretty mode this will stop the spinner, display a red x and not start a new one. In all other modes this will simply print an error message.
func (*Formatter) PrintFinalSuccess ¶
PrintFinalSuccess prints a final success message; usually to end the program on. In pretty mode this will stop the spinner, display a green checkmark and not start a new one. In all other modes this will simply print an info message.
func (*Formatter) PrintLintError ¶
func (f *Formatter) PrintLintError(details LintErrorDetails)
PrintLintError formats and prints details from a lint error.
It borrows(blatantly copies) from rust style errors: https://doc.rust-lang.org/edition-guide/rust-2018/the-compiler/improved-error-messages.html
Example format:
x Error: lolwut is inherently unsafe; see link for more details
--> ./testdata/test1.tf:17:1 | 17 | lolwut = "weow" | | = additional information: • rule name: resource_should_not_contain_attr_lolwut • link: http://lolwut.com/ • more info: tfvet rule describe example resource_should_not_contain_attr_lolwut • remediation: some text here about how to fix the problem. • remediation: `some code to fix the issue`
func (*Formatter) PrintMsg ¶
PrintMsg outputs a simple message. In pretty mode it will display it after the suffix text.
func (*Formatter) PrintRuleset ¶
PrintRuleset formats and outputs the information for a single ruleset
func (*Formatter) PrintStandaloneMsg ¶
PrintStandaloneMsg outputs a message unattached to the spinner or suffix text. In pretty mode this causes the spinner to first stop, print the message, and then immediately start a new spinner as to not cause the spinner suffix text to be printed.
func (*Formatter) PrintSuccess ¶
PrintSuccess outputs a success message. Pretty mode will cause it to print the message with a checkmark, replacing the current suffix, and immediately start a new spinner.
func (*Formatter) UpdateSuffix ¶
UpdateSuffix updates the text that comes right after the spinner.
type LintErrorDetails ¶
type LintErrorDetails struct { Filepath string Line string Ruleset string Rule models.Rule LintErr *proto.RuleError }
LintErrorDetails is a harness for all the details that go into a lint error