diff --git a/api/tangled/citriggerPipeline.go b/api/tangled/citriggerPipeline.go index 364672bf..66ec49e4 100644 --- a/api/tangled/citriggerPipeline.go +++ b/api/tangled/citriggerPipeline.go @@ -64,7 +64,7 @@ func (t *CiTriggerPipeline_Input_Trigger) UnmarshalJSON(b []byte) error { // CiTriggerPipeline_Output is the output of a sh.tangled.ci.triggerPipeline call. type CiTriggerPipeline_Output struct { - // pipeline: AT-URI of the created pipeline + // pipeline: Spindle-local id of the created pipeline Pipeline string `json:"pipeline" cborgen:"pipeline"` } diff --git a/appview/models/pipeline.go b/appview/models/pipeline.go index c1785904..f754945d 100644 --- a/appview/models/pipeline.go +++ b/appview/models/pipeline.go @@ -8,7 +8,6 @@ import ( "github.com/bluesky-social/indigo/atproto/syntax" "github.com/go-git/go-git/v5/plumbing" - "tangled.org/core/api/tangled" spindle "tangled.org/core/spindle/models" "tangled.org/core/workflow" ) @@ -29,10 +28,6 @@ type Pipeline struct { Statuses map[string]WorkflowStatus } -func (p *Pipeline) AtUri() syntax.ATURI { - return syntax.ATURI(fmt.Sprintf("at://did:web:%s/%s/%s", p.Knot, tangled.PipelineNSID, p.Rkey)) -} - type WorkflowStatus struct { Data []PipelineStatus } @@ -198,7 +193,3 @@ func (ps PipelineStatus) ErrorDetails() string { } return strings.Join(lines[:truncateTo], "\n") + "\n…" } - -func (ps *PipelineStatus) PipelineAt() syntax.ATURI { - return syntax.ATURI(fmt.Sprintf("at://did:web:%s/%s/%s", ps.PipelineKnot, tangled.PipelineNSID, ps.PipelineRkey)) -} diff --git a/appview/pipelines/pipelines.go b/appview/pipelines/pipelines.go index bd2768e7..dc3d328e 100644 --- a/appview/pipelines/pipelines.go +++ b/appview/pipelines/pipelines.go @@ -24,7 +24,6 @@ import ( "tangled.org/core/rbac" "tangled.org/core/types" - "github.com/bluesky-social/indigo/atproto/syntax" indigoxrpc "github.com/bluesky-social/indigo/xrpc" "github.com/go-chi/chi/v5" "github.com/gorilla/websocket" @@ -229,9 +228,10 @@ func (p *Pipelines) Workflow(w http.ResponseWriter, r *http.Request) { return } - pipelineId, err := syntax.ParseTID(chi.URLParam(r, "pipeline")) - if err != nil { - l.Debug("invalid pipeline id", "id", pipelineId) + // pipeline ids are opaque, any format the spindle minted + pipelineId := chi.URLParam(r, "pipeline") + if pipelineId == "" { + l.Debug("missing pipeline id") p.pages.Error404(w) return } @@ -261,7 +261,7 @@ func (p *Pipelines) Workflow(w http.ResponseWriter, r *http.Request) { } xrpcc := &indigoxrpc.Client{Host: spindleUrl} - out, err := tangled.CiGetPipeline(r.Context(), xrpcc, pipelineId.String()) + out, err := tangled.CiGetPipeline(r.Context(), xrpcc, pipelineId) if err != nil { // TODO(boltless): change behavior based on error l.Debug("failed to get pipeline", "err", err) @@ -391,9 +391,10 @@ func (p *Pipelines) Logs(w http.ResponseWriter, r *http.Request) { return } - pipelineId, err := syntax.ParseTID(chi.URLParam(r, "pipeline")) - if err != nil { - l.Debug("invalid pipeline id", "id", pipelineId) + // pipeline ids are opaque, any format the spindle minted + pipelineId := chi.URLParam(r, "pipeline") + if pipelineId == "" { + l.Debug("missing pipeline id") http.Error(w, "invalid pipeline id", http.StatusBadRequest) return } @@ -426,7 +427,7 @@ func (p *Pipelines) Logs(w http.ResponseWriter, r *http.Request) { sched := &webLogScheduler{ch: evChan} xrpcc := &lexutil.Client{Client: indigoxrpc.Client{Host: spindleUrl}} go func() { - done <- tangled.CiSubscribePipelineLogs(ctx, xrpcc, pipelineId.String(), []string{workflowName}, sched) + done <- tangled.CiSubscribePipelineLogs(ctx, xrpcc, pipelineId, []string{workflowName}, sched) }() var lastWriteLk sync.Mutex @@ -594,9 +595,10 @@ func (p *Pipelines) cancel(w http.ResponseWriter, r *http.Request, workflows []s return } - pipelineId, err := syntax.ParseTID(chi.URLParam(r, "pipeline")) - if err != nil { - l.Debug("invalid pipeline id", "id", pipelineId) + // pipeline ids are opaque, any format the spindle minted + pipelineId := chi.URLParam(r, "pipeline") + if pipelineId == "" { + l.Debug("missing pipeline id") p.pages.Error404(w) return } @@ -614,7 +616,7 @@ func (p *Pipelines) cancel(w http.ResponseWriter, r *http.Request, workflows []s spindleClient, &tangled.CiCancelPipeline_Input{ Repo: f.RepoDid, - Pipeline: pipelineId.String(), + Pipeline: pipelineId, Workflows: workflows, }, ); err != nil { @@ -664,9 +666,10 @@ func (p *Pipelines) retry(w http.ResponseWriter, r *http.Request, only string) { return } - pipelineId, err := syntax.ParseTID(chi.URLParam(r, "pipeline")) - if err != nil { - l.Debug("invalid pipeline id", "id", pipelineId) + // pipeline ids are opaque, any format the spindle minted + pipelineId := chi.URLParam(r, "pipeline") + if pipelineId == "" { + l.Debug("missing pipeline id") p.pages.Error404(w) return } @@ -680,7 +683,7 @@ func (p *Pipelines) retry(w http.ResponseWriter, r *http.Request, only string) { // fetch the original pipeline to replay the same commit and workflows queryClient := &indigoxrpc.Client{Host: spindleUrl} - orig, err := tangled.CiGetPipeline(r.Context(), queryClient, pipelineId.String()) + orig, err := tangled.CiGetPipeline(r.Context(), queryClient, pipelineId) if err != nil { fail("failed to load the original pipeline", err) return @@ -725,12 +728,11 @@ func (p *Pipelines) retry(w http.ResponseWriter, r *http.Request, only string) { return } - newAt, err := syntax.ParseATURI(out.Pipeline) - if err != nil { - fail("pipeline triggered, but the response was malformed", err) + newId := out.Pipeline + if newId == "" { + fail("pipeline triggered, but the response was malformed", fmt.Errorf("empty pipeline id")) return } - newId := newAt.RecordKey().String() l = l.With("new", newId) l.Info("pipeline retried") diff --git a/docs/DOCS.md b/docs/DOCS.md index 2977e303..6e8d4d6a 100644 --- a/docs/DOCS.md +++ b/docs/DOCS.md @@ -933,7 +933,7 @@ environment: By default, the following environment variables are set: - `CI` - Always set to `true` to indicate a CI environment -- `TANGLED_PIPELINE_ID` - The AT URI of the current pipeline +- `TANGLED_PIPELINE_ID` - The id of the current pipeline - `TANGLED_PIPELINE_KIND` - One of `push`, `pull_request` or `manual` - `TANGLED_REPO_KNOT` - The repository's knot hostname diff --git a/lexicons/ci/triggerPipeline.json b/lexicons/ci/triggerPipeline.json index e45fdafa..c4263db2 100644 --- a/lexicons/ci/triggerPipeline.json +++ b/lexicons/ci/triggerPipeline.json @@ -43,8 +43,7 @@ "properties": { "pipeline": { "type": "string", - "format": "at-uri", - "description": "AT-URI of the created pipeline" + "description": "Spindle-local id of the created pipeline" } } } diff --git a/web/src/lib/api/lexicons/types/sh/tangled/ci/triggerPipeline.ts b/web/src/lib/api/lexicons/types/sh/tangled/ci/triggerPipeline.ts index 5e3edaf9..306789ec 100644 --- a/web/src/lib/api/lexicons/types/sh/tangled/ci/triggerPipeline.ts +++ b/web/src/lib/api/lexicons/types/sh/tangled/ci/triggerPipeline.ts @@ -33,9 +33,9 @@ const _mainSchema = /*#__PURE__*/ v.procedure("sh.tangled.ci.triggerPipeline", { type: "lex", schema: /*#__PURE__*/ v.object({ /** - * AT-URI of the created pipeline + * Spindle-local id of the created pipeline */ - pipeline: /*#__PURE__*/ v.resourceUriString(), + pipeline: /*#__PURE__*/ v.string(), }), }, });