restic/internal/backend/local/config.go

39 lines
903 B
Go
Raw Normal View History

2015-12-28 15:51:24 +01:00
package local
import (
"strings"
2017-07-23 14:21:03 +02:00
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/options"
2015-12-28 15:51:24 +01:00
)
2017-03-25 13:20:03 +01:00
// Config holds all information needed to open a local repository.
type Config struct {
2017-04-02 17:57:28 +02:00
Path string
2024-03-29 13:51:59 +01:00
Layout string `option:"layout" help:"use this backend directory layout (default: auto-detect) (deprecated)"`
Connections uint `option:"connections" help:"set a limit for the number of concurrent operations (default: 2)"`
}
// NewConfig returns a new config with default options applied.
func NewConfig() Config {
return Config{
Connections: 2,
}
}
func init() {
options.Register("local", Config{})
2017-03-25 13:20:03 +01:00
}
2015-12-28 15:51:24 +01:00
// ParseConfig parses a local backend config.
func ParseConfig(s string) (*Config, error) {
if !strings.HasPrefix(s, "local:") {
return nil, errors.New(`invalid format, prefix "local" not found`)
2015-12-28 15:51:24 +01:00
}
cfg := NewConfig()
cfg.Path = s[6:]
return &cfg, nil
2015-12-28 15:51:24 +01:00
}