From 605b338d531eec8c2e5acbb9436a42f5c1b7d3b7 Mon Sep 17 00:00:00 2001 From: aabccd021 Date: Sun, 5 Jan 2025 21:06:48 +0700 Subject: [PATCH] Support reading age identity from file --- cmd/litestream/main.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/cmd/litestream/main.go b/cmd/litestream/main.go index 0115e553..2c6545cb 100644 --- a/cmd/litestream/main.go +++ b/cmd/litestream/main.go @@ -369,8 +369,9 @@ type ReplicaConfig struct { // Encryption identities and recipients Age struct { - Identities []string `yaml:"identities"` - Recipients []string `yaml:"recipients"` + IdentityFiles []string `yaml:"identity-files"` + Identities []string `yaml:"identities"` + Recipients []string `yaml:"recipients"` } `yaml:"age"` } @@ -398,6 +399,19 @@ func NewReplicaFromConfig(c *ReplicaConfig, db *litestream.DB) (_ *litestream.Re if v := c.ValidationInterval; v != nil { r.ValidationInterval = *v } + for _, path := range c.Age.IdentityFiles { + buf, err := os.ReadFile(path) + if err != nil { + return nil, err + } + + identities, err := age.ParseIdentities(strings.NewReader(string(buf))) + if err != nil { + return nil, err + } + + r.AgeIdentities = append(r.AgeIdentities, identities...) + } for _, str := range c.Age.Identities { identities, err := age.ParseIdentities(strings.NewReader(str)) if err != nil {