Documentation ¶
Index ¶
- Variables
- type DefaultLayout
- func (l *DefaultLayout) Basedir(t backend.FileType) (dirname string, subdirs bool)
- func (l *DefaultLayout) Dirname(h backend.Handle) string
- func (l *DefaultLayout) Filename(h backend.Handle) string
- func (l *DefaultLayout) Name() string
- func (l *DefaultLayout) Paths() (dirs []string)
- func (l *DefaultLayout) String() string
- type Filesystem
- type Layout
- type LocalFilesystem
- type RESTLayout
- func (l *RESTLayout) Basedir(t backend.FileType) (dirname string, subdirs bool)
- func (l *RESTLayout) Dirname(h backend.Handle) string
- func (l *RESTLayout) Filename(h backend.Handle) string
- func (l *RESTLayout) Name() string
- func (l *RESTLayout) Paths() (dirs []string)
- func (l *RESTLayout) String() string
- type S3LegacyLayout
- func (l *S3LegacyLayout) Basedir(t backend.FileType) (dirname string, subdirs bool)
- func (l *S3LegacyLayout) Dirname(h backend.Handle) string
- func (l *S3LegacyLayout) Filename(h backend.Handle) string
- func (l *S3LegacyLayout) Name() string
- func (l *S3LegacyLayout) Paths() (dirs []string)
- func (l *S3LegacyLayout) String() string
Constants ¶
This section is empty.
Variables ¶
var ErrLayoutDetectionFailed = errors.New("auto-detecting the filesystem layout failed")
ErrLayoutDetectionFailed is returned by DetectLayout() when the layout cannot be detected automatically.
Functions ¶
This section is empty.
Types ¶
type DefaultLayout ¶
DefaultLayout implements the default layout for local and sftp backends, as described in the Design document. The `data` directory has one level of subdirs, two characters each (taken from the first two characters of the file name).
func (*DefaultLayout) Basedir ¶
func (l *DefaultLayout) Basedir(t backend.FileType) (dirname string, subdirs bool)
Basedir returns the base dir name for type t.
func (*DefaultLayout) Dirname ¶
func (l *DefaultLayout) Dirname(h backend.Handle) string
Dirname returns the directory path for a given file type and name.
func (*DefaultLayout) Filename ¶
func (l *DefaultLayout) Filename(h backend.Handle) string
Filename returns a path to a file, including its name.
func (*DefaultLayout) Name ¶
func (l *DefaultLayout) Name() string
Name returns the name for this layout.
func (*DefaultLayout) Paths ¶
func (l *DefaultLayout) Paths() (dirs []string)
Paths returns all directory names needed for a repo.
func (*DefaultLayout) String ¶
func (l *DefaultLayout) String() string
type Filesystem ¶
type Filesystem interface { Join(...string) string ReadDir(context.Context, string) ([]os.FileInfo, error) IsNotExist(error) bool }
Filesystem is the abstraction of a file system used for a backend.
type Layout ¶
type Layout interface { Filename(backend.Handle) string Dirname(backend.Handle) string Basedir(backend.FileType) (dir string, subdirs bool) Paths() []string Name() string }
Layout computes paths for file name storage.
func DetectLayout ¶
DetectLayout tries to find out which layout is used in a local (or sftp) filesystem at the given path. If repo is nil, an instance of LocalFilesystem is used.
func ParseLayout ¶
func ParseLayout(ctx context.Context, repo Filesystem, layout, defaultLayout, path string) (l Layout, err error)
ParseLayout parses the config string and returns a Layout. When layout is the empty string, DetectLayout is used. If that fails, defaultLayout is used.
type LocalFilesystem ¶
type LocalFilesystem struct { }
LocalFilesystem implements Filesystem in a local path.
func (*LocalFilesystem) IsNotExist ¶
func (l *LocalFilesystem) IsNotExist(err error) bool
IsNotExist returns true for errors that are caused by not existing files.
func (*LocalFilesystem) Join ¶
func (l *LocalFilesystem) Join(paths ...string) string
Join combines several path components to one.
type RESTLayout ¶
RESTLayout implements the default layout for the REST protocol.
func (*RESTLayout) Basedir ¶
func (l *RESTLayout) Basedir(t backend.FileType) (dirname string, subdirs bool)
Basedir returns the base dir name for files of type t.
func (*RESTLayout) Dirname ¶
func (l *RESTLayout) Dirname(h backend.Handle) string
Dirname returns the directory path for a given file type and name.
func (*RESTLayout) Filename ¶
func (l *RESTLayout) Filename(h backend.Handle) string
Filename returns a path to a file, including its name.
func (*RESTLayout) Paths ¶
func (l *RESTLayout) Paths() (dirs []string)
Paths returns all directory names
func (*RESTLayout) String ¶
func (l *RESTLayout) String() string
type S3LegacyLayout ¶
S3LegacyLayout implements the old layout used for s3 cloud storage backends, as described in the Design document.
func (*S3LegacyLayout) Basedir ¶
func (l *S3LegacyLayout) Basedir(t backend.FileType) (dirname string, subdirs bool)
Basedir returns the base dir name for type t.
func (*S3LegacyLayout) Dirname ¶
func (l *S3LegacyLayout) Dirname(h backend.Handle) string
Dirname returns the directory path for a given file type and name.
func (*S3LegacyLayout) Filename ¶
func (l *S3LegacyLayout) Filename(h backend.Handle) string
Filename returns a path to a file, including its name.
func (*S3LegacyLayout) Name ¶
func (l *S3LegacyLayout) Name() string
Name returns the name for this layout.
func (*S3LegacyLayout) Paths ¶
func (l *S3LegacyLayout) Paths() (dirs []string)
Paths returns all directory names
func (*S3LegacyLayout) String ¶
func (l *S3LegacyLayout) String() string