2015-12-28 09:51:24 -05:00
|
|
|
package local
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"strings"
|
2016-08-21 11:46:23 -04:00
|
|
|
|
2017-07-23 08:21:03 -04:00
|
|
|
"github.com/restic/restic/internal/errors"
|
|
|
|
|
"github.com/restic/restic/internal/options"
|
2015-12-28 09:51:24 -05:00
|
|
|
)
|
|
|
|
|
|
2017-03-25 08:20:03 -04:00
|
|
|
// Config holds all information needed to open a local repository.
|
|
|
|
|
type Config struct {
|
2017-04-02 11:57:28 -04:00
|
|
|
Path string
|
2017-04-13 17:55:32 -04:00
|
|
|
Layout string `option:"layout" help:"use this backend directory layout (default: auto-detect)"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
|
options.Register("local", Config{})
|
2017-03-25 08:20:03 -04:00
|
|
|
}
|
|
|
|
|
|
2015-12-28 09:51:24 -05: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 08:20:03 -04:00
|
|
|
return Config{Path: cfg[6:]}, nil
|
2015-12-28 09:51:24 -05:00
|
|
|
}
|