Merge: archive and unarchive pipelines

# Conflicts:
#	internal/cli/commands.go
#	internal/pipeline/store.go
This commit is contained in:
2026-11-04 23:39:02 +00:00
30 changed files with 1206 additions and 78 deletions
+24 -4
View File
@@ -52,6 +52,7 @@ type options struct {
all bool
debugFiles bool
json, source, noOpen, yes, allow, createOnly, force, wait bool
archived bool
version, expected, limit, retryVisit int
timeout, waitTimeout time.Duration
stageModels stageModelFlags
@@ -138,6 +139,11 @@ func (a App) flags(command string) (*flag.FlagSet, *options) {
f.BoolVar(&o.yes, "yes", false, "Confirm publication (schedules may activate)")
case "template":
f.BoolVar(&o.source, "source", false, "Print original Markdown instead of metadata")
case "list":
f.BoolVar(&o.archived, "archived", false, "List only archived pipelines")
f.BoolVar(&o.all, "all", false, "List active and archived pipelines (archived ones are marked)")
case "archive":
f.BoolVar(&o.yes, "yes", false, "Confirm archiving without an interactive prompt")
case "submit":
f.BoolVar(&o.yes, "yes", false, "Confirm publication without an interactive prompt")
f.StringVar(&o.name, "name", "", "Name for an external Markdown file (managed drafts already know their name)")
@@ -513,8 +519,10 @@ func (a App) Run(ctx context.Context, args []string) error {
defer cancel()
return c.Call(requestCtx, request)
}
// Resolution includes archived pipelines so history, show and unarchive
// still address them; the server refuses runs and publications for them.
resolve := func(value string) (protocol.PipelineSummary, error) {
r, err := call(protocol.Message{Type: protocol.List})
r, err := call(protocol.Message{Type: protocol.List, IncludeArchived: true})
if err != nil {
return protocol.PipelineSummary{}, err
}
@@ -760,6 +768,8 @@ func (a App) Run(ctx context.Context, args []string) error {
}
}
return nil
case "archive", "unarchive":
return a.archive(command, pos, o, call, resolve)
case "list", "templates", "runs", "ping", "connection":
if command == "runs" && len(pos) > 0 && pos[0] == "rm" {
return a.removeRuns(o, pos[1:], call)
@@ -768,10 +778,13 @@ func (a App) Run(ctx context.Context, args []string) error {
return fmt.Errorf("%s takes no positional arguments", command)
}
typeName := map[string]string{"list": protocol.List, "templates": protocol.ListTemplates, "runs": protocol.ListRuns, "ping": protocol.Ping, "connection": protocol.List}[command]
r, err := call(protocol.Message{Type: typeName})
r, err := call(protocol.Message{Type: typeName, IncludeArchived: command == "list" && (o.all || o.archived)})
if err != nil {
return err
}
if command == "list" && o.archived && !o.all {
r.Pipelines = archivedOnly(r.Pipelines)
}
if command == "runs" && o.name != "" {
p, err := resolve(o.name)
if err != nil {
@@ -791,7 +804,11 @@ func (a App) Run(ctx context.Context, args []string) error {
switch command {
case "list":
for _, p := range r.Pipelines {
fmt.Fprintf(a.Out, "%d\t%s\tv%d\t%d stages\n", p.ID, p.Name, p.Version, p.Stages)
note := ""
if p.ArchivedAt != "" {
note = "\tarchived " + p.ArchivedAt
}
fmt.Fprintf(a.Out, "%d\t%s\tv%d\t%d stages%s\n", p.ID, p.Name, p.Version, p.Stages, note)
}
case "templates":
for _, t := range r.Templates {
@@ -1207,11 +1224,14 @@ func (a App) author(ctx context.Context, command string, pos []string, o *option
if (o.name != "" && strings.TrimSpace(o.name) == "") || len(o.name) > 200 || strings.ContainsAny(o.name, "\r\n\x00") {
return fmt.Errorf("name must be 1–200 bytes without line breaks or NUL")
}
r, err := call(protocol.Message{Type: protocol.List})
r, err := call(protocol.Message{Type: protocol.List, IncludeArchived: true})
if err != nil {
return err
}
for _, p := range r.Pipelines {
if p.Name == o.name && p.ArchivedAt != "" {
return &pipeline.ArchivedError{Name: p.Name}
}
if p.Name == o.name {
return fmt.Errorf("pipeline already exists; use edit or choose another name")
}