06bf580154
archived_at on pipelines (migrated in place). archive_pipeline and unarchive_pipeline by id or name with an expected-version guard; list_pipelines hides archived unless include_archived. Archived pipelines refuse runs, retries, new versions and name reuse, and cannot be archived while an enabled schedule points at them. CLI archive/unarchive and list --archived/--all, docs and skill note.
24 lines
784 B
Go
24 lines
784 B
Go
package server
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"git.a-wan.net/alan/pipelines/internal/pipeline"
|
|
"git.a-wan.net/alan/pipelines/internal/protocol"
|
|
)
|
|
|
|
// archivePipeline serves archive_pipeline and unarchive_pipeline. Like saving
|
|
// a schedule it is a lifecycle change, not authoring: no definition or version
|
|
// is written, so it is not gated by AllowAuthoring.
|
|
func archivePipeline(ctx context.Context, store *pipeline.Store, request protocol.Message) (*protocol.PipelineDetail, error) {
|
|
id, err := store.ResolvePipelineID(ctx, request.PipelineID, request.Name)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if err := store.SetArchived(ctx, id, request.Type == protocol.ArchivePipeline, request.ExpectedVersion, time.Now()); err != nil {
|
|
return nil, err
|
|
}
|
|
return store.Get(ctx, id, 0)
|
|
}
|