2022-06-25 22:13:35 -04:00
|
|
|
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{
|
2022-07-02 13:19:33 -04:00
|
|
|
ISOUser: viper.Get("iso.user").(string),
|
|
|
|
ISOPassword: viper.Get("iso.password").(string),
|
2022-06-25 22:13:35 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|