Complete pipeline preflight verification
This commit is contained in:
@@ -96,38 +96,39 @@ func selectPipelineInvocation(ctx context.Context, loaded loadedPipelineInvocati
|
||||
}
|
||||
|
||||
type preparedPipelineInvocation struct {
|
||||
resolved pipeline.ResolvedPipeline
|
||||
prepared *pipeline.PreparedPipeline
|
||||
raw []byte
|
||||
sessionID string
|
||||
diagnostics []contracts.ProducerDiagnostic
|
||||
resolved pipeline.ResolvedPipeline
|
||||
prepared *pipeline.PreparedPipeline
|
||||
raw []byte
|
||||
sessionID string
|
||||
diagnostics []contracts.ProducerDiagnostic
|
||||
failureTarget string
|
||||
}
|
||||
|
||||
func preparePipelineInvocation(loaded loadedPipelineInvocation, selected selectedPipelineInvocation, input pipelineRunInput) (preparedPipelineInvocation, *commandkit.Outcome) {
|
||||
workingDirectory, err := os.Getwd()
|
||||
if err != nil {
|
||||
outcome := commandkit.Failure(err.Error()).WithCause(err)
|
||||
return preparedPipelineInvocation{}, &outcome
|
||||
return preparedPipelineInvocation{failureTarget: "preparation"}, &outcome
|
||||
}
|
||||
materialized, diagnostics, err := pipeline.MaterializeReferences(selected.effective.ResolvedPipeline, selected.catalog, pipeline.ReferenceMaterializationOptions{ConfigPath: loaded.loaded.MainSourcePath(), WorkingDir: workingDirectory})
|
||||
if err != nil {
|
||||
outcome := commandkit.Failure(err.Error()).WithCause(err)
|
||||
return preparedPipelineInvocation{}, &outcome
|
||||
return preparedPipelineInvocation{failureTarget: "references"}, &outcome
|
||||
}
|
||||
prepared, err := pipeline.Prepare(materialized, selected.registries, pipeline.ModuleDependencies{Engine: selected.engine})
|
||||
if err != nil {
|
||||
outcome := commandkit.Failure(err.Error()).WithCause(err)
|
||||
return preparedPipelineInvocation{}, &outcome
|
||||
return preparedPipelineInvocation{resolved: materialized, diagnostics: diagnostics, failureTarget: "modules"}, &outcome
|
||||
}
|
||||
raw, err := os.ReadFile(input.InputFile.Value)
|
||||
if err != nil {
|
||||
outcome := commandkit.Failure(fmt.Sprintf("Read input %q: %v", input.InputFile.Value, err)).WithCause(err)
|
||||
return preparedPipelineInvocation{}, &outcome
|
||||
return preparedPipelineInvocation{resolved: materialized, diagnostics: diagnostics, failureTarget: "input"}, &outcome
|
||||
}
|
||||
sessionID, err := runSessionID(input.Overrides.Resources.SessionID, materialized.Input.Module, raw)
|
||||
if err != nil {
|
||||
outcome := commandkit.Failure(err.Error()).WithCause(err)
|
||||
return preparedPipelineInvocation{}, &outcome
|
||||
return preparedPipelineInvocation{resolved: materialized, diagnostics: diagnostics, failureTarget: "input"}, &outcome
|
||||
}
|
||||
return preparedPipelineInvocation{resolved: materialized, prepared: prepared, raw: raw, sessionID: sessionID, diagnostics: diagnostics}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user