Documentation ¶
Index ¶
- Variables
- func CreateBucket(creator BucketCreator, bucketName string) error
- func CredsOK(fs sys.FS) bool
- func DownloadObject(getter ObjectGetter, bucketName, objKey string) ([]byte, error)
- func ObjectExists(statter ObjectStatter, bucketName, objKey string) (bool, error)
- func UploadObject(putter ObjectPutter, bucketName, objKey string, reader io.Reader) error
- func WaitForObject(statter ObjectStatter, bucketName, objKey string, tick, timeout time.Duration) error
- type BucketCreator
- type Client
- type Endpoint
- type FakeBucketCreator
- type FakeGetObjectCall
- type FakeMakeBucketCall
- type FakeObject
- type FakeObjectGetter
- type FakeObjectPutter
- type FakeObjectStatter
- type FakePutObjectCall
- type FakeStatObjectCall
- type Object
- type ObjectGetter
- type ObjectPutter
- type ObjectStatter
- type RealObjectGetter
- type SlugBuilderInfo
- func (s SlugBuilderInfo) AbsoluteProcfileKey() string
- func (s SlugBuilderInfo) AbsoluteSlugObjectKey() string
- func (s SlugBuilderInfo) AbsoluteSlugURL() string
- func (s SlugBuilderInfo) PushKey() string
- func (s SlugBuilderInfo) PushURL() string
- func (s SlugBuilderInfo) TarKey() string
- func (s SlugBuilderInfo) TarURL() string
Constants ¶
This section is empty.
Variables ¶
var ( // ACLPublicRead default ACL for objects in the S3 API compatible storage. ACLPublicRead = s3.BucketACL("public-read") )
Functions ¶
func CreateBucket ¶
func CreateBucket(creator BucketCreator, bucketName string) error
CreateBucket creates a new bucket in the S3 API compatible storage. If the bucket was successfully created or already exists, returns nil. Otherwise returns an appropriate error.
func DownloadObject ¶
func DownloadObject(getter ObjectGetter, bucketName, objKey string) ([]byte, error)
DownloadObject uses the given getter to download the contents the object at ${bucketName}/${objKey} and returns the object's contents in the given byte slice. Returns nil and the appropriate error if there were problems with the download.
func ObjectExists ¶
func ObjectExists(statter ObjectStatter, bucketName, objKey string) (bool, error)
ObjectExists determines whether the object in ${bucketName}/${objKey} exists, as reported by statter. Returns the following:
- false, nil if statter succeeded and reported the object doesn't exist - false, err with the appropriate error if the statter failed - true, nil if the statter succeeded and reported the object exists
func UploadObject ¶
func UploadObject(putter ObjectPutter, bucketName, objKey string, reader io.Reader) error
UploadObject uploads the contents of readaer to ${bucektName}/${objectKey} using the given putter.
func WaitForObject ¶
func WaitForObject(statter ObjectStatter, bucketName, objKey string, tick, timeout time.Duration) error
WaitForObject checks statter for the object at ${bucketName}/${objKey} right away, then at every tick, then once when the timeout is up. Returns nil if it finds the object before or at timeout. Otherwise returns a non-nil error.
Types ¶
type BucketCreator ¶
type BucketCreator interface {
MakeBucket(bucketName string, acl s3.BucketACL, location string) error
}
BucketCreator is a *(github.com/minio/minio-go).Client compatible interface, restricted to just the MakeBucket function. You can use it in your code for easier unit testing without any external dependencies.
type Client ¶
type Client struct { *s3.Client // Endpoint is the the endpoint information for the location that the S3 client will access. Endpoint *Endpoint }
Client is the S3 client combined with the S3 endpoint.
type Endpoint ¶
type Endpoint struct { // URLStr is the url string, stripped of its scheme. URLStr string // Secure determines if TLS should be used (e.g. a "https://" scheme). Secure bool }
Endpoint represents all the details about a storage endpoint.
type FakeBucketCreator ¶
type FakeBucketCreator struct { Fn func(string, s3.BucketACL, string) error Calls []FakeMakeBucketCall }
FakeBucketCreator is a mock function that can be swapped in for an BucketCreator, so you can unit test your code.
func (*FakeBucketCreator) MakeBucket ¶
MakeBucket is the interface definition for BucketCreator.
type FakeGetObjectCall ¶
FakeGetObjectCall represents a single call a single call to GetObject on a FakeObjectGetter.
type FakeMakeBucketCall ¶
FakeMakeBucketCall represents a single call to MakeBucket on a FakeBucketCreator.
type FakeObject ¶
type FakeObject struct {
Data string
}
FakeObject is a mock function that can be swapped in for an *s3.Object, so you can unit test your code.
func (*FakeObject) Close ¶
func (f *FakeObject) Close() (err error)
Close is the interface definition for Object.
func (*FakeObject) Read ¶
func (f *FakeObject) Read(b []byte) (n int, err error)
Read is the interface definition for Object.
func (*FakeObject) ReadAt ¶
func (f *FakeObject) ReadAt(b []byte, offset int64) (n int, err error)
ReadAt is the interface definition for Object.
func (*FakeObject) Seek ¶
func (f *FakeObject) Seek(offset int64, whence int) (n int64, err error)
Seek is the interface definition for Object.
func (*FakeObject) Stat ¶
func (f *FakeObject) Stat() (s3.ObjectInfo, error)
Stat is the interface definition for Object.
type FakeObjectGetter ¶
type FakeObjectGetter struct { Fn func(string, string) (Object, error) Calls []FakeGetObjectCall }
FakeObjectGetter is a mock function that can be swapped in for an ObjectGetter, so you can unit test your code.
type FakeObjectPutter ¶
type FakeObjectPutter struct { Fn func(bucketName, objectKey string, reader io.Reader, contentType string) (int64, error) Calls []FakePutObjectCall }
FakeObjectPutter is a mock function that can be swapped in for an ObjectPutter, so you can unit test your code.
type FakeObjectStatter ¶
type FakeObjectStatter struct { Fn func(string, string) (s3.ObjectInfo, error) Calls []FakeStatObjectCall }
FakeObjectStatter is a mock function that can be swapped in for an ObjectStatter, so you can unit test your code.
func (*FakeObjectStatter) StatObject ¶
func (f *FakeObjectStatter) StatObject(bucketName, objectKey string) (s3.ObjectInfo, error)
StatObject is the interface definition.
type FakePutObjectCall ¶
type FakePutObjectCall struct { BucketName string ObjectKey string Reader io.Reader ContentType string }
FakePutObjectCall represents a single call to PutObject on a FakeObjectPutter.
type FakeStatObjectCall ¶
FakeStatObjectCall represents a single call to StatObject on the FakeObjectStatter.
type Object ¶
type Object interface { // This is called an interface composition - it automatically gives your interface the function // in io.Reader (https://godoc.org/io#Reader) and the function in io.Closer // (https://godoc.org/io#Closer). io.ReadCloser // This is also an interface composition. It gives your interface the function in // io.Seeker (https://godoc.org/io#Seeker). io.Seeker // This is also interface composition. It gives your interface the function in // io.ReaderAt (https://godoc.org/io#ReaderAt). io.ReaderAt // This function is the last one we have to add to make this interface have all the same // functions as s3.Object. Stat() (s3.ObjectInfo, error) }
Object is a *(github.com/minio/minio-go).Object compatible interface. Currently, ObjectGetter returns these so that FakeObjectGetters can return mock implementations.
type ObjectGetter ¶
type ObjectGetter interface { // GetObject is *almost* the same function as the GetObject func in the minio client, but it // returns Object instead of *s3.Object. GetObject(string, string) (Object, error) }
ObjectGetter is the interface to get an object from object storage. The minio client doesn't already satisfy this interface, because the GetObject func (https://godoc.org/github.com/minio/minio-go#Client.GetObject) doesn't return an Object. Instead, it returns a *s3.Object. Use the RealObjectGetter below to use the minio client.
type ObjectPutter ¶
type ObjectPutter interface {
PutObject(bucketName, objectKey string, reader io.Reader, contentType string) (int64, error)
}
ObjectPutter is a *(github.com/minio/minio-go).Client compatible interface, restricted to just the PutObject function. You can use it in your code for easier unit testing without any external dependencies.
type ObjectStatter ¶
type ObjectStatter interface {
StatObject(bucketName, objectKey string) (s3.ObjectInfo, error)
}
ObjectStatter is a *(github.com/minio/minio-go).Client compatible interface, restricted to just the StatObject function. You can use it in your code for easier unit testing without any external dependencies (like access to S3).
type RealObjectGetter ¶
RealObjectGetter is an adapter to make the *s3.Client GetObject function compatible with the ObjectGetter interface.
type SlugBuilderInfo ¶
type SlugBuilderInfo struct {
// contains filtered or unexported fields
}
SlugBuilderInfo contains all of the object storage related information needed to pass to a slug builder.
func NewSlugBuilderInfo ¶
func NewSlugBuilderInfo(s3Endpoint *Endpoint, bucket, appName, slugName string, gitSha *git.SHA) *SlugBuilderInfo
NewSlugBuilderInfo creates and populates a new SlugBuilderInfo based on the given data.
func (SlugBuilderInfo) AbsoluteProcfileKey ¶
func (s SlugBuilderInfo) AbsoluteProcfileKey() string
AbsoluteProcfileKey returns the PushKey plus the standard procfile name.
func (SlugBuilderInfo) AbsoluteSlugObjectKey ¶
func (s SlugBuilderInfo) AbsoluteSlugObjectKey() string
AbsoluteSlugObjectKey returns the PushKey plus the final filename of the slug.
func (SlugBuilderInfo) AbsoluteSlugURL ¶
func (s SlugBuilderInfo) AbsoluteSlugURL() string
AbsoluteSlugURL returns the PushURL plus the final filename of the slug.
func (SlugBuilderInfo) PushKey ¶
func (s SlugBuilderInfo) PushKey() string
PushKey returns the object storage key that the slug builder will store the slug in. The returned value only contains the path to the folder, not including the final filename.
func (SlugBuilderInfo) PushURL ¶
func (s SlugBuilderInfo) PushURL() string
PushURL returns the complete object storage URL that the slug builder will store the slug in. The returned value only contains the URL to the folder, not including the final filename.
func (SlugBuilderInfo) TarKey ¶
func (s SlugBuilderInfo) TarKey() string
TarKey returns the object storage key from which the slug builder will download for the tarball (from which it uses to build the slug). The returned value only contains the path to the folder, not including the final filename.
func (SlugBuilderInfo) TarURL ¶
func (s SlugBuilderInfo) TarURL() string
TarURL returns the complete object storage URL that the slug builder will download the tarball from. The returned value only contains the URL to the folder, not including the final filename.