Documentation ¶
Overview ¶
Package storage implements operations for s3 and fs.
Index ¶
- Variables
- func IsCancelationError(err error) bool
- func IsGoogleEndpoint(endpoint urlpkg.URL) bool
- func ShouldProcessUrl(url *url.URL, followSymlinks bool) bool
- type Bucket
- type ErrGivenObjectNotFound
- type Filesystem
- func (f *Filesystem) Copy(ctx context.Context, src, dst *url.URL, _ Metadata) error
- func (f *Filesystem) Create(path string) (*os.File, error)
- func (f *Filesystem) Delete(ctx context.Context, url *url.URL) error
- func (f *Filesystem) List(ctx context.Context, src *url.URL, followSymlinks bool) <-chan *Object
- func (f *Filesystem) MkdirAll(path string) error
- func (f *Filesystem) MultiDelete(ctx context.Context, urlch <-chan *url.URL) <-chan *Object
- func (f *Filesystem) Open(path string) (*os.File, error)
- func (f *Filesystem) Stat(ctx context.Context, url *url.URL) (*Object, error)
- type Metadata
- func (m Metadata) ACL() string
- func (m Metadata) CacheControl() string
- func (m Metadata) ContentEncoding() string
- func (m Metadata) ContentType() string
- func (m Metadata) Expires() string
- func (m Metadata) SSE() string
- func (m Metadata) SSEKeyID() string
- func (m Metadata) SetACL(acl string) Metadata
- func (m Metadata) SetCacheControl(cacheControl string) Metadata
- func (m Metadata) SetContentEncoding(contentEncoding string) Metadata
- func (m Metadata) SetContentType(contentType string) Metadata
- func (m Metadata) SetExpires(expires string) Metadata
- func (m Metadata) SetSSE(sse string) Metadata
- func (m Metadata) SetSSEKeyID(kid string) Metadata
- func (m Metadata) SetStorageClass(class string) Metadata
- func (m Metadata) StorageClass() string
- type MockStorage
- func (_m *MockStorage) Copy(ctx context.Context, src *url.URL, dst *url.URL, metadata Metadata) error
- func (_m *MockStorage) Delete(ctx context.Context, src *url.URL) error
- func (_m *MockStorage) List(ctx context.Context, src *url.URL, followSymlinks bool) <-chan *Object
- func (_m *MockStorage) MultiDelete(ctx context.Context, urls <-chan *url.URL) <-chan *Object
- func (_m *MockStorage) Stat(ctx context.Context, src *url.URL) (*Object, error)
- type Object
- type ObjectType
- type Options
- type S3
- func (s *S3) Copy(ctx context.Context, from, to *url.URL, metadata Metadata) error
- func (s *S3) Delete(ctx context.Context, url *url.URL) error
- func (s *S3) Get(ctx context.Context, from *url.URL, to io.WriterAt, concurrency int, ...) (int64, error)
- func (s *S3) List(ctx context.Context, url *url.URL, _ bool) <-chan *Object
- func (s *S3) ListBuckets(ctx context.Context, prefix string) ([]Bucket, error)
- func (s *S3) MakeBucket(ctx context.Context, name string) error
- func (s *S3) MultiDelete(ctx context.Context, urlch <-chan *url.URL) <-chan *Object
- func (s *S3) Put(ctx context.Context, reader io.Reader, to *url.URL, metadata Metadata, ...) error
- func (s *S3) Read(ctx context.Context, src *url.URL) (io.ReadCloser, error)
- func (s *S3) RemoveBucket(ctx context.Context, name string) error
- func (s *S3) RequestPayer() *string
- func (s *S3) Select(ctx context.Context, url *url.URL, query *SelectQuery, ...) error
- func (s *S3) Stat(ctx context.Context, url *url.URL) (*Object, error)
- type SelectQuery
- type SessionCache
- type Storage
- type StorageClass
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoObjectFound indicates there are no objects found from a given directory. ErrNoObjectFound = fmt.Errorf("no object found") )
Functions ¶
func IsCancelationError ¶
IsCancelationError reports whether given error is a storage related cancelation error.
func IsGoogleEndpoint ¶
Types ¶
type ErrGivenObjectNotFound ¶
type ErrGivenObjectNotFound struct {
ObjectAbsPath string
}
ErrGivenObjectNotFound indicates a specified object is not found.
func (*ErrGivenObjectNotFound) Error ¶
func (e *ErrGivenObjectNotFound) Error() string
type Filesystem ¶
type Filesystem struct {
// contains filtered or unexported fields
}
Filesystem is the Storage implementation of a local filesystem.
func NewLocalClient ¶
func NewLocalClient(opts Options) *Filesystem
func (*Filesystem) Create ¶
func (f *Filesystem) Create(path string) (*os.File, error)
Create creates a new os.File.
func (*Filesystem) MkdirAll ¶
func (f *Filesystem) MkdirAll(path string) error
MkdirAll calls os.MkdirAll.
func (*Filesystem) MultiDelete ¶
MultiDelete deletes all files returned from given channel.
type Metadata ¶
func (Metadata) CacheControl ¶
func (Metadata) ContentEncoding ¶
func (Metadata) ContentType ¶
func (Metadata) SetCacheControl ¶
func (Metadata) SetContentEncoding ¶
func (Metadata) SetContentType ¶
func (Metadata) SetExpires ¶
func (Metadata) SetSSEKeyID ¶
func (Metadata) SetStorageClass ¶
func (Metadata) StorageClass ¶
type MockStorage ¶
MockStorage is an autogenerated mock type for the Storage type
func (*MockStorage) Copy ¶
func (_m *MockStorage) Copy(ctx context.Context, src *url.URL, dst *url.URL, metadata Metadata) error
Copy provides a mock function with given fields: ctx, src, dst, metadata
func (*MockStorage) List ¶
List provides a mock function with given fields: ctx, src, followSymlinks
func (*MockStorage) MultiDelete ¶
MultiDelete provides a mock function with given fields: ctx, urls
type Object ¶
type Object struct { URL *url.URL `json:"key,omitempty"` Etag string `json:"etag,omitempty"` ModTime *time.Time `json:"last_modified,omitempty"` Type ObjectType `json:"type,omitempty"` Size int64 `json:"size,omitempty"` StorageClass StorageClass `json:"storage_class,omitempty"` Err error `json:"error,omitempty"` // contains filtered or unexported fields }
Object is a generic type which contains metadata for storage items.
type ObjectType ¶
type ObjectType struct {
// contains filtered or unexported fields
}
ObjectType is the type of Object.
func (ObjectType) IsDir ¶
func (o ObjectType) IsDir() bool
IsDir checks if the object is a directory.
func (ObjectType) IsSymlink ¶
func (o ObjectType) IsSymlink() bool
IsSymlink checks if the object is a symbolic link.
func (ObjectType) MarshalJSON ¶
func (o ObjectType) MarshalJSON() ([]byte, error)
MarshalJSON returns the stringer of ObjectType as a marshalled json.
func (ObjectType) String ¶
func (o ObjectType) String() string
String returns the string representation of ObjectType.
type Options ¶
type Options struct { MaxRetries int NoSuchUploadRetryCount int Endpoint string NoVerifySSL bool DryRun bool NoSignRequest bool UseListObjectsV1 bool LogLevel log.LogLevel RequestPayer string Profile string CredentialFile string // contains filtered or unexported fields }
Options stores configuration for storage.
type S3 ¶
type S3 struct {
// contains filtered or unexported fields
}
S3 is a storage type which interacts with S3API, DownloaderAPI and UploaderAPI.
func NewRemoteClient ¶
func (*S3) Copy ¶
Copy is a single-object copy operation which copies objects to S3 destination from another S3 source.
func (*S3) Get ¶
func (s *S3) Get( ctx context.Context, from *url.URL, to io.WriterAt, concurrency int, partSize int64, ) (int64, error)
Get is a multipart download operation which downloads S3 objects into any destination that implements io.WriterAt interface. Makes a single 'GetObject' call if 'concurrency' is 1 and ignores 'partSize'.
func (*S3) List ¶
List is a non-blocking S3 list operation which paginates and filters S3 keys. If no object found or an error is encountered during this period, it sends these errors to object channel.
func (*S3) ListBuckets ¶
ListBuckets is a blocking list-operation which gets bucket list and returns the buckets that match with given prefix.
func (*S3) MakeBucket ¶
MakeBucket creates an S3 bucket with the given name.
func (*S3) MultiDelete ¶
MultiDelete is a asynchronous removal operation for multiple objects. It reads given url channel, creates multiple chunks and run these chunks in parallel. Each chunk may have at most 1000 objects since DeleteObjects API has a limitation. See: https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObjects.html.
func (*S3) Put ¶
func (s *S3) Put( ctx context.Context, reader io.Reader, to *url.URL, metadata Metadata, concurrency int, partSize int64, ) error
Put is a multipart upload operation to upload resources, which implements io.Reader interface, into S3 destination.
func (*S3) RemoveBucket ¶
RemoveBucket removes an S3 bucket with the given name.
func (*S3) RequestPayer ¶
type SelectQuery ¶
type SessionCache ¶
SessionCache holds session.Session according to s3Opts and it synchronizes access/modification.
type Storage ¶
type Storage interface { // Stat returns the Object structure describing object. If src is not // found, ErrGivenObjectNotFound is returned. Stat(ctx context.Context, src *url.URL) (*Object, error) // List the objects and directories/prefixes in the src. List(ctx context.Context, src *url.URL, followSymlinks bool) <-chan *Object // Delete deletes the given src. Delete(ctx context.Context, src *url.URL) error // MultiDelete deletes all items returned from given urls in batches. MultiDelete(ctx context.Context, urls <-chan *url.URL) <-chan *Object // Copy src to dst, optionally setting the given metadata. Src and dst // arguments are of the same type. If src is a remote type, server side // copying will be used. Copy(ctx context.Context, src, dst *url.URL, metadata Metadata) error }
Storage is an interface for storage operations that is common to local filesystem and remote object storage.
type StorageClass ¶
type StorageClass string
StorageClass represents the storage used to store an object.
func (StorageClass) IsGlacier ¶
func (s StorageClass) IsGlacier() bool