Documentation ¶
Overview ¶
Package gs provides a restic backend for Google Cloud Storage.
Index ¶
- func Create(ctx context.Context, cfg Config, rt http.RoundTripper) (backend.Backend, error)
- func NewFactory() location.Factory
- func Open(_ context.Context, cfg Config, rt http.RoundTripper) (backend.Backend, error)
- type Backend
- func (be *Backend) Close() error
- func (be *Backend) Connections() uint
- func (be *Backend) Delete(ctx context.Context) error
- func (be *Backend) HasAtomicReplace() bool
- func (be *Backend) Hasher() hash.Hash
- func (be *Backend) IsNotExist(err error) bool
- func (be *Backend) IsPermanentError(err error) bool
- func (be *Backend) Join(p ...string) string
- func (be *Backend) List(ctx context.Context, t backend.FileType, fn func(backend.FileInfo) error) error
- func (be *Backend) Load(ctx context.Context, h backend.Handle, length int, offset int64, ...) error
- func (be *Backend) Path() string
- func (be *Backend) Remove(ctx context.Context, h backend.Handle) error
- func (be *Backend) Save(ctx context.Context, h backend.Handle, rd backend.RewindReader) error
- func (be *Backend) SetListMaxItems(i int)
- func (be *Backend) Stat(ctx context.Context, h backend.Handle) (bi backend.FileInfo, err error)
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Create ¶
Create opens the gs backend at the specified bucket and attempts to creates the bucket if it does not exist yet.
The service account must have the "storage.buckets.create" permission to create a bucket the does not yet exist.
func NewFactory ¶ added in v0.16.0
Types ¶
type Backend ¶
Backend stores data in a GCS bucket.
The service account used to access the bucket must have these permissions:
- storage.objects.create
- storage.objects.delete
- storage.objects.get
- storage.objects.list
func (*Backend) Connections ¶ added in v0.14.0
func (*Backend) Delete ¶
Delete removes all restic keys in the bucket. It will not remove the bucket itself.
func (*Backend) HasAtomicReplace ¶ added in v0.14.0
HasAtomicReplace returns whether Save() can atomically replace files
func (*Backend) Hasher ¶ added in v0.13.0
Hasher may return a hash function for calculating a content hash for the backend
func (*Backend) IsNotExist ¶
IsNotExist returns true if the error is caused by a not existing file.
func (*Backend) IsPermanentError ¶ added in v0.17.0
func (*Backend) List ¶
func (be *Backend) List(ctx context.Context, t backend.FileType, fn func(backend.FileInfo) error) error
List runs fn for each file in the backend which has the type t. When an error occurs (or fn returns an error), List stops and returns it.
func (*Backend) Load ¶
func (be *Backend) Load(ctx context.Context, h backend.Handle, length int, offset int64, fn func(rd io.Reader) error) error
Load runs fn with a reader that yields the contents of the file at h at the given offset.
func (*Backend) SetListMaxItems ¶ added in v0.7.3
SetListMaxItems sets the number of list items to load per request.
type Config ¶
type Config struct { ProjectID string Bucket string Prefix string Connections uint `option:"connections" help:"set a limit for the number of concurrent connections (default: 5)"` Region string `option:"region" help:"region to create the bucket in (default: us)"` }
Config contains all configuration necessary to connect to a Google Cloud Storage bucket. We use Google's default application credentials to acquire an access token, so we don't require that calling code supply any authentication material here.
func NewConfig ¶
func NewConfig() Config
NewConfig returns a new Config with the default values filled in.
func ParseConfig ¶
ParseConfig parses the string s and extracts the gcs config. The supported configuration format is gs:bucketName:/[prefix].
func (*Config) ApplyEnvironment ¶ added in v0.16.0
ApplyEnvironment saves values from the environment to the config.