2026-05-23 14:03:31 +00:00
|
|
|
package app
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
2026-11-20 05:23:32 +00:00
|
|
|
"errors"
|
2026-05-23 14:03:31 +00:00
|
|
|
"flag"
|
|
|
|
|
"fmt"
|
|
|
|
|
"io"
|
|
|
|
|
"strings"
|
2026-11-20 05:23:32 +00:00
|
|
|
|
|
|
|
|
"go.maximumdirect.net/commandkit"
|
2026-05-23 14:03:31 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// ArtifactsList lists effective artifact sources.
|
|
|
|
|
func ArtifactsList(ctx context.Context, args []string, out io.Writer) error {
|
2026-09-05 18:00:50 +00:00
|
|
|
return artifactsListWithDependencies(ctx, args, out, commandDependencies{})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func artifactsListWithDependencies(ctx context.Context, args []string, out io.Writer, deps commandDependencies) error {
|
|
|
|
|
deps = normalizeCommandDependencies(deps)
|
2026-05-23 14:03:31 +00:00
|
|
|
fs := flag.NewFlagSet("artifacts list", flag.ContinueOnError)
|
|
|
|
|
fs.SetOutput(io.Discard)
|
|
|
|
|
var flags commonConfigFlags
|
|
|
|
|
var remote bool
|
|
|
|
|
addCommonConfigFlags(fs, &flags)
|
|
|
|
|
fs.BoolVar(&remote, "remote", false, "inspect remote publish availability")
|
|
|
|
|
if err := parseSessionAwareFlags("artifacts list", fs, args, &flags.sessionID); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
if strings.TrimSpace(flags.sessionID) == "" {
|
|
|
|
|
return fmt.Errorf("artifacts list: session_id is required")
|
|
|
|
|
}
|
2026-11-20 05:23:32 +00:00
|
|
|
loaded, err := loadCommandConfigWithDependencies(ctx, flags.pipelinePath, flags.campaignPath, flags.campaignFilePath, flags.sessionPath, flags.sessionOptions(), flags.secretsDir.pointer(), deps)
|
2026-05-23 14:03:31 +00:00
|
|
|
if err != nil {
|
2026-11-20 05:23:32 +00:00
|
|
|
return err
|
2026-05-23 14:03:31 +00:00
|
|
|
}
|
2026-11-20 05:23:32 +00:00
|
|
|
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}, ""))
|
2026-05-23 14:03:31 +00:00
|
|
|
}
|
2026-11-20 05:23:32 +00:00
|
|
|
return err
|
2026-05-23 14:03:31 +00:00
|
|
|
}
|