Honor cancellation at standard inspection boundaries
This commit is contained in:
13
sources.go
13
sources.go
@@ -44,6 +44,9 @@ type locationDTO struct {
|
||||
}
|
||||
|
||||
func runConfigSources[C any](invocation Invocation, suite ConfigSuite[C], input configInput[C]) Outcome {
|
||||
if err := invocation.Context.Err(); err != nil {
|
||||
return Failure(err)
|
||||
}
|
||||
scopeNames, err := selectConfigScopes(suite, input, ConfigSources)
|
||||
if err != nil {
|
||||
return Failure(err)
|
||||
@@ -54,11 +57,18 @@ func runConfigSources[C any](invocation Invocation, suite ConfigSuite[C], input
|
||||
if !ok || scope.Acquire == nil {
|
||||
return sourceReportFailure(fmt.Errorf("configuration scope %q has no acquisition callback", name), nil, false)
|
||||
}
|
||||
if err := invocation.Context.Err(); err != nil {
|
||||
return sourceReportFailure(err, nil, false)
|
||||
}
|
||||
acquired, acquireErr := scope.Acquire(invocation.Context, ConfigRequest{Operation: ConfigSources, Selection: input.Selection}, contexts[name])
|
||||
diagnostics := append([]Diagnostic(nil), acquired.Diagnostics...)
|
||||
if acquireErr != nil {
|
||||
return sourceReportFailure(acquireErr, diagnostics, false)
|
||||
}
|
||||
if err := invocation.Context.Err(); err != nil {
|
||||
return sourceReportFailure(err, diagnostics, false)
|
||||
}
|
||||
|
||||
if acquired.Value.Sources == nil {
|
||||
return sourceReportFailure(fmt.Errorf("configuration scope %q did not provide a source reader", name), diagnostics, false)
|
||||
}
|
||||
@@ -87,6 +97,9 @@ func runConfigSources[C any](invocation Invocation, suite ConfigSuite[C], input
|
||||
} else {
|
||||
writeSourceReportText(&report, document)
|
||||
}
|
||||
if err := invocation.Context.Err(); err != nil {
|
||||
return sourceReportFailure(err, diagnostics, false)
|
||||
}
|
||||
if err := writeReport(invocation.Streams.Out, report.Bytes()); err != nil {
|
||||
outcome := sourceReportFailure(err, diagnostics, true)
|
||||
outcome.DeliveryError = err
|
||||
|
||||
Reference in New Issue
Block a user