Documentation
¶
Index ¶
Constants ¶
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.
const NoneCredentialsSource = "none"
NoneCredentialsSource specifies that credentials are explicitly empty and that the client should be restricted to a read-only scope.
const ServiceAccountFileCredentialsSource = "static"
ServiceAccountFileCredentialsSource specifies that a service account file included in json_key should be used for authentication.
Variables ¶
var ErrBadLocationStorageClass = errors.New("incompatible location and storage_class")
ErrBadLocationStorageClass is returned when location and storage_class cannot be combined
var ErrEmptyBucketName = errors.New("bucket_name must be set")
ErrEmptyBucketName is returned when a bucket_name in the config is empty
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.
var ErrUnknownLocation = errors.New("unknown location")
ErrUnknownLocation is returned when a location is chosen that this package has no knowledge of.
var ErrUnknownStorageClass = errors.New("unknown storage_class")
ErrUnknownStorageClass is returned when a stroage_class is chosen that this package has no knowledge of.
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.
var GCSMultiRegionalLocations = map[string]struct{}{
"ASIA": struct{}{},
"EU": struct{}{},
"US": struct{}{},
}
GCSMultiRegionalLocations are the valid locations for a multi-regional bucket
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.
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 ¶
NewFromReader returns the new gcscli configuration struct from the contents of the reader.
reader.Read() is expected to return valid JSON.
func (*GCSCli) FitCompatibleLocation ¶
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.