Skip to content

Commit 3f40a51

Browse files
committed
Support reading age identity from file
1 parent 996a50d commit 3f40a51

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

cmd/litestream/main.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,9 @@ type ReplicaConfig struct {
369369

370370
// Encryption identities and recipients
371371
Age struct {
372-
Identities []string `yaml:"identities"`
373-
Recipients []string `yaml:"recipients"`
372+
IdentityFiles []string `yaml:"identity-files"`
373+
Identities []string `yaml:"identities"`
374+
Recipients []string `yaml:"recipients"`
374375
} `yaml:"age"`
375376
}
376377

@@ -398,6 +399,19 @@ func NewReplicaFromConfig(c *ReplicaConfig, db *litestream.DB) (_ *litestream.Re
398399
if v := c.ValidationInterval; v != nil {
399400
r.ValidationInterval = *v
400401
}
402+
for _, path := range c.Age.IdentityFiles {
403+
buf, err := os.ReadFile(path)
404+
if err != nil {
405+
return nil, err
406+
}
407+
408+
identities, err := age.ParseIdentities(strings.NewReader(string(buf)))
409+
if err != nil {
410+
return nil, err
411+
}
412+
413+
r.AgeIdentities = append(r.AgeIdentities, identities...)
414+
}
401415
for _, str := range c.Age.Identities {
402416
identities, err := age.ParseIdentities(strings.NewReader(str))
403417
if err != nil {

0 commit comments

Comments
 (0)