node-api/common/config.go
Adam Štrauch bc7969bcce
Add a few configuration fields
Configurable path for application storage,
SSH IP and HTTP IP
2021-01-30 12:33:57 +01:00

27 lines
722 B
Go

package common
import (
"log"
"github.com/kelseyhightower/envconfig"
)
// Config keeps info about configuration of this daemon
type Config struct {
AppsPath string `envconfig:"APPS_PATH" default:"/srv"` // Where applications are located
AppsBindIPHTTP string `envconfig:"APPS_BIND_IP_HTTP" default:"0.0.0.0"` // On what IP apps' HTTP port gonna be bound
AppsBindIPSSH string `envconfig:"APPS_BIND_IP_SSH" default:"0.0.0.0"` // On what IP apps' SSH ports gonna be bound
}
// GetConfig return configuration created based on environment variables
func GetConfig() *Config {
var config Config
err := envconfig.Process("", &config)
if err != nil {
log.Fatal(err.Error())
}
return &config
}