energyd/internal/config/config.go
2022-07-02 13:19:33 -04:00

27 lines
523 B
Go

package config
import (
"fmt"
"github.com/spf13/viper"
)
type Conf struct {
ISOUser string
ISOPassword string
}
func Config() *Conf {
viper.SetConfigName("energyd")
viper.SetConfigType("yaml")
viper.AddConfigPath(".")
err := viper.ReadInConfig() // Find and read the config file
if err != nil { // Handle errors reading the config file
panic(fmt.Errorf("fatal error config file: %w", err))
}
return &Conf{
ISOUser: viper.Get("iso.user").(string),
ISOPassword: viper.Get("iso.password").(string),
}
}