Improve documentation
[nonrtric/rapp/ransliceassurance.git] / smoversion / internal / config / config.go
index f1eb26f..993365e 100644 (file)
@@ -36,6 +36,7 @@ type Config struct {
        SDNPassword string
        Polltime    int
        LogLevel    log.Level
+       NodeId      string
 }
 
 func New() *Config {
@@ -47,11 +48,12 @@ func New() *Config {
                SDNPassword: getEnv("SDNR_PASSWORD", "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U"),
                Polltime:    getEnvAsInt("Polltime", 30),
                LogLevel:    getLogLevel(),
+               NodeId:      getEnv("NODE_ID", ""),
        }
 }
 
 func (c Config) String() string {
-       return fmt.Sprintf("[MRHost: %v, MRPort: %v, SDNRAddress: %v, SDNRUser: %v, SDNRPassword: %v, PollTime: %v, LogLevel: %v]", c.MRHost, c.MRPort, c.SDNRAddress, c.SDNRUser, c.SDNPassword, c.Polltime, c.LogLevel)
+       return fmt.Sprintf("[MRHost: %v, MRPort: %v, SDNRAddress: %v, SDNRUser: %v, SDNRPassword: %v, PollTime: %v, LogLevel: %v, NodeId: %v]", c.MRHost, c.MRPort, c.SDNRAddress, c.SDNRUser, c.SDNPassword, c.Polltime, c.LogLevel, c.NodeId)
 }
 
 func getEnv(key string, defaultVal string) string {
@@ -75,8 +77,8 @@ func getEnvAsInt(name string, defaultVal int) int {
 
 func getLogLevel() log.Level {
        logLevelStr := getEnv("LOG_LEVEL", "Info")
-       if loglevel, err := log.ParseLevel(logLevelStr); err == nil {
-               return loglevel
+       if logLevel, err := log.ParseLevel(logLevelStr); err == nil {
+               return logLevel
        } else {
                log.Warnf("Invalid log level: %v. Log level will be Info!", logLevelStr)
                return log.InfoLevel