Documentation
¶
Overview ¶
Package validation enforces a cloud assembly's validation report: the results of the app's policy validation plugins, merged with the stacks' construct annotations (Epic K's K.4).
Check is upstream's StackCollection.reportValidationFailuresAndThrow, which the synth, deploy, rollback and asset publishing actions call before they act. The report's text is cloud-assembly-api's ValidationReportFormatter, which upstream's toolkit uses, with two differences:
- it has no colour, underlining or bold, because the toolkit's messages carry none;
- paths are left as the report has them, where upstream makes them relative to the process's working directory, which the library doesn't read.
As upstream, a stack-trace frame without a file and line, such as the jsii placeholder "...jsii runtime, node internals..." in a Go app's report, isn't shown as a source location. The stack traces of annotations are rendered as upstream's JustMyCode, with the library's frames collapsed.
It also differs where upstream's code is wrong, or can't apply to a Go process:
- a malformed rule ID, such as one with a second "::" or unbalanced brackets, is split at its first "::", where upstream fails the action with a plain error;
- a stack-trace frame without parentheses, "<file>:<line>:<col>", is a frame of that file, where upstream mangles it;
- the hint for a trace without user code names Node's default stack trace limit, 10, since a Go process has no Error.stackTraceLimit to name.
A stack checked twice, because it is both selected and marked validateOnSynth, is checked once, where upstream reports its annotations twice.
Index ¶
- func Check(ctx context.Context, io *iohelper.Helper, a *cloudassembly.Assembly, ...) error
- func Conclusion(reports []cloudassembly.PluginReport) string
- func Format(reports []cloudassembly.PluginReport) []string
- func Report(a *cloudassembly.Assembly, stacks []*cloudassembly.Stack) ([]cloudassembly.PluginReport, error)
- type FailAt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Check ¶
func Check(ctx context.Context, io *iohelper.Helper, a *cloudassembly.Assembly, stacks []*cloudassembly.Stack, failAt FailAt) error
Check reads the validation report of a for stacks, and fails when its findings reach failAt: upstream's StackCollection.reportValidationFailuresAndThrow. When there are findings, it first sends them as CDK_TOOLKIT_E9600.
It fails with a cdkerr.Error of Kind cdkerr.KindAssembly and Code "AssemblyError", whose SynthesisCode is "AnnotationErrors" or "StrictAnnotationWarnings" and whose cause is a *cloudassembly.StacksError naming the stacks checked, and with the errors of cloudassembly.Assembly.ValidationReport.
func Conclusion ¶
func Conclusion(reports []cloudassembly.PluginReport) string
Conclusion returns cloudassembly.ConclusionFailure if any report failed, and cloudassembly.ConclusionSuccess otherwise: upstream's combineConclusions.
func Format ¶
func Format(reports []cloudassembly.PluginReport) []string
Format returns the text of the reports, as blocks to be joined by blank lines: upstream's ValidationReportFormatter.formatReports, without colour. Plugins that failed to run come first, then one block per violating construct, the most severe first.
func Report ¶
func Report(a *cloudassembly.Assembly, stacks []*cloudassembly.Stack) ([]cloudassembly.PluginReport, error)
Report returns the plugin reports for stacks: cloud-assembly-api's loadUnifiedValidationReport. They are the app's own report, filtered to stacks, and, unless the app's report already holds them, the stacks' annotations as a report of their own, when there are any.
Types ¶
type FailAt ¶
type FailAt string
FailAt is the least severe kind of finding that fails an action: upstream's MinimumSeverity.
const ( // FailAtError fails on a report whose conclusion is a failure, such as an error annotation. FailAtError FailAt = "error" // FailAtWarning also fails on any violation of severity warning: the CLI's --strict. FailAtWarning FailAt = "warn" // FailAtNone never fails: the CLI's --ignore-errors. FailAtNone FailAt = "none" )
The failure levels.