Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var MarshalCLI = marshalerFunc(func(data analysis.Diagnostics) ([]byte, error) { var buf bytes.Buffer for name := range data { for _, d := range data[name] { switch d.Severity { case analysis.Error: buf.WriteString(color.RedString("error: ")) case analysis.Warning: buf.WriteString(color.YellowString("warning: ")) case analysis.Recommendation: buf.WriteString(color.CyanString("recommendation: ")) case analysis.OK: buf.WriteString(color.GreenString("ok: ")) case analysis.SuspectedProblem: buf.WriteString(color.YellowString("suspected: ")) } if d.Context != "" { buf.WriteString(d.Context + ": ") } buf.WriteString(d.Title) if len(d.Detail) > 0 { buf.WriteRune('\n') buf.WriteString(color.BlueString("detail: ")) buf.WriteString(d.Detail) } buf.WriteRune('\n') } } return buf.Bytes(), nil })
MarshalCLI is a Marshaler that returns the diagnostics data in a human-readable format, for CLI usage.
var MarshalGHA = marshalerFunc(func(data analysis.Diagnostics) ([]byte, error) { var buf bytes.Buffer for name := range data { for _, d := range data[name] { var readableSeverity string switch d.Severity { case analysis.Error: buf.WriteString("::error ") readableSeverity = "Error" case analysis.Warning, analysis.SuspectedProblem: buf.WriteString("::warning ") readableSeverity = "Warning" case analysis.Recommendation: buf.WriteString("::notice ") readableSeverity = "Recommendation" case analysis.OK: buf.WriteString("::debug::") readableSeverity = "OK" } ghaTitleFallback := "plugin-validator: " + readableSeverity ghaTitle := ghaTitleFallback var ghaMessage string diagnosticsTitle := d.Title if d.Context != "" { diagnosticsTitle = d.Context + ": " + diagnosticsTitle } if diagnosticsTitle != "" { ghaTitle += ": " + diagnosticsTitle } if d.Detail != "" { ghaMessage = d.Detail } else { ghaMessage = diagnosticsTitle ghaTitle = ghaTitleFallback } buf.WriteString("title=") buf.WriteString(ghaEscape(ghaTitle)) buf.WriteString("::") buf.WriteString(ghaEscape(ghaMessage)) buf.WriteRune('\n') } } return buf.Bytes(), nil })
MarshalGHA is a Marshaler that returns the diagnostics data in GitHub Actions workflow commands format. See GitHub Actions docs for more information: https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-commands#setting-a-notice-message
Functions ¶
Types ¶
type Marshaler ¶
type Marshaler interface {
// Marshal encodes the diagnostics data in the format implemented by the marshaler.
Marshal(data analysis.Diagnostics) ([]byte, error)
}
Marshaler is an interface for encoding the analysis results into bytes. Each implementation outputs the analysis results in a different format.
func NewJSONMarshaler ¶
NewJSONMarshaler returns a new Marshaler that outputs the diagnostics data in JSON format. This marshaler requires additional plugin id and plugin version arguments.