Skip to content

Commit

Permalink
move GetENV to utils, and make it generic
Browse files Browse the repository at this point in the history
Signed-off-by: feihuang <feihuang@feihuangs-mbp.cn.ibm.com>
  • Loading branch information
feihuang committed Feb 28, 2018
1 parent 968b395 commit fe2a3be
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
13 changes: 2 additions & 11 deletions database/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ package database

import (
"github.com/IBM/ubiquity/utils/logs"
"github.com/IBM/ubiquity/utils"
"strings"
"os"
)

const DBVolumeNameSuffix = "ibm-ubiquity-db"
var VolumeNameSuffix = getDBVolumeName(keyPsqlDbPVName)

var VolumeNameSuffix = utils.GetEnv(keyPsqlDbPVName, DBVolumeNameSuffix)

func IsDatabaseVolume(volName string) bool {
defer logs.GetLogger().Trace(logs.DEBUG)()
Expand All @@ -33,11 +32,3 @@ func IsDatabaseVolume(volName string) bool {
return isDatabaseVolume
}

func getDBVolumeName(dbPVNameENVKey string) string {
volumeNameSuffix := os.Getenv(dbPVNameENVKey)
if volumeNameSuffix == "" {
volumeNameSuffix = DBVolumeNameSuffix
}
return volumeNameSuffix
}

8 changes: 8 additions & 0 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,3 +274,11 @@ func LoadConfig() (resources.UbiquityServerConfig, error) {

return config, nil
}

func GetEnv(envName string, defaultValue string) string {
envValue := os.Getenv(envName)
if envValue == "" {
envValue = defaultValue
}
return envValue
}

0 comments on commit fe2a3be

Please sign in to comment.