about summary refs log tree commit diff
path: root/tools/nixery/server/main.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/main.go
parent20e0ca53cba796a67311360d7a21c0f7c8baf78a (diff)
refactor(server): Change setup to create new storage backends
Diffstat (limited to 'tools/nixery/server/main.go')
-rw-r--r--tools/nixery/server/main.go20
1 files changed, 17 insertions, 3 deletions
diff --git a/tools/nixery/server/main.go b/tools/nixery/server/main.go
index 22ed6f1a5e2c..b5d7091ed002 100644
--- a/tools/nixery/server/main.go
+++ b/tools/nixery/server/main.go
@@ -36,6 +36,7 @@ import (
 	"github.com/google/nixery/server/builder"
 	"github.com/google/nixery/server/config"
 	"github.com/google/nixery/server/layers"
+	"github.com/google/nixery/server/storage"
 	log "github.com/sirupsen/logrus"
 )
 
@@ -196,6 +197,18 @@ func main() {
 		log.WithError(err).Fatal("failed to load configuration")
 	}
 
+	var s storage.Backend
+
+	switch cfg.Backend {
+	case config.GCS:
+		s, err = storage.NewGCSBackend()
+	}
+	if err != nil {
+		log.WithError(err).Fatal("failed to initialise storage backend")
+	}
+
+	log.WithField("backend", s.Name()).Info("initialised storage backend")
+
 	ctx := context.Background()
 	cache, err := builder.NewCache()
 	if err != nil {
@@ -212,9 +225,10 @@ func main() {
 	}
 
 	state := builder.State{
-		Cache: &cache,
-		Cfg:   cfg,
-		Pop:   pop,
+		Cache:   &cache,
+		Cfg:     cfg,
+		Pop:     pop,
+		Storage: s,
 	}
 
 	log.WithFields(log.Fields{