storage

package
v0.0.0-...-fbcd7f5 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API interface {
	CreateBucket(ctx context.Context, name string, location string) error
	DeleteBucket(ctx context.Context, name string) error
	Read(ctx context.Context, bucket, storageObject string) ([]byte, error)
	Write(ctx context.Context, data []byte, bucket, storageObject string) error
}

API provides a mockable interface for the GCP api. Find the implementation of the GCP wrapped API in wrapped.go

type APIWrapper

type APIWrapper struct {
	ProjectID string
	GCSClient *gcs.Client
}

APIWrapper wraps the GCP api

func (*APIWrapper) CreateBucket

func (caw *APIWrapper) CreateBucket(ctx context.Context, name string, location string) error

CreateBucket attempts to create a storage bucket

func (*APIWrapper) DeleteBucket

func (caw *APIWrapper) DeleteBucket(ctx context.Context, name string) error

DeleteBucket attempts to delete a storage bucket

func (*APIWrapper) Read

func (caw *APIWrapper) Read(ctx context.Context, bucket, storageObject string) ([]byte, error)

Read attempts to read from a storage bucket

func (*APIWrapper) Write

func (caw *APIWrapper) Write(ctx context.Context, data []byte, bucket, storageObject string) error

Write attempts to write to a storage bucket

type Bucket

type Bucket struct {
	Name     string `yaml:"name"`
	Location string `yaml:"location,omitempty"`
}

Struct that defines each bucket to create

type Client

type Client struct {
	Option
	// contains filtered or unexported fields
}

Client wrapper for GCS storage API

func New

func New(opts Option, api API) (*Client, error)

New returns a new Client, wrapping gcs for storage management on GCP

func NewClient

func NewClient(ctx context.Context, opts Option, credentials string) (*Client, error)

func (*Client) CreateBucket

func (sc *Client) CreateBucket(ctx context.Context, name string, location string) error

CreateBucket attempts to create a storage bucket

func (*Client) DeleteBucket

func (sc *Client) DeleteBucket(ctx context.Context, name string) error

DeleteBucket attempts to delete a storage bucket

func (*Client) Read

func (sc *Client) Read(ctx context.Context, bucket, storageObject string) ([]byte, error)

Read attempts to read from a storage bucket

func (*Client) Write

func (sc *Client) Write(ctx context.Context, data []byte, bucket, storageObject string) error

Write attempts to write to a storage bucket

type Option

type Option struct {
	Prefix         string // storage prefix
	ProjectID      string // GCP project ID
	LocationID     string // location of the key rings
	ServiceAccount string // filename of the serviceaccount to use
}

Option wrapper for relevant Options for the client

func (Option) WithPrefix

func (o Option) WithPrefix(pre string) Option

WithPrefix modifies option to have a prefix

func (Option) WithProjectID

func (o Option) WithProjectID(pid string) Option

WithProjectID modifies option to have a project id

func (Option) WithServiceAccount

func (o Option) WithServiceAccount(sa string) Option

WithServiceAccount modifies option to have a service account

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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