mirror of
https://github.com/grafana/grafana.git
synced 2024-11-26 02:40:26 -06:00
70c7724b65
* GCS uploader: Add tests Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> * Use go generate Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
45 lines
1.3 KiB
Go
45 lines
1.3 KiB
Go
// Package gcsifaces provides interfaces for Google Cloud Storage.
|
|
//go:generate mockgen -source $GOFILE -destination ../../mocks/mock_gcsifaces/mocks.go StorageClient
|
|
package gcsifaces
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
|
|
"cloud.google.com/go/storage"
|
|
"golang.org/x/oauth2/google"
|
|
"golang.org/x/oauth2/jwt"
|
|
)
|
|
|
|
// StorageClient represents a GCS client.
|
|
type StorageClient interface {
|
|
// Bucket gets a StorageBucket.
|
|
Bucket(name string) StorageBucket
|
|
// FindDefaultCredentials finds default Google credentials.
|
|
FindDefaultCredentials(ctx context.Context, scope string) (*google.Credentials, error)
|
|
// JWTConfigFromJSON gets JWT config from a JSON document.
|
|
JWTConfigFromJSON(keyJSON []byte) (*jwt.Config, error)
|
|
// SignedURL returns a signed URL for the specified object.
|
|
SignedURL(bucket, name string, opts *storage.SignedURLOptions) (string, error)
|
|
}
|
|
|
|
// StorageBucket represents a GCS bucket.
|
|
type StorageBucket interface {
|
|
// Object returns a StorageObject for a key.
|
|
Object(key string) StorageObject
|
|
}
|
|
|
|
// StorageObject represents a GCS object.
|
|
type StorageObject interface {
|
|
// NewWriter returns a new StorageWriter.
|
|
NewWriter(ctx context.Context) StorageWriter
|
|
}
|
|
|
|
// StorageWriter represents a GCS writer.
|
|
type StorageWriter interface {
|
|
io.WriteCloser
|
|
|
|
// SetACL sets a pre-defined ACL.
|
|
SetACL(acl string)
|
|
}
|