add ability to log to file, update to v2.28.1 and fix 'first upgrade' issue
This commit is contained in:
@@ -13,7 +13,8 @@ var (
|
||||
ConfigFile string
|
||||
Output string
|
||||
Password string
|
||||
Verbose bool
|
||||
Verbose int
|
||||
LogFile string
|
||||
)
|
||||
|
||||
type Host struct {
|
||||
@@ -27,7 +28,8 @@ type Host struct {
|
||||
type Config struct {
|
||||
BaseDir string
|
||||
InventoryDir string
|
||||
Verbose bool
|
||||
Verbose int
|
||||
LogFile string
|
||||
KubeconfigFile string
|
||||
Forks string `yaml:"forks" env-default:"10"`
|
||||
InstallationName string `yaml:"installation_name" env-default:"cluster.local"`
|
||||
@@ -52,7 +54,7 @@ type Config struct {
|
||||
|
||||
var instance *Config
|
||||
|
||||
func createConfig(configFile string, out string, password string, verbose bool) *Config {
|
||||
func createConfig(configFile string, out string, password string, verbose int, logFile string) *Config {
|
||||
instance = &Config{}
|
||||
|
||||
if err := cleanenv.ReadConfig(configFile, instance); err != nil {
|
||||
@@ -77,17 +79,21 @@ func createConfig(configFile string, out string, password string, verbose bool)
|
||||
}
|
||||
|
||||
instance.Verbose = verbose
|
||||
instance.LogFile = logFile
|
||||
|
||||
err := validateConfig(*instance)
|
||||
if err != nil {
|
||||
logging.Log.Fatal(err.Error())
|
||||
}
|
||||
|
||||
logging.SetupLogging(instance.Verbose, instance.LogFile)
|
||||
|
||||
return instance
|
||||
}
|
||||
|
||||
func GetConfig() *Config {
|
||||
if instance == nil {
|
||||
createConfig(ConfigFile, Output, Password, Verbose)
|
||||
createConfig(ConfigFile, Output, Password, Verbose, LogFile)
|
||||
}
|
||||
return instance
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user