From 78356f459cd908f6e735da3b31089d5a3dc3d2c1 Mon Sep 17 00:00:00 2001 From: deadnews Date: Sun, 19 Jul 2026 21:21:02 +0700 Subject: [PATCH 1/2] feat: forward `RESTIC_*` env to workers Lets operators set tuning like `RESTIC_COMPRESSION` for workers. --- README.md | 1 + internal/restic/restic.go | 12 +++++++++--- internal/restic/restic_test.go | 13 +++++++++++-- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c876714..b52f766 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,7 @@ The daemon runs `restic` in a short-lived worker container named `volkeep-worker | `VOLKEEP_HOST` | required | Identifier for `restic snapshots --host` | | `RESTIC_REPOSITORY` | required | Restic URI, or `volume:` (local) | | `RESTIC_PASSWORD` | required | Restic repo password | +| `RESTIC_*` | — | Forwarded to workers (tuning) | | `AWS_*` | — | Forwarded to workers (S3 backends) | | `RCLONE_*` | — | Forwarded to workers (rclone backends) | | `VOLKEEP_RETENTION_DAYS` | `5` | Daily snapshots to keep | diff --git a/internal/restic/restic.go b/internal/restic/restic.go index de41c9c..a5058c6 100644 --- a/internal/restic/restic.go +++ b/internal/restic/restic.go @@ -13,15 +13,21 @@ const ( ExitRepoMissing = 10 ) -// WorkerEnv returns the env forwarded to every worker: -// repo credentials plus the AWS_* and RCLONE_* entries from environ. +// WorkerEnv returns the env forwarded to every worker: the resolved repo +// credentials plus the RESTIC_*, AWS_*, and RCLONE_* entries from environ. func WorkerEnv(repository, password string, environ []string) []string { env := []string{ "RESTIC_REPOSITORY=" + repository, "RESTIC_PASSWORD=" + password, } for _, kv := range environ { - if strings.HasPrefix(kv, "AWS_") || strings.HasPrefix(kv, "RCLONE_") { + if strings.HasPrefix(kv, "RESTIC_REPOSITORY=") || + strings.HasPrefix(kv, "RESTIC_PASSWORD=") { + continue + } + if strings.HasPrefix(kv, "RESTIC_") || + strings.HasPrefix(kv, "AWS_") || + strings.HasPrefix(kv, "RCLONE_") { env = append(env, kv) } } diff --git a/internal/restic/restic_test.go b/internal/restic/restic_test.go index e2a28f1..c5f3999 100644 --- a/internal/restic/restic_test.go +++ b/internal/restic/restic_test.go @@ -9,13 +9,22 @@ import ( func TestWorkerEnv(t *testing.T) { t.Parallel() - environ := []string{"PATH=/bin", "AWS_ACCESS_KEY_ID=id", "HOME=/root", "RCLONE_CONFIG_R_TYPE=s3"} + environ := []string{ + "PATH=/bin", + "AWS_ACCESS_KEY_ID=id", + "HOME=/root", + "RCLONE_CONFIG_R_TYPE=s3", + "RESTIC_COMPRESSION=max", + "RESTIC_REPOSITORY=volume:stale", + "RESTIC_PASSWORD=stale", + } assert.Equal(t, []string{ "RESTIC_REPOSITORY=s3:h/b", "RESTIC_PASSWORD=pw", "AWS_ACCESS_KEY_ID=id", "RCLONE_CONFIG_R_TYPE=s3", - }, WorkerEnv("s3:h/b", "pw", environ)) + "RESTIC_COMPRESSION=max", + }, WorkerEnv("s3:h/b", "pw", environ), "resolved credentials supersede the daemon's copies") assert.Equal(t, []string{ "RESTIC_REPOSITORY=/repo", From 2f8459a59c0eaf8c3ad75d467fe4096a477e749b Mon Sep 17 00:00:00 2001 From: deadnews Date: Mon, 20 Jul 2026 13:57:09 +0700 Subject: [PATCH 2/2] chore(lint): exclude `lll` from test files --- .golangci.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.golangci.toml b/.golangci.toml index d2125c2..b19c4ee 100644 --- a/.golangci.toml +++ b/.golangci.toml @@ -97,7 +97,7 @@ linters = ["govet"] [[linters.exclusions.rules]] path = "_test\\.go" -linters = ["errchkjson", "gocognit", "godoclint", "gosec"] +linters = ["errchkjson", "gocognit", "godoclint", "gosec", "lll"] [formatters] enable = ["gofumpt", "goimports"]