This commit is contained in:
Alexander Neumann 2018-05-04 00:22:25 +02:00
parent 740e2d6139
commit 1fbcf63830

View file

@ -15,11 +15,12 @@ import (
// Config contains configuration items read from a file. // Config contains configuration items read from a file.
type Config struct { type Config struct {
Repo string `hcl:"repo" flag:"repo" env:"RESTIC_REPOSITORY"` Repo string `config:"repo" flag:"repo" env:"RESTIC_REPOSITORY"`
Password string `hcl:"password" env:"RESTIC_PASSWORD"` Password string `config:"password" env:"RESTIC_PASSWORD"`
PasswordFile string `config:`
Backends map[string]Backend `hcl:"backend"` Backends map[string]Backend `config:"backend"`
Backup *Backup `hcl:"backup"` Backup *Backup `config:"backup"`
} }
// Backend is a configured backend to store a repository. // Backend is a configured backend to store a repository.
@ -30,7 +31,7 @@ type Backend struct {
// Backup sets the options for the "backup" command. // Backup sets the options for the "backup" command.
type Backup struct { type Backup struct {
Target []string `hcl:"target"` Target []string `config:"target"`
} }
// listTags returns the all the top-level tags with the name tagname of obj. // listTags returns the all the top-level tags with the name tagname of obj.
@ -78,8 +79,8 @@ func Parse(buf []byte) (cfg Config, err error) {
root := parsed.Node.(*ast.ObjectList) root := parsed.Node.(*ast.ObjectList)
checks := map[string]map[string]struct{}{ checks := map[string]map[string]struct{}{
"": listTags(cfg, "hcl"), "": listTags(cfg, "config"),
"backup": listTags(Backup{}, "hcl"), "backup": listTags(Backup{}, "config"),
} }
for name, valid := range checks { for name, valid := range checks {