github.com/mckael/restic@v0.8.3/internal/backend/local/config.go (about)

     1  package local
     2  
     3  import (
     4  	"strings"
     5  
     6  	"github.com/restic/restic/internal/errors"
     7  	"github.com/restic/restic/internal/options"
     8  )
     9  
    10  // Config holds all information needed to open a local repository.
    11  type Config struct {
    12  	Path   string
    13  	Layout string `option:"layout" help:"use this backend directory layout (default: auto-detect)"`
    14  }
    15  
    16  func init() {
    17  	options.Register("local", Config{})
    18  }
    19  
    20  // ParseConfig parses a local backend config.
    21  func ParseConfig(cfg string) (interface{}, error) {
    22  	if !strings.HasPrefix(cfg, "local:") {
    23  		return nil, errors.New(`invalid format, prefix "local" not found`)
    24  	}
    25  
    26  	return Config{Path: cfg[6:]}, nil
    27  }