location

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 22, 2023 License: BSD-2-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package location implements parsing the restic repository location from a string.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NoPassword

func NoPassword(s string) string

NoPassword returns the repository location unchanged (there's no sensitive information there)

func StripPassword

func StripPassword(registry *Registry, s string) string

StripPassword returns a displayable version of a repository location (with any sensitive information removed)

Types

type Factory

type Factory interface {
	Scheme() string
	ParseConfig(s string) (interface{}, error)
	StripPassword(s string) string
	Create(ctx context.Context, cfg interface{}, rt http.RoundTripper, lim limiter.Limiter) (restic.Backend, error)
	Open(ctx context.Context, cfg interface{}, rt http.RoundTripper, lim limiter.Limiter) (restic.Backend, error)
}

func NewHTTPBackendFactory

func NewHTTPBackendFactory[C any, T restic.Backend](
	scheme string,
	parseConfigFn func(s string) (*C, error),
	stripPasswordFn func(s string) string,
	createFn func(ctx context.Context, cfg C, rt http.RoundTripper) (T, error),
	openFn func(ctx context.Context, cfg C, rt http.RoundTripper) (T, error)) Factory

func NewLimitedBackendFactory

func NewLimitedBackendFactory[C any, T restic.Backend](
	scheme string,
	parseConfigFn func(s string) (*C, error),
	stripPasswordFn func(s string) string,
	createFn func(ctx context.Context, cfg C, lim limiter.Limiter) (T, error),
	openFn func(ctx context.Context, cfg C, lim limiter.Limiter) (T, error)) Factory

type Location

type Location struct {
	Scheme string
	Config interface{}
}

Location specifies the location of a repository, including the method of access and (possibly) credentials needed for access.

func Parse

func Parse(registry *Registry, s string) (u Location, err error)

Parse extracts repository location information from the string s. If s starts with a backend name followed by a colon, that backend's Parse() function is called. Otherwise, the local backend is used which interprets s as the name of a directory.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

func NewRegistry

func NewRegistry() *Registry

func (*Registry) Lookup

func (r *Registry) Lookup(scheme string) Factory

func (*Registry) Register

func (r *Registry) Register(factory Factory)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL