io

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GSAnonHost   = "storage.googleapis.com"
	GSCookieHost = "storage.cloud.google.com"
)

Variables

View Source
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.

View Source
var PreconditionFailedObjectAlreadyExists = fmt.Errorf("object already exists")

Functions

func IsNotExist

func IsNotExist(err error) bool

IsNotExist will return true if the error shows that the object does not exist.

func LogClose

func LogClose(c io.Closer)

LogClose will attempt a close an log any error

func ReadContent

func ReadContent(ctx context.Context, logger *logrus.Entry, opener Opener, path string) ([]byte, error)

func WriteContent

func WriteContent(ctx context.Context, logger *logrus.Entry, opener Opener, path string, content []byte, opts ...WriterOptions) error

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
	// 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
}

type ObjectAttrsToUpdate

type ObjectAttrsToUpdate struct {
	ContentEncoding *string
	Metadata        map[string]string
}

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)
	UpdateAtributes(context.Context, string, ObjectAttrsToUpdate) (*Attributes, error)
}

Opener has methods to read and write paths

func NewGCSOpener

func NewGCSOpener(gcsClient *storage.Client) Opener

NewGCSOpener can be used for testing against a fakeGCSClient

func NewOpener

func NewOpener(ctx context.Context, gcsCredentialsFile, s3CredentialsFile string) (Opener, error)

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 ReadCloser

type ReadCloser = io.ReadCloser

Aliases to types in the standard library

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 WriteCloser

type WriteCloser = io.WriteCloser

Aliases to types in the standard library

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)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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