Answer the build queue as data too, so a check can say how far back it waits
The queue verb answered only a table, so nothing outside the controller could say an ask's place in the queue. It now asks its command for JSON: each ask's state, kind, repository, commit, machine, since and position among the waiting, with the table carried beside it and answered as the verb's output, both written from one read. A repository's password, if one were ever written into it, is left out of what is shown. novox/hq issue 455
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/nats-io/nats.go"
|
||||
@@ -268,6 +269,30 @@ func ReadQueue(ctx context.Context, js *broker.JetStream, seat string) (Queue, e
|
||||
return q, nil
|
||||
}
|
||||
|
||||
// WithoutPassword is a repository as a listing may say it: a URL's password, should one ever be written
|
||||
// into it, left out (novox/hq issue 455). Only for what is shown: the ask itself keeps what it was given,
|
||||
// which a cancel's outcome and a rebuild's match are read from.
|
||||
func WithoutPassword(repository string) string {
|
||||
scheme, rest, found := strings.Cut(repository, "://")
|
||||
if !found {
|
||||
return repository
|
||||
}
|
||||
authority, path, _ := strings.Cut(rest, "/")
|
||||
at := strings.LastIndex(authority, "@")
|
||||
if at < 0 {
|
||||
return repository
|
||||
}
|
||||
user, _, password := strings.Cut(authority[:at], ":")
|
||||
if !password {
|
||||
return repository
|
||||
}
|
||||
out := scheme + "://" + user + authority[at:]
|
||||
if len(rest) > len(authority) {
|
||||
out += "/" + path
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// ReadBuildEvents is every start and outcome the seat announced since a moment, from the events
|
||||
// stream, with a consumer of its own that is gone when this returns.
|
||||
func ReadBuildEvents(ctx context.Context, js *broker.JetStream, seat string, since time.Time) (BuildHeard, error) {
|
||||
|
||||
Reference in New Issue
Block a user