Replace session validation with standalone preflight
This commit is contained in:
@@ -9,8 +9,22 @@ import (
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/adapters/storage"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/config"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/preflight"
|
||||
"go.maximumdirect.net/commandkit"
|
||||
)
|
||||
|
||||
func preflightCommand(deps commandDependencies) commandkit.Command {
|
||||
spec := sessionInspectionSpec("preflight", "Prepare session inputs and check readiness.", false)
|
||||
spec.Description = "Preparation writes state and downloads inputs; readiness checks may contact providers."
|
||||
spec.Run = func(invocation commandkit.Invocation, input *sessionInspectionInput) commandkit.Outcome {
|
||||
report, err := preflightSelectedSession(invocation.Context, input, withCommandReporting(deps, invocation))
|
||||
if report != nil {
|
||||
err = errors.Join(err, invocation.Reporter().Report(commandkit.Report{Value: report}))
|
||||
}
|
||||
return reportOperationOutcome(invocation, err)
|
||||
}
|
||||
return commandkit.NewCommand(spec)
|
||||
}
|
||||
|
||||
type preparationAssessment struct {
|
||||
Outcome string `json:"outcome"`
|
||||
Reason string `json:"reason,omitempty"`
|
||||
@@ -50,9 +64,13 @@ func preflightSelectedSession(ctx context.Context, input *sessionInspectionInput
|
||||
}
|
||||
report.Campaign, report.SessionID, report.SessionSource = cfg.Session.Campaign, cfg.Session.SessionID, sessionSourceSummary(cfg)
|
||||
report.Checks = append(report.Checks, readinessCheck{Group: "configuration", Outcome: "succeeded"})
|
||||
return report, inspectConfiguredSessionReadiness(ctx, cfg, deps, report)
|
||||
}
|
||||
|
||||
func inspectConfiguredSessionReadiness(ctx context.Context, cfg *config.Config, deps commandDependencies, report *sessionReadinessReport) error {
|
||||
plan, err := BuildBoundedPlan("prepare", "prepare")
|
||||
if err != nil {
|
||||
return report, err
|
||||
return err
|
||||
}
|
||||
invocationDeps := invocationDependencies{newAudita: deps.newAudita, newNotarius: deps.newNotarius, newScriptorium: deps.newScriptorium,
|
||||
newObjectStore: func(ctx context.Context, cfg *config.Config) (storage.ObjectStore, error) {
|
||||
@@ -69,7 +87,7 @@ func preflightSelectedSession(ctx context.Context, input *sessionInspectionInput
|
||||
// Finalization and lock-release failures may be joined after the checks.
|
||||
report.Findings = append(report.Findings, errorFinding("preflight", err.Error()))
|
||||
}
|
||||
return report, err
|
||||
return err
|
||||
}
|
||||
|
||||
func assessSessionReadiness(runtime *invocationRuntime, report *sessionReadinessReport, deps commandDependencies) error {
|
||||
|
||||
Reference in New Issue
Block a user