From 39c6654dd8b897e5305baaa9f3bb1be938cff855 Mon Sep 17 00:00:00 2001 From: Liang Mingqiang Date: Tue, 31 Jul 2018 16:28:42 -0400 Subject: [PATCH] read a section of config (#255) --- root.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/root.go b/root.go index 7e35add..a7643a8 100644 --- a/root.go +++ b/root.go @@ -67,6 +67,11 @@ func Execute() { func init() { cobra.OnInitialize(initConfig) + // read default node name from environment variable. + // it can be overwritten by cli flags if specified. + if os.Getenv("DEFAULT_NODE_NAME") != "" { + nodeName = os.Getenv("DEFAULT_NODE_NAME") + } // Here you will define your flags and configuration settings. // Cobra supports persistent flags, which, if defined here, // will be global for your application.