Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d58e3e2653 |
No files matched your search
@@ -11,7 +11,7 @@ concurrency:
|
|||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
env:
|
env:
|
||||||
GOLANGCI_LINT_VERSION: v2.12.2
|
GOLANGCI_LINT_VERSION: v2.15.0
|
||||||
SQLC_VERSION: v1.31.1
|
SQLC_VERSION: v1.31.1
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@@ -58,7 +58,7 @@ jobs:
|
|||||||
# Targets of the database checks; SQL Server is left to local runs,
|
# Targets of the database checks; SQL Server is left to local runs,
|
||||||
# its image is too large for ephemeral runners.
|
# its image is too large for ephemeral runners.
|
||||||
mariadb:
|
mariadb:
|
||||||
image: mariadb:11@sha256:e1d5495f445654134f226f55a41ce0da227116f6f27f283101f405c794d841fc
|
image: mariadb:11
|
||||||
env:
|
env:
|
||||||
MARIADB_ROOT_PASSWORD: checkpw
|
MARIADB_ROOT_PASSWORD: checkpw
|
||||||
MARIADB_DATABASE: shop
|
MARIADB_DATABASE: shop
|
||||||
@@ -74,7 +74,7 @@ jobs:
|
|||||||
RABBITMQ_DEFAULT_USER: check
|
RABBITMQ_DEFAULT_USER: check
|
||||||
RABBITMQ_DEFAULT_PASS: checkpw
|
RABBITMQ_DEFAULT_PASS: checkpw
|
||||||
kafka:
|
kafka:
|
||||||
image: apache/kafka-native:4.1.1@sha256:b8faca36f5385f90e46861ea0b2f532ebed86e9b2868b717c75a67f6fda0c7ce
|
image: apache/kafka-native:4.1.1
|
||||||
env:
|
env:
|
||||||
KAFKA_NODE_ID: 1
|
KAFKA_NODE_ID: 1
|
||||||
KAFKA_PROCESS_ROLES: broker,controller
|
KAFKA_PROCESS_ROLES: broker,controller
|
||||||
@@ -146,7 +146,7 @@ jobs:
|
|||||||
# once the PACKAGE_TOKEN secret (write:package) exists.
|
# once the PACKAGE_TOKEN secret (write:package) exists.
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
image: docker:cli@sha256:34507eb5069d8be82c95dd3b6987d4250fd5fee49b82e2509b7d7a7030740d6d
|
image: docker:cli
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
shell: sh
|
shell: sh
|
||||||
|
|||||||
+2
-2
@@ -4,8 +4,6 @@ run:
|
|||||||
tests: true
|
tests: true
|
||||||
|
|
||||||
linters:
|
linters:
|
||||||
# staticcheck and unused are left out until honnef.co/go/tools supports
|
|
||||||
# the Go 1.27 standard library; they panic during analysis otherwise.
|
|
||||||
default: none
|
default: none
|
||||||
enable:
|
enable:
|
||||||
- errcheck
|
- errcheck
|
||||||
@@ -17,6 +15,8 @@ linters:
|
|||||||
- misspell
|
- misspell
|
||||||
- unconvert
|
- unconvert
|
||||||
- usestdlibvars
|
- usestdlibvars
|
||||||
|
- staticcheck
|
||||||
|
- unused
|
||||||
settings:
|
settings:
|
||||||
revive:
|
revive:
|
||||||
rules:
|
rules:
|
||||||
|
|||||||
+1
-1
@@ -18,7 +18,7 @@ RUN CGO_ENABLED=0 go build -trimpath \
|
|||||||
-ldflags "-s -w -X git.zb-server.de/ZB-Server/uptimesebi/internal/buildinfo.Version=${VERSION} -X git.zb-server.de/ZB-Server/uptimesebi/internal/buildinfo.Commit=${COMMIT}" \
|
-ldflags "-s -w -X git.zb-server.de/ZB-Server/uptimesebi/internal/buildinfo.Version=${VERSION} -X git.zb-server.de/ZB-Server/uptimesebi/internal/buildinfo.Commit=${COMMIT}" \
|
||||||
-o /out/ ./cmd/...
|
-o /out/ ./cmd/...
|
||||||
|
|
||||||
FROM gcr.io/distroless/static-debian12:nonroot@sha256:afa5c872c891853ca7fcf1f12c3edb23f7eeef36189728842dd51042ff57f7ab
|
FROM gcr.io/distroless/static-debian12:nonroot
|
||||||
COPY --from=build /out/ /usr/local/bin/
|
COPY --from=build /out/ /usr/local/bin/
|
||||||
USER nonroot
|
USER nonroot
|
||||||
ENTRYPOINT ["/usr/local/bin/api"]
|
ENTRYPOINT ["/usr/local/bin/api"]
|
||||||
+7
-2
@@ -30,6 +30,11 @@ const usage = `usage:
|
|||||||
region and agent manage platform resources shared by all organizations;
|
region and agent manage platform resources shared by all organizations;
|
||||||
organizations manage their own in the console.`
|
organizations manage their own in the console.`
|
||||||
|
|
||||||
|
// usageError reports a command line the binary does not understand.
|
||||||
|
type usageError struct{}
|
||||||
|
|
||||||
|
func (usageError) Error() string { return usage }
|
||||||
|
|
||||||
// admin runs operator commands. They act across all organizations, hence the
|
// admin runs operator commands. They act across all organizations, hence the
|
||||||
// system scope, and print to stdout for humans and scripts.
|
// system scope, and print to stdout for humans and scripts.
|
||||||
func admin(ctx context.Context, cfg config.API, args []string) error {
|
func admin(ctx context.Context, cfg config.API, args []string) error {
|
||||||
@@ -96,7 +101,7 @@ func admin(ctx context.Context, cfg config.API, args []string) error {
|
|||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return errors.New(usage)
|
return usageError{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func createAgent(ctx context.Context, db *tenant.DB, args []string) error {
|
func createAgent(ctx context.Context, db *tenant.DB, args []string) error {
|
||||||
@@ -108,7 +113,7 @@ func createAgent(ctx context.Context, db *tenant.DB, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if *name == "" || (*kind == "checker") != (*region != "") {
|
if *name == "" || (*kind == "checker") != (*region != "") {
|
||||||
return errors.New(usage)
|
return usageError{}
|
||||||
}
|
}
|
||||||
var tok string
|
var tok string
|
||||||
err := db.Tx(ctx, tenant.System(), func(q *store.Queries) error {
|
err := db.Tx(ctx, tenant.System(), func(q *store.Queries) error {
|
||||||
|
|||||||
+1
-1
@@ -50,7 +50,7 @@ func run(log *slog.Logger, level *slog.LevelVar, args []string) error {
|
|||||||
return admin(ctx, cfg, args)
|
return admin(ctx, cfg, args)
|
||||||
case "serve":
|
case "serve":
|
||||||
default:
|
default:
|
||||||
return errors.New(usage)
|
return usageError{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -35,7 +35,7 @@ func run(log *slog.Logger, level *slog.LevelVar) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
level.Set(cfg.LogLevel)
|
level.Set(cfg.LogLevel)
|
||||||
if err := cfg.Common.Validate(); err != nil {
|
if err := cfg.Validate(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
ctx, stop := platform.SignalContext()
|
ctx, stop := platform.SignalContext()
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ func run(log *slog.Logger, level *slog.LevelVar) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
level.Set(cfg.LogLevel)
|
level.Set(cfg.LogLevel)
|
||||||
if err := cfg.Common.Validate(); err != nil {
|
if err := cfg.Validate(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
ctx, stop := platform.SignalContext()
|
ctx, stop := platform.SignalContext()
|
||||||
|
|||||||
+2
-2
@@ -53,7 +53,7 @@ services:
|
|||||||
# Databases the database checks are tested against:
|
# Databases the database checks are tested against:
|
||||||
# docker compose --profile checks up -d --wait
|
# docker compose --profile checks up -d --wait
|
||||||
mariadb:
|
mariadb:
|
||||||
image: mariadb:11@sha256:e1d5495f445654134f226f55a41ce0da227116f6f27f283101f405c794d841fc
|
image: mariadb:11
|
||||||
profiles: [checks]
|
profiles: [checks]
|
||||||
environment: {MARIADB_ROOT_PASSWORD: checkpw, MARIADB_DATABASE: shop}
|
environment: {MARIADB_ROOT_PASSWORD: checkpw, MARIADB_DATABASE: shop}
|
||||||
ports: ["13306:3306"]
|
ports: ["13306:3306"]
|
||||||
@@ -93,7 +93,7 @@ services:
|
|||||||
retries: 60
|
retries: 60
|
||||||
|
|
||||||
kafka:
|
kafka:
|
||||||
image: apache/kafka-native:4.1.1@sha256:b8faca36f5385f90e46861ea0b2f532ebed86e9b2868b717c75a67f6fda0c7ce
|
image: apache/kafka-native:4.1.1
|
||||||
profiles: [checks]
|
profiles: [checks]
|
||||||
ports: ["19092:9092"]
|
ports: ["19092:9092"]
|
||||||
environment:
|
environment:
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ func (s *Server) audit() gin.HandlerFunc {
|
|||||||
|
|
||||||
action := auditActions[c.Request.Method+" "+c.FullPath()]
|
action := auditActions[c.Request.Method+" "+c.FullPath()]
|
||||||
status := c.Writer.Status()
|
status := c.Writer.Status()
|
||||||
if action == "" || c.GetBool(ctxAuditSkip) || (status >= 400 && !(auditFailures[action] && status < 500)) {
|
if action == "" || c.GetBool(ctxAuditSkip) || (status >= 400 && (!auditFailures[action] || status >= 500)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if status >= 400 {
|
if status >= 400 {
|
||||||
|
|||||||
@@ -68,9 +68,6 @@ func (t groupTree) resources(group *uuid.UUID) []authz.Resource {
|
|||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
// depth returns how many ancestors a group has.
|
|
||||||
func (t groupTree) depth(id uuid.UUID) int { return len(t.resources(&id)) - 1 }
|
|
||||||
|
|
||||||
// walk visits groups depth-first in name order.
|
// walk visits groups depth-first in name order.
|
||||||
func (t groupTree) walk(fn func(g store.MonitorGroup, depth int)) {
|
func (t groupTree) walk(fn func(g store.MonitorGroup, depth int)) {
|
||||||
var visit func(ids []uuid.UUID, depth int)
|
var visit func(ids []uuid.UUID, depth int)
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ var emailProviders = []Provider{
|
|||||||
AccessToken string `json:"access_token"`
|
AccessToken string `json:"access_token"`
|
||||||
}
|
}
|
||||||
if json.Unmarshal(reply, &tok) != nil || tok.AccessToken == "" {
|
if json.Unmarshal(reply, &tok) != nil || tok.AccessToken == "" {
|
||||||
return errors.New("Microsoft Entra issued no access token")
|
return errors.New("no access token from Microsoft Entra")
|
||||||
}
|
}
|
||||||
recipients := func(s string) []any {
|
recipients := func(s string) []any {
|
||||||
return addresses(s, func(a string) any { return map[string]any{"emailAddress": map[string]string{"address": a}} })
|
return addresses(s, func(a string) any { return map[string]any{"emailAddress": map[string]string{"address": a}} })
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ var incidentProviders = []Provider{
|
|||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
}
|
}
|
||||||
if json.Unmarshal(reply, &alert) != nil || alert.ID == "" {
|
if json.Unmarshal(reply, &alert) != nil || alert.ID == "" {
|
||||||
return errors.New("Jira Service Management: alert to close not found")
|
return errors.New("alert to close not found in Jira Service Management")
|
||||||
}
|
}
|
||||||
return c.json(ctx, http.MethodPost, base+"/"+url.PathEscape(alert.ID)+"/close", h, map[string]any{"source": "UptimeSebi"})
|
return c.json(ctx, http.MethodPost, base+"/"+url.PathEscape(alert.ID)+"/close", h, map[string]any{"source": "UptimeSebi"})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -356,7 +356,7 @@ var smsProviders = []Provider{
|
|||||||
} `json:"data"`
|
} `json:"data"`
|
||||||
}
|
}
|
||||||
if err != nil || json.Unmarshal(reply, &login) != nil || !login.Success {
|
if err != nil || json.Unmarshal(reply, &login) != nil || !login.Success {
|
||||||
return errors.Join(errors.New("Teltonika: sign-in failed"), err)
|
return errors.Join(errors.New("sign-in to Teltonika failed"), err)
|
||||||
}
|
}
|
||||||
reply, err = c.callJSON(ctx, http.MethodPost, base+"/api/messages/actions/send", bearer(login.Data.Token), map[string]any{
|
reply, err = c.callJSON(ctx, http.MethodPost, base+"/api/messages/actions/send", bearer(login.Data.Token), map[string]any{
|
||||||
"data": map[string]any{"modem": cfg["modem"], "number": cfg["phone_number"], "message": truncate(m.sms(), 159)},
|
"data": map[string]any{"modem": cfg["modem"], "number": cfg["phone_number"], "message": truncate(m.sms(), 159)},
|
||||||
|
|||||||
+2
-3
@@ -21,11 +21,10 @@ const (
|
|||||||
margin = 50.0
|
margin = 50.0
|
||||||
bodySize = 9.0
|
bodySize = 9.0
|
||||||
lineHeight = 12.0
|
lineHeight = 12.0
|
||||||
// Courier advances 0.6 em per character, which makes wrapping exact.
|
|
||||||
charWidth = 0.6 * bodySize
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// maxChars is how many Courier characters fit on a line.
|
// maxChars is how many Courier characters fit on a line: Courier advances
|
||||||
|
// 0.6 em per character, which makes wrapping exact.
|
||||||
const maxChars = 91
|
const maxChars = 91
|
||||||
|
|
||||||
type font string
|
type font string
|
||||||
|
|||||||
+1
-1
@@ -96,7 +96,7 @@ func (c *Client) checkIssuer(issuer string) error {
|
|||||||
if err != nil || u.Host == "" || u.RawQuery != "" || u.Fragment != "" || u.User != nil {
|
if err != nil || u.Host == "" || u.RawQuery != "" || u.Fragment != "" || u.User != nil {
|
||||||
return ErrInvalidIssuer
|
return ErrInvalidIssuer
|
||||||
}
|
}
|
||||||
if u.Scheme != "https" && !(c.allowHTTP && u.Scheme == "http") {
|
if u.Scheme != "https" && (!c.allowHTTP || u.Scheme != "http") {
|
||||||
return ErrInvalidIssuer
|
return ErrInvalidIssuer
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -55,12 +55,6 @@ func (f *fakeSource) set(fn func(*fakeSource)) {
|
|||||||
fn(f)
|
fn(f)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *fakeSource) callCount() int {
|
|
||||||
f.mu.Lock()
|
|
||||||
defer f.mu.Unlock()
|
|
||||||
return f.calls
|
|
||||||
}
|
|
||||||
|
|
||||||
type harness struct {
|
type harness struct {
|
||||||
srv *Server
|
srv *Server
|
||||||
src *fakeSource
|
src *fakeSource
|
||||||
|
|||||||
Reference in new issue
Block a user