diff --git a/appview/pipelines/ssh/session.go b/appview/pipelines/ssh/session.go index c1a9a275..b5328a63 100644 --- a/appview/pipelines/ssh/session.go +++ b/appview/pipelines/ssh/session.go @@ -3,7 +3,6 @@ package ssh import ( "fmt" - "github.com/bluesky-social/indigo/atproto/syntax" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/ssh" wishtea "github.com/charmbracelet/wish/bubbletea" @@ -20,36 +19,23 @@ func (s *Server) teaHandler(sess ssh.Session) (tea.Model, []tea.ProgramOption) { renderer := wishtea.MakeRenderer(sess) - if len(args) != 1 { + if len(args) != 2 { l.Warn("bad invocation", "args", args) - return newErrorModel(renderer, "usage: ssh -t -p 2222 \nexample: ssh -t host -p 2222 at://did:web:knot.example/sh.tangled.pipeline/abc123"), wishtea.MakeOptions(sess) + return newErrorModel(renderer, "usage: ssh -t -p "), wishtea.MakeOptions(sess) } - rawURI := args[0] - aturi, err := syntax.ParseATURI(rawURI) - if err != nil { - l.Warn("invalid AT URI", "uri", rawURI, "err", err) - return newErrorModel(renderer, fmt.Sprintf("invalid AT URI %q: %v", rawURI, err)), wishtea.MakeOptions(sess) - } - - did := aturi.Authority().String() - const didWebPrefix = "did:web:" - if len(did) <= len(didWebPrefix) { - l.Warn("unsupported DID format", "did", did) - return newErrorModel(renderer, fmt.Sprintf("unsupported DID format %q (expected did:web:...)", did)), wishtea.MakeOptions(sess) - } - knot := did[len(didWebPrefix):] - rkey := aturi.RecordKey().String() + repoDID := args[0] + sha := args[1] - l = l.With("knot", knot, "rkey", rkey) + l = l.With("repoDID", repoDID, "sha", sha) pipelines, err := db.GetPipelineStatuses(s.db, 1, - orm.FilterEq("p.knot", knot), - orm.FilterEq("p.rkey", rkey), + orm.FilterEq("p.repo_did", repoDID), + orm.FilterEq("p.sha", sha), ) if err != nil || len(pipelines) == 0 { l.Warn("pipeline not found", "err", err) - return newErrorModel(renderer, fmt.Sprintf("pipeline not found: %s", rawURI)), wishtea.MakeOptions(sess) + return newErrorModel(renderer, fmt.Sprintf("pipeline not found for repo %s @ %s", repoDID, sha)), wishtea.MakeOptions(sess) } pipeline := pipelines[0] diff --git a/knotserver/config/config.go b/knotserver/config/config.go index 05b9d709..994ff73a 100644 --- a/knotserver/config/config.go +++ b/knotserver/config/config.go @@ -44,7 +44,7 @@ type Config struct { Server Server `env:",prefix=KNOT_SERVER_"` Git Git `env:",prefix=KNOT_GIT_"` AppViewEndpoint string `env:"APPVIEW_ENDPOINT, default=https://tangled.org"` - LogsHostname string `env:"LOGS_HOSTNAME, default=logs.tangled.org"` + LogsAddr string `env:"LOGS_ADDR, default=tangled.org:3333"` KnotMirrors []string `env:"KNOT_MIRRORS, default=https://mirror.tangled.network"` } diff --git a/knotserver/internal.go b/knotserver/internal.go index dcc365e0..f31b495d 100644 --- a/knotserver/internal.go +++ b/knotserver/internal.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "log/slog" + "net" "net/http" "net/url" "os" @@ -422,9 +423,12 @@ func (h *InternalHandle) triggerPipeline( EventJson: string(eventJson), } - if h.c.LogsHostname != "" { - *clientMsgs = append(*clientMsgs, "→ Browse CI logs in your terminal:") - *clientMsgs = append(*clientMsgs, fmt.Sprintf(" ssh -t %s at://did:web:%s/sh.tangled.pipeline/%s", h.c.LogsHostname, h.c.Server.Hostname, event.Rkey)) + if h.c.LogsAddr != "" { + host, port, err := net.SplitHostPort(h.c.LogsAddr) + if err == nil { + *clientMsgs = append(*clientMsgs, "→ Browse CI logs in your terminal:") + *clientMsgs = append(*clientMsgs, fmt.Sprintf(" ssh -t -p %s %s %s %s", port, host, repoDid, line.NewSha)) + } } return h.db.InsertEvent(event, h.n)