restic/internal/backend/local/config.go

28 lines
579 B
Go
Raw Normal View History

2015-12-28 14:51:24 +00:00
package local
import (
"strings"
2016-09-01 20:17:37 +00:00
"restic/errors"
"restic/options"
2015-12-28 14:51:24 +00:00
)
2017-03-25 12:20:03 +00:00
// Config holds all information needed to open a local repository.
type Config struct {
2017-04-02 15:57:28 +00:00
Path string
Layout string `option:"layout" help:"use this backend directory layout (default: auto-detect)"`
}
func init() {
options.Register("local", Config{})
2017-03-25 12:20:03 +00:00
}
2015-12-28 14:51:24 +00:00
// ParseConfig parses a local backend config.
func ParseConfig(cfg string) (interface{}, error) {
if !strings.HasPrefix(cfg, "local:") {
return nil, errors.New(`invalid format, prefix "local" not found`)
}
2017-03-25 12:20:03 +00:00
return Config{Path: cfg[6:]}, nil
2015-12-28 14:51:24 +00:00
}