Documentation ¶
Index ¶
- Constants
- Variables
- func IsNotExist(err error) bool
- func LogClose(c io.Closer)
- func ReadContent(ctx context.Context, logger *logrus.Entry, opener Opener, path string) ([]byte, error)
- func WriteContent(ctx context.Context, logger *logrus.Entry, opener Opener, path string, ...) error
- type Attributes
- type Closer
- type ObjectAttributes
- type ObjectAttrsToUpdate
- type ObjectIterator
- type Opener
- type ReadCloser
- type SignedURLOptions
- type WriteCloser
- type Writer
- type WriterOptions
Constants ¶
const ( GSAnonHost = "storage.googleapis.com" GSCookieHost = "storage.cloud.google.com" )
Variables ¶
var ErrNotFoundTest = fmt.Errorf("not found error which should only be used in tests")
ErrNotFoundTest can be used for unit tests to simulate NotFound errors. This is required because gocloud doesn't expose its errors.
var PreconditionFailedObjectAlreadyExists = fmt.Errorf("object already exists")
Functions ¶
func IsNotExist ¶
IsNotExist will return true if the error shows that the object does not exist.
func ReadContent ¶
Types ¶
type Attributes ¶
type Attributes struct { // ContentEncoding specifies the encoding used for the blob's content, if any. // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding ContentEncoding string // ContentType is the MIME type of the blob, if any. // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type ContentType string // ContentDisposition specifies whether the blob content is expected to be displayed inline or as an attachment. // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition ContentDisposition string // ContentLanguage specifies the language used in the blob's content, if any. // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Language ContentLanguage string // Size is the size of the blob's content in bytes. Size int64 // Metadata includes user-metadata associated with the file Metadata map[string]string }
type ObjectAttributes ¶
type ObjectAttributes struct { // Name is the full path of the object or directory Name string // ObjName is the last segment of the name in case of an object ObjName string // IsDir is true if the object is a directory IsDir bool // Size is the size of the blob's content in bytes in case of an object. Size int64 // Updated is the creation or modification time in case of the object. Updated time.Time }
type ObjectAttrsToUpdate ¶
type ObjectIterator ¶
type ObjectIterator interface {
Next(ctx context.Context) (attr ObjectAttributes, err error)
}
ObjectIterator iterates through storage objects It returns attr as long as it finds objects. When no objects can be found anymore io.EOF error is returned
type Opener ¶
type Opener interface { Reader(ctx context.Context, path string) (ReadCloser, error) RangeReader(ctx context.Context, path string, offset, length int64) (io.ReadCloser, error) Writer(ctx context.Context, path string, opts ...WriterOptions) (WriteCloser, error) Attributes(ctx context.Context, path string) (Attributes, error) SignedURL(ctx context.Context, path string, opts SignedURLOptions) (string, error) Iterator(ctx context.Context, prefix, delimiter string) (ObjectIterator, error) UpdateAttributes(context.Context, string, ObjectAttrsToUpdate) (*Attributes, error) }
Opener has methods to read and write paths
func NewGCSOpener ¶
NewGCSOpener can be used for testing against a fakeGCSClient
func NewOpener ¶
NewOpener returns an opener that can read GCS, S3 and local paths. credentialsFile may also be empty For local paths it has to be empty In all other cases gocloud auto-discovery is used to detect credentials, if credentialsFile is empty. For more details about the possible content of the credentialsFile see prow/io/providers.GetBucket
type SignedURLOptions ¶
type SignedURLOptions struct { // UseGSCookieAuth defines if we should use cookie auth for GCS, see: // https://cloud.google.com/storage/docs/access-control/cookie-based-authentication UseGSCookieAuth bool }
SignedURLOptions are options for the opener SignedURL method
type WriterOptions ¶
type WriterOptions struct { BufferSize *int64 ContentEncoding *string ContentType *string Metadata map[string]string PreconditionDoesNotExist *bool CacheControl *string }
WriterOptions are options for the opener Writer method
func (WriterOptions) Apply ¶
func (wo WriterOptions) Apply(opts *WriterOptions)