about summary refs log tree commit diff
path: root/tools/nixery/server/storage/gcs.go
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2019-10-27T17·33+0100
committerVincent Ambo <github@tazj.in>2019-10-28T21·31+0100
commite8fd6b67348610ff7bbd4585036567b9e56945b7 (patch)
treed90066bd2a8d35efbc655227432e0772faf3a616 /tools/nixery/server/storage/gcs.go
parent20e0ca53cba796a67311360d7a21c0f7c8baf78a (diff)
refactor(server): Change setup to create new storage backends
Diffstat (limited to 'tools/nixery/server/storage/gcs.go')
-rw-r--r--tools/nixery/server/storage/gcs.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/tools/nixery/server/storage/gcs.go b/tools/nixery/server/storage/gcs.go
index 1b75722bbb77..feb6d30d681e 100644
--- a/tools/nixery/server/storage/gcs.go
+++ b/tools/nixery/server/storage/gcs.go
@@ -30,10 +30,10 @@ type GCSBackend struct {
 
 // Constructs a new GCS bucket backend based on the configured
 // environment variables.
-func New() (GCSBackend, error) {
+func NewGCSBackend() (*GCSBackend, error) {
 	bucket := os.Getenv("GCS_BUCKET")
 	if bucket == "" {
-		return GCSBackend{}, fmt.Errorf("GCS_BUCKET must be configured for GCS usage")
+		return nil, fmt.Errorf("GCS_BUCKET must be configured for GCS usage")
 	}
 
 	ctx := context.Background()
@@ -46,16 +46,16 @@ func New() (GCSBackend, error) {
 
 	if _, err := handle.Attrs(ctx); err != nil {
 		log.WithError(err).WithField("bucket", bucket).Error("could not access configured bucket")
-		return GCSBackend{}, err
+		return nil, err
 	}
 
 	signing, err := signingOptsFromEnv()
 	if err != nil {
 		log.WithError(err).Error("failed to configure GCS bucket signing")
-		return GCSBackend{}, err
+		return nil, err
 	}
 
-	return GCSBackend{
+	return &GCSBackend{
 		bucket:  bucket,
 		handle:  handle,
 		signing: signing,
@@ -66,7 +66,7 @@ func (b *GCSBackend) Name() string {
 	return "Google Cloud Storage (" + b.bucket + ")"
 }
 
-func (b *GCSBackend) Persist(path string, f func(io.Writer) (string, int, error)) (string, int, error) {
+func (b *GCSBackend) Persist(path string, f func(io.Writer) (string, int64, error)) (string, int64, error) {
 	ctx := context.Background()
 	obj := b.handle.Object(path)
 	w := obj.NewWriter(ctx)
@@ -139,7 +139,7 @@ func (b *GCSBackend) Move(old, new string) error {
 	return nil
 }
 
-func (b *GCSBackend) Serve(digest string, w http.ResponseWriter) error {
+func (b *GCSBackend) ServeLayer(digest string, w http.ResponseWriter) error {
 	url, err := b.constructLayerUrl(digest)
 	if err != nil {
 		log.WithError(err).WithFields(log.Fields{