Loading go-apps/meepctl/cmd/root.go +4 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,10 @@ func Execute() { fmt.Println(err) os.Exit(1) } _ = utils.ConfigValidateVersion("") // if !configValid { // os.Exit(1) // } if err := rootCmd.Execute(); err != nil { fmt.Println(err) os.Exit(1) Loading go-apps/meepctl/utils/config.go +23 −1 Original line number Diff line number Diff line Loading @@ -26,8 +26,10 @@ import ( var RepoCfg *viper.Viper // Config version needs to be bumped only when new elements are added const configVersion string = "1.1.0" var defaultConfig = ` version: 1.0.0 version: 1.1.0 node: ip: "" Loading Loading @@ -132,6 +134,26 @@ func ConfigReadFile(filePath string) (cfg *Config) { return cfg } // ConfigValidateVersion validates config file func ConfigValidateVersion(filePath string) (valid bool) { if filePath == "" { filePath = ConfigGetDefaultPath() } cfg := ConfigReadFile(filePath) // Validate version if cfg.Version != configVersion { fmt.Println("") fmt.Println(" WARNING meepctl version[" + configVersion + "] != config file version[" + cfg.Version + "]") fmt.Println(" config file location: " + filePath) fmt.Println(" To fix, erase the config file and run meepctl tool again; it will generate a new one.") fmt.Println(" NOTE: The new config file will have the default configuration which you will have to update again.") fmt.Println("") return false } return true } // ConfigValidate validates config file func ConfigValidate(filePath string) (valid bool) { if filePath == "" { Loading Loading
go-apps/meepctl/cmd/root.go +4 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,10 @@ func Execute() { fmt.Println(err) os.Exit(1) } _ = utils.ConfigValidateVersion("") // if !configValid { // os.Exit(1) // } if err := rootCmd.Execute(); err != nil { fmt.Println(err) os.Exit(1) Loading
go-apps/meepctl/utils/config.go +23 −1 Original line number Diff line number Diff line Loading @@ -26,8 +26,10 @@ import ( var RepoCfg *viper.Viper // Config version needs to be bumped only when new elements are added const configVersion string = "1.1.0" var defaultConfig = ` version: 1.0.0 version: 1.1.0 node: ip: "" Loading Loading @@ -132,6 +134,26 @@ func ConfigReadFile(filePath string) (cfg *Config) { return cfg } // ConfigValidateVersion validates config file func ConfigValidateVersion(filePath string) (valid bool) { if filePath == "" { filePath = ConfigGetDefaultPath() } cfg := ConfigReadFile(filePath) // Validate version if cfg.Version != configVersion { fmt.Println("") fmt.Println(" WARNING meepctl version[" + configVersion + "] != config file version[" + cfg.Version + "]") fmt.Println(" config file location: " + filePath) fmt.Println(" To fix, erase the config file and run meepctl tool again; it will generate a new one.") fmt.Println(" NOTE: The new config file will have the default configuration which you will have to update again.") fmt.Println("") return false } return true } // ConfigValidate validates config file func ConfigValidate(filePath string) (valid bool) { if filePath == "" { Loading