28 lines
521 B
Go
28 lines
521 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("isouser").(string),
|
||
|
ISOPassword: viper.Get("isopassword").(string),
|
||
|
}
|
||
|
}
|
||
|
|