Report structured session validation and inspection results

This commit is contained in:
2026-11-20 05:23:32 +00:00
parent 97cced5d88
commit e44247b5b1
12 changed files with 730 additions and 210 deletions

View File

@@ -2,10 +2,13 @@ package app
import (
"context"
"errors"
"flag"
"fmt"
"io"
"strings"
"go.maximumdirect.net/commandkit"
)
// ArtifactsList lists effective artifact sources.
@@ -27,24 +30,14 @@ func artifactsListWithDependencies(ctx context.Context, args []string, out io.Wr
if strings.TrimSpace(flags.sessionID) == "" {
return fmt.Errorf("artifacts list: session_id is required")
}
cfg, store, locks, m, cleanup, err := loadHelperContextWithDependencies(ctx, flags, remote, deps)
loaded, err := loadCommandConfigWithDependencies(ctx, flags.pipelinePath, flags.campaignPath, flags.campaignFilePath, flags.sessionPath, flags.sessionOptions(), flags.secretsDir.pointer(), deps)
if err != nil {
return fmt.Errorf("artifacts list: %w", err)
return err
}
defer cleanup()
catalog, err := buildHelperArtifactCatalog(cfg, m)
if err != nil {
return fmt.Errorf("artifacts list: %w", err)
defer func() { _ = loaded.Close() }()
report, err := inspectSessionState(ctx, loaded.Config, false, remote, deps)
if report != nil {
err = errors.Join(err, commandkit.RenderReport(out, commandkit.Report{Value: report}, ""))
}
publishedRemoteState := map[string]string{}
if remote && store != nil {
current := inspectRemoteCurrentStateWithDependencies(ctx, cfg, store, deps)
if current.Err != nil {
publishedRemoteState = unresolvedRemotePublishedOutputAvailability(cfg, catalog, "remote=error")
} else {
publishedRemoteState = remotePublishedOutputAvailabilityForCurrent(ctx, cfg, store, catalog, current.State)
}
}
writeArtifactList(out, cfg, catalog, locks, publishedRemoteState)
return nil
return err
}