build(android): upgrade toolchain and migrate Room to KSP
Lint / Lint (push) Successful in 1m29s
Security / Secrets (gitleaks) (push) Successful in 1m11s
Security / Dependencies (Trivy) (push) Successful in 1m59s
Tests / Dashboard checks (push) Successful in 1m49s
Security / Code (Semgrep) (push) Successful in 3m8s
Tests / Go backend (push) Successful in 2m50s
Docker / Docker Build & Push (push) Successful in 8m42s
Lint / Lint (push) Successful in 1m29s
Security / Secrets (gitleaks) (push) Successful in 1m11s
Security / Dependencies (Trivy) (push) Successful in 1m59s
Tests / Dashboard checks (push) Successful in 1m49s
Security / Code (Semgrep) (push) Successful in 3m8s
Tests / Go backend (push) Successful in 2m50s
Docker / Docker Build & Push (push) Successful in 8m42s
- Target API 37 and use build-tools 37 for release signature checks - Adjust list pagination spacing and clarify shared backend docs
This commit is contained in:
1 parent
7150ebd13e
commit
0fd1805502
40 files changed
+912
-690
No files matched your search
@@ -0,0 +1,55 @@
|
||||
package carriernodeclient
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
|
||||
"repos.gfranz.ch/Gabriel20xx/shared/backend/settings"
|
||||
)
|
||||
|
||||
// carrierNodeInstancePattern matches a registered project key naming a CarrierNode instance: the
|
||||
// base "carriernode" itself, or a numbered peer like "carriernode_2" - see
|
||||
// ProjectConfigurator/backend/cmd/projectconfigurator/settings.go's identical pattern (kept in
|
||||
// sync manually since one is the sender's copy and this is the direct-DB-read receiver's copy of
|
||||
// the same convention, not literally shared code).
|
||||
var carrierNodeInstancePattern = regexp.MustCompile(`^carriernode(_\d+)?$`)
|
||||
|
||||
// URLsFromSettings returns every CarrierNode instance registered in ProjectConfigurator's Projects
|
||||
// workspace ("carriernode_url", "carriernode_2_url", ...), read directly from the shared
|
||||
// `settings` table in registration order, dropping any instance with no URL set. This is for
|
||||
// CarrierNode instances that share this database directly instead of going through
|
||||
// ProjectConfigurator's coreconfig push (see ProjectConfigurator/README.md's "Pushing core service
|
||||
// info to other projects" section) - wire it as a carriernodeclient.Client's BaseURLs:
|
||||
//
|
||||
// carriernodeclient.NewMulti(secret, func(ctx context.Context) []string {
|
||||
// return carriernodeclient.URLsFromSettings(ctx, db, fallback)
|
||||
// })
|
||||
//
|
||||
// Returns fallback if no carriernode* instance is registered (or none has a URL) yet.
|
||||
func URLsFromSettings(ctx context.Context, db *pgxpool.Pool, fallback []string) []string {
|
||||
var registered []string
|
||||
_ = json.Unmarshal([]byte(settings.ValueOrFallback(ctx, db, "configured_central", "")), ®istered)
|
||||
var urls []string
|
||||
for _, project := range registered {
|
||||
key := strings.ToLower(strings.TrimSpace(project))
|
||||
if !carrierNodeInstancePattern.MatchString(key) {
|
||||
continue
|
||||
}
|
||||
if url := strings.TrimSpace(settings.ValueOrFallback(ctx, db, key+"_url", "")); url != "" {
|
||||
urls = append(urls, url)
|
||||
}
|
||||
}
|
||||
if len(urls) == 0 {
|
||||
if url := strings.TrimSpace(settings.ValueOrFallback(ctx, db, "carriernode_url", "")); url != "" {
|
||||
urls = []string{url}
|
||||
}
|
||||
}
|
||||
if len(urls) == 0 {
|
||||
return fallback
|
||||
}
|
||||
return urls
|
||||
}
|
||||
Reference in new issue
Block a user