vfs

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2016 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Context = VFSContext{
	// contains filtered or unexported fields
}

Functions

func AWSErrorCode

func AWSErrorCode(err error) string

AWSErrorCode returns the aws error code, if it is an awserr.Error, otherwise ""

func IsClusterReadable

func IsClusterReadable(p Path) bool

func IsDirectory

func IsDirectory(p Path) bool

func RelativePath

func RelativePath(base Path, child Path) (string, error)

func SyncDir

func SyncDir(src *VFSScan, destBase Path) error

Types

type Change

type Change struct {
	ChangeType ChangeType
	Path       Path
	Hash       *hashing.Hash
}

type ChangeType

type ChangeType string
const ChangeType_Added ChangeType = "ADDED"
const ChangeType_Modified ChangeType = "MODIFIED"
const ChangeType_Removed ChangeType = "REMOVED"

type FSPath

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

func NewFSPath

func NewFSPath(location string) *FSPath

func (*FSPath) Base

func (p *FSPath) Base() string

func (*FSPath) CreateFile

func (p *FSPath) CreateFile(data []byte) error

func (*FSPath) Hash

func (p *FSPath) Hash(a hashing.HashAlgorithm) (*hashing.Hash, error)

func (*FSPath) Join

func (p *FSPath) Join(relativePath ...string) Path

func (*FSPath) Path

func (p *FSPath) Path() string

func (*FSPath) PreferredHash

func (p *FSPath) PreferredHash() (*hashing.Hash, error)

func (*FSPath) ReadDir

func (p *FSPath) ReadDir() ([]Path, error)

func (*FSPath) ReadFile

func (p *FSPath) ReadFile() ([]byte, error)

func (*FSPath) ReadTree

func (p *FSPath) ReadTree() ([]Path, error)

func (*FSPath) Remove

func (p *FSPath) Remove() error

func (*FSPath) String

func (p *FSPath) String() string

func (*FSPath) WriteFile

func (p *FSPath) WriteFile(data []byte) error

type HasClusterReadable

type HasClusterReadable interface {
	IsClusterReadable() bool
}

type HasHash

type HasHash interface {
	// Returns the hash of the file contents, with the preferred hash algorithm
	PreferredHash() (*hashing.Hash, error)

	// Gets the hash, or nil if the hash cannot be (easily) computed
	Hash(algorithm hashing.HashAlgorithm) (*hashing.Hash, error)
}

type MemFSContext

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

func NewMemFSContext

func NewMemFSContext() *MemFSContext

func (*MemFSContext) MarkClusterReadable

func (c *MemFSContext) MarkClusterReadable()

MarkClusterReadable pretends the current memfscontext is cluster readable; this is useful for tests

type MemFSPath

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

func NewMemFSPath

func NewMemFSPath(context *MemFSContext, location string) *MemFSPath

func (*MemFSPath) Base

func (p *MemFSPath) Base() string

func (*MemFSPath) CreateFile

func (p *MemFSPath) CreateFile(data []byte) error

func (*MemFSPath) IsClusterReadable

func (c *MemFSPath) IsClusterReadable() bool

func (*MemFSPath) Join

func (p *MemFSPath) Join(relativePath ...string) Path

func (*MemFSPath) Path

func (p *MemFSPath) Path() string

func (*MemFSPath) ReadDir

func (p *MemFSPath) ReadDir() ([]Path, error)

func (*MemFSPath) ReadFile

func (p *MemFSPath) ReadFile() ([]byte, error)

func (*MemFSPath) ReadTree

func (p *MemFSPath) ReadTree() ([]Path, error)

func (*MemFSPath) Remove

func (p *MemFSPath) Remove() error

func (*MemFSPath) String

func (p *MemFSPath) String() string

func (*MemFSPath) WriteFile

func (p *MemFSPath) WriteFile(data []byte) error

type Path

type Path interface {
	Join(relativePath ...string) Path
	ReadFile() ([]byte, error)

	WriteFile(data []byte) error
	// CreateFile writes the file contents, but only if the file does not already exist
	CreateFile(data []byte) error

	// Remove deletes the file
	Remove() error

	// Base returns the base name (last element)
	Base() string

	// Path returns a string representing the full path
	Path() string

	// ReadDir lists the files in a particular Path
	ReadDir() ([]Path, error)

	// ReadTree lists all files in the subtree rooted at the current Path
	ReadTree() ([]Path, error)
}

type S3Context added in v1.4.1

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

func NewS3Context added in v1.4.1

func NewS3Context() *S3Context

type S3Path

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

func NewS3Path

func NewS3Path(s3Context *S3Context, bucket string, key string) *S3Path

func (*S3Path) Base

func (p *S3Path) Base() string

func (*S3Path) Bucket

func (p *S3Path) Bucket() string

func (*S3Path) CreateFile

func (p *S3Path) CreateFile(data []byte) error

func (*S3Path) Hash

func (p *S3Path) Hash(a hashing.HashAlgorithm) (*hashing.Hash, error)

func (*S3Path) Join

func (p *S3Path) Join(relativePath ...string) Path

func (*S3Path) Key

func (p *S3Path) Key() string

func (*S3Path) Path

func (p *S3Path) Path() string

func (*S3Path) PreferredHash

func (p *S3Path) PreferredHash() (*hashing.Hash, error)

func (*S3Path) ReadDir

func (p *S3Path) ReadDir() ([]Path, error)

func (*S3Path) ReadFile

func (p *S3Path) ReadFile() ([]byte, error)

func (*S3Path) ReadTree

func (p *S3Path) ReadTree() ([]Path, error)

func (*S3Path) Remove

func (p *S3Path) Remove() error

func (*S3Path) String

func (p *S3Path) String() string

func (*S3Path) WriteFile

func (p *S3Path) WriteFile(data []byte) error

type SSHPath

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

func NewSSHPath

func NewSSHPath(client *ssh.Client, server string, path string, sudo bool) *SSHPath

func (*SSHPath) Base

func (p *SSHPath) Base() string

func (*SSHPath) CreateFile

func (p *SSHPath) CreateFile(data []byte) error

func (*SSHPath) Join

func (p *SSHPath) Join(relativePath ...string) Path

func (*SSHPath) Path

func (p *SSHPath) Path() string

func (*SSHPath) ReadDir

func (p *SSHPath) ReadDir() ([]Path, error)

func (*SSHPath) ReadFile

func (p *SSHPath) ReadFile() ([]byte, error)

func (*SSHPath) ReadTree

func (p *SSHPath) ReadTree() ([]Path, error)

func (*SSHPath) Remove

func (p *SSHPath) Remove() error

func (*SSHPath) String

func (p *SSHPath) String() string

func (*SSHPath) WriteFile

func (p *SSHPath) WriteFile(data []byte) error

type VFS

type VFS interface {
}

type VFSContext

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

VFSContext is a 'context' for VFS, that is normally a singleton but allows us to configure S3 credentials, for example

func (*VFSContext) BuildVfsPath

func (c *VFSContext) BuildVfsPath(p string) (Path, error)

func (*VFSContext) ReadFile

func (c *VFSContext) ReadFile(location string) ([]byte, error)

ReadLocation reads a file from a vfs URL It supports additional schemes which don't (yet) have full VFS implementations:

metadata: reads from instance metadata on GCE/AWS
http / https: reads from HTTP

type VFSScan

type VFSScan struct {
	Base Path
	// contains filtered or unexported fields
}

VFSScan scans a source Path for changes files

func NewVFSScan

func NewVFSScan(base Path) *VFSScan

func (*VFSScan) Scan

func (v *VFSScan) Scan() ([]Change, error)

Scans for changes files. On the first call will return all files as ChangeType_Added. On subsequent calls will return any changed files (using their hashes)

type WriteOption added in v1.4.1

type WriteOption string
const (
	WriteOptionCreate       WriteOption = "Create"
	WriteOptionOnlyIfExists WriteOption = "IfExists"
)

Jump to

Keyboard shortcuts

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