Files
worker/internal/webapp/constants.go
root ff0d2f088f
Некоторые проверки не удались
CI / test (push) Failing after 6s
Docker / Build and publish worker image (push) Failing after 8s
feat(worker): add Docker Compose discovery and management
Add an internal/compose package that discovers Compose projects via
`docker compose ls` + `docker ps` labels (grouped by
com.docker.compose.project/service) and enriches each container with
`docker inspect` ports/mounts and Traefik router labels. Management
runs `docker compose` in each project's working directory for
up/down/stop/restart/pull plus per-service variants and log tails.

Wire it into the webapp: a 60s ComposeRefresher (constructed in New,
started in Start, stopped in Close), a /compose list + detail + logs
HTML surface, and /web/api/compose/* JSON endpoints (list, detail,
logs, project/service lifecycle). Browser lifecycle POSTs are
session+CSRF protected; the /web/api/* variants accept HTTP basic auth.
WORKER_COMPOSE_ENABLED defaults on (false to disable).

Tests cover discovery parsing/grouping/traefik/summary, the action
allowlists, and the full handler surface (list/detail/logs HTML+API,
CSRF enforcement, disabled/unknown-action rejection, audit writes,
success+failure exec paths) via a stub Docker binary.
2026-07-29 21:31:52 +03:00

48 строки
1.5 KiB
Go

package webapp
// Audit constants used across the webapp audit-log writes. They
// live in their own file so goconst sees them as named values
// rather than scattered string literals.
const (
auditActorLocal = "operator"
auditRoleAdmin = "admin"
auditAuthModeLocal = "local"
auditAuthModeBasic = "basic_auth"
auditTargetSelf = "self"
auditActionLogin = "login"
auditActionLoginFail = "login_failed"
auditActionLogout = "logout"
auditActionPassChange = "password_change"
)
// Inventory source labels. Phase 1 only emits "process"; Phase 3
// adds "compose" and "docker".
const (
inventorySourceProcess = "process"
)
// Environment variable names referenced by ConfigFromEnv. Lifted out
// so the validator and the cmd binary share the same constants.
const (
envWorkerHost = "WORKER_HOST"
envWorkerPort = "WORKER_PORT"
envWorkerURL = "WORKER_URL"
envWorkerLogin = "WORKER_LOGIN"
envWorkerPassword = "WORKER_PASSWORD"
envClusterEnabled = "WORKER_CLUSTER_ENABLED"
envComposeEnabled = "WORKER_COMPOSE_ENABLED"
envReleaseURL = "WORKER_RELEASE_URL"
)
// Route paths used as redirect targets. Lifted out so goconst stops
// flagging the duplicates across handlers.
const (
pathOverview = "/overview"
pathChangePassword = "/web/change-password"
pathLogin = "/web/login"
)
// basicAuthRealm is the value returned in the WWW-Authenticate
// header. Fixed string so scripted callers can match on it.
const basicAuthRealm = `Basic realm="rsmon-worker"`