From e55b0dca13e32904a6cedc061188ad99e945744a Mon Sep 17 00:00:00 2001 From: Jay Gabriels Date: Tue, 1 Mar 2022 09:13:03 -0800 Subject: [PATCH] Fix ghorg config env (#188) --- CHANGELOG.md | 9 ++++++++- cmd/clone.go | 2 +- cmd/root.go | 12 ++++++------ cmd/version.go | 2 +- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b64da0..21483e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) - +## [1.7.10] - unreleased +### Added +### Changed +### Deprecated +### Removed +### Fixed +Configuration env var; thanks @Rabattkarte +### Security ## [1.7.9] - 2/27/22 ### Added diff --git a/cmd/clone.go b/cmd/clone.go index 20962d7..35668f5 100644 --- a/cmd/clone.go +++ b/cmd/clone.go @@ -709,7 +709,7 @@ func PrintConfigs() { colorlog.PrintInfo("* Dry Run : " + "true") } - colorlog.PrintInfo("* Config Used : " + os.Getenv("GHORG_CONF")) + colorlog.PrintInfo("* Config Used : " + os.Getenv("GHORG_CONFIG")) colorlog.PrintInfo("*************************************") fmt.Println("") diff --git a/cmd/root.go b/cmd/root.go index 668d252..b3211be 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -128,21 +128,21 @@ func getOrSetDefaults(envVar string) { func InitConfig() { if config != "" { viper.SetConfigFile(config) - os.Setenv("GHORG_CONF", config) + os.Setenv("GHORG_CONFIG", config) } else { config = configs.DefaultConfFile() viper.SetConfigType("yaml") viper.AddConfigPath(configs.GhorgDir()) viper.SetConfigName("conf") - os.Setenv("GHORG_CONF", configs.DefaultConfFile()) + os.Setenv("GHORG_CONFIG", configs.DefaultConfFile()) } if err := viper.ReadInConfig(); err != nil { if _, ok := err.(viper.ConfigFileNotFoundError); ok { - os.Setenv("GHORG_CONF", "none") + os.Setenv("GHORG_CONFIG", "none") } else { - colorlog.PrintError(fmt.Sprintf("Something unexpected happened reading configuration file: %s, err: %s", os.Getenv("GHORG_CONF"), err)) + colorlog.PrintError(fmt.Sprintf("Something unexpected happened reading configuration file: %s, err: %s", os.Getenv("GHORG_CONFIG"), err)) os.Exit(1) } } @@ -184,7 +184,7 @@ func InitConfig() { if os.Getenv("GHORG_DEBUG") != "" { viper.Debug() fmt.Println("Viper config file used:", viper.ConfigFileUsed()) - fmt.Printf("GHORG_CONF SET TO: %s\n", os.Getenv("GHORG_CONF")) + fmt.Printf("GHORG_CONFIG SET TO: %s\n", os.Getenv("GHORG_CONFIG")) } } @@ -193,7 +193,7 @@ func init() { cobra.OnInitialize(InitConfig) rootCmd.PersistentFlags().StringVar(&color, "color", "", "GHORG_COLOR - toggles colorful output, enabled/disabled (default: disabled)") - rootCmd.PersistentFlags().StringVar(&config, "config", "", "manually set the path to your config file") + rootCmd.PersistentFlags().StringVar(&config, "config", "", "GHORG_CONFIG - manually set the path to your config file") viper.SetDefault("config", configs.DefaultConfFile()) diff --git a/cmd/version.go b/cmd/version.go index eda1edb..af4638b 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -11,6 +11,6 @@ var versionCmd = &cobra.Command{ Short: "Print the version number of Ghorg", Long: `All software has versions. This is Ghorg's`, Run: func(cmd *cobra.Command, args []string) { - fmt.Println("v1.7.9") + fmt.Println("v1.7.10") }, }