gcs

package
v0.0.0-...-d22e7c3 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2020 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCredentialsEmpty = errors.New("credentials is empty")
)

error list

Functions

func CredentialsFromEnvVar

func CredentialsFromEnvVar(ctx context.Context, name string) (*google.Credentials, error)

CredentialsFromEnvVar return content of credentials from environment variable

func CredentialsFromFile

func CredentialsFromFile(ctx context.Context, path string) (*google.Credentials, error)

CredentialsFromFile return content of credentials from file

func CredentialsFromGcloud

func CredentialsFromGcloud(ctx context.Context) (*google.Credentials, error)

CredentialsFromGcloud to provide credentials form default gcloud command

func CredentialsFromString

func CredentialsFromString(ctx context.Context, content string) (*google.Credentials, error)

CredentialsFromString if user want to load credentials by their own

Types

type Config

type Config struct {
	Bucket      string
	BucketProto string
	BucketURL   string
	// contains filtered or unexported fields
}

Config of Google Cloud Storage

func NewConfig

func NewConfig(ctx context.Context, creds *google.Credentials) (*Config, error)

NewConfig to build a new config

func (*Config) SetBucket

func (c *Config) SetBucket(bucket string) *Config

SetBucket set bucket name

func (*Config) SetBucketProto

func (c *Config) SetBucketProto(bucketProto string) *Config

SetBucketProto set bucket protocol

func (*Config) SetBucketURL

func (c *Config) SetBucketURL(bucketURL string) *Config

SetBucketURL set bucket URL

type GCS

type GCS struct {
	// contains filtered or unexported fields
}

GCS struct

func New

func New(ctx context.Context, config *Config) (*GCS, error)

New gcs storage gcs storage expect user already authenticated using 'gcs' command json path is a path to json service account path

func (*GCS) Bucket

func (gcs *GCS) Bucket() *blob.Bucket

Bucket function

func (*GCS) BucketName

func (gcs *GCS) BucketName() string

BucketName return name of bucket used for objectstorage

func (*GCS) BucketURL

func (gcs *GCS) BucketURL() string

BucketURL return full path for bucket

func (*GCS) Close

func (gcs *GCS) Close() error

Close the gcs bucket

func (*GCS) Name

func (gcs *GCS) Name() string

Name of objectstorage provider

Jump to

Keyboard shortcuts

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