package defaults
import (
"log"
"os"
"path"
)
var (
BaseDataPathType = "homedir"
BaseDataPathValue = "/var/lib/opencloud"
)
func BaseDataPath() string {
p := os.Getenv("OC_BASE_DATA_PATH")
if p != "" {
return p
}
switch BaseDataPathType {
case "homedir":
dir, err := os.UserHomeDir()
if err != nil {
return BaseDataPathValue
}
return path.Join(dir, ".opencloud")
case "path":
return BaseDataPathValue
default:
log.Fatalf("BaseDataPathType %s not found", BaseDataPathType)
return ""
}
}
var (
BaseConfigPathType = "homedir"
BaseConfigPathValue = "/etc/opencloud"
)
func BaseConfigPath() string {
p := os.Getenv("OC_CONFIG_DIR")
if p != "" {
return p
}
switch BaseConfigPathType {
case "homedir":
dir, err := os.UserHomeDir()
if err != nil {
return BaseConfigPathValue
}
return path.Join(dir, ".opencloud", "config")
case "path":
return BaseConfigPathValue
default:
log.Fatalf("BaseConfigPathType %s not found", BaseConfigPathType)
return ""
}
}