Skip to content

Commit

Permalink
Add redis address and blocksize conf with env var
Browse files Browse the repository at this point in the history
  • Loading branch information
JCapul committed Mar 22, 2019
1 parent 55eb7aa commit 31292e9
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/go/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ package config

import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
"strconv"
"strings"
)

//Mount point configuration
Expand Down Expand Up @@ -74,6 +77,10 @@ func New() *Pdwfs {
RedisConf: &defaultRedis,
}

if addrs := os.Getenv("PDWFS_REDIS"); addrs != "" {
conf.RedisConf.RedisAddrs = strings.Split(addrs, ",")
}

if path := os.Getenv("PDWFS_MOUNTPATH"); path != "" {
mount := Mount{
Path: path,
Expand All @@ -84,6 +91,17 @@ func New() *Pdwfs {
conf.Mounts[path] = &mount
}

if blockSize := os.Getenv("PDWFS_BLOCKSIZE"); blockSize != "" {
for _, mount := range conf.Mounts {
size, err := strconv.Atoi(blockSize)
if err != nil {
log.Fatalln("Can't convert BlockSize in PDWFS_BLOCKSIZE to int")
}
mount.BlockSize = size * 1024 * 1024
fmt.Println("BlockSize: ", mount.BlockSize)
}
}

if confFile := os.Getenv("PDWFS_CONF"); confFile != "" {
jsonFile, err := os.Open(confFile)
if err != nil {
Expand Down

0 comments on commit 31292e9

Please sign in to comment.