diff options
author | Vincent Ambo <tazjin@google.com> | 2019-10-28T17·19+0100 |
---|---|---|
committer | Vincent Ambo <github@tazj.in> | 2019-10-28T21·31+0100 |
commit | 790bce219cf9acf01de3257fcf137a0a2833529e (patch) | |
tree | a26922af66344e3d08d42b87e50371e1f888bdc4 /tools/nixery/server/storage/filesystem.go | |
parent | 167a0b32630ed86b3a053e56fa499957872d7b38 (diff) |
feat(server): Add filesystem storage backend config options
The filesystem storage backend can be enabled by setting `NIXERY_STORAGE_BACKEND` to `filesystem` and `STORAGE_PATH` to a disk location from which Nixery can serve files.
Diffstat (limited to 'tools/nixery/server/storage/filesystem.go')
-rw-r--r-- | tools/nixery/server/storage/filesystem.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/tools/nixery/server/storage/filesystem.go b/tools/nixery/server/storage/filesystem.go index ef763da67f14..f343d67b65f8 100644 --- a/tools/nixery/server/storage/filesystem.go +++ b/tools/nixery/server/storage/filesystem.go @@ -15,7 +15,12 @@ type FSBackend struct { path string } -func NewFSBackend(p string) (*FSBackend, error) { +func NewFSBackend() (*FSBackend, error) { + p := os.Getenv("STORAGE_PATH") + if p == "" { + return nil, fmt.Errorf("STORAGE_PATH must be set for filesystem storage") + } + p = path.Clean(p) err := os.MkdirAll(p, 0755) if err != nil { |