config

package
v0.0.0-...-73df0bb Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2018 License: Apache-2.0, Apache-2.0, Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultCredentialsSource = ""

DefaultCredentialsSource specifies that credentials should be detected. Application Default Credentials will be used if avaliable. A read-only client will be used otherwise.

View Source
const NoneCredentialsSource = "none"

NoneCredentialsSource specifies that credentials are explicitly empty and that the client should be restricted to a read-only scope.

View Source
const ServiceAccountFileCredentialsSource = "static"

ServiceAccountFileCredentialsSource specifies that a service account file included in json_key should be used for authentication.

Variables

View Source
var ErrBadLocationStorageClass = errors.New("incompatible location and storage_class")

ErrBadLocationStorageClass is returned when location and storage_class cannot be combined

View Source
var ErrEmptyBucketName = errors.New("bucket_name must be set")

ErrEmptyBucketName is returned when a bucket_name in the config is empty

View Source
var ErrEmptyServiceAccountFile = errors.New("json_key must be set")

ErrEmptyServiceAccountFile is returned when json_key in the config is empty when StaticCredentialsSource is explicitly requested.

View Source
var ErrUnknownLocation = errors.New("unknown location")

ErrUnknownLocation is returned when a location is chosen that this package has no knowledge of.

View Source
var ErrUnknownStorageClass = errors.New("unknown storage_class")

ErrUnknownStorageClass is returned when a stroage_class is chosen that this package has no knowledge of.

View Source
var ErrWrongLengthEncryptionKey = errors.New("encryption_key not 32 bytes")

ErrWrongLengthEncryptionKey is returned when a non-nil encryption_key in the config is not exactly 32 bytes.

View Source
var GCSMultiRegionalLocations = map[string]struct{}{
	"ASIA": struct{}{},
	"EU":   struct{}{},
	"US":   struct{}{},
}

GCSMultiRegionalLocations are the valid locations for a multi-regional bucket

View Source
var GCSRegionalLocations = map[string]struct{}{
	"US-CENTRAL1":     struct{}{},
	"US-EAST1":        struct{}{},
	"US-WEST1":        struct{}{},
	"US-EAST4":        struct{}{},
	"EUROPE-WEST1":    struct{}{},
	"ASIA-EAST1":      struct{}{},
	"ASIA-NORTHEAST1": struct{}{},
	"ASIA-SOUTHEAST1": struct{}{},
}

GCSRegionalLocations are the valid locations for a regional bucket.

View Source
var GCSStorageClass = map[string]struct{}{
	// contains filtered or unexported fields
}

GCSStorageClass are the valid storage classes for a bucket.

Functions

This section is empty.

Types

type GCSCli

type GCSCli struct {
	// BucketName is the GCS bucket operations will use.
	BucketName string `json:"bucket_name"`
	// CredentialsSource is the location of a Service Account File.
	// If left empty, Application Default Credentials will be used if available.
	// If equal to 'none', read-only scope will be used.
	// If equal to 'static', json_key will be used.
	CredentialsSource string `json:"credentials_source"`
	// ServiceAccountFile is the contents of a JSON Service Account File.
	// Required if credentials_source is 'static', otherwise ignored.
	ServiceAccountFile string `json:"json_key"`
	// StorageClass is the type of storage used for objects added to the bucket
	// https://cloud.google.com/storage/docs/storage-classes
	StorageClass string `json:"storage_class"`
	// EncryptionKey is a Customer-Supplied encryption key used to
	// encrypt objects added to the bucket.
	// If left empty, no explicit encryption key will be used;
	// GCS transparently encrypts data using server-side encryption keys.
	// https://cloud.google.com/storage/docs/encryption
	EncryptionKey []byte `json:"encryption_key"`
}

GCSCli represents the configuration for the gcscli

func NewFromReader

func NewFromReader(reader io.Reader) (GCSCli, error)

NewFromReader returns the new gcscli configuration struct from the contents of the reader.

reader.Read() is expected to return valid JSON.

func (*GCSCli) FitCompatibleLocation

func (c *GCSCli) FitCompatibleLocation(loc string) error

FitCompatibleLocation returns whether a provided Location can have c.StorageClass objects written to it.

When c.StorageClass is empty, a compatible default is filled in.

nil return value when compatible, otherwise a non-nil explanation.

Jump to

Keyboard shortcuts

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