From a9eb57759cb15d165892c9c637752dd219fa36aa Mon Sep 17 00:00:00 2001 From: wchao1241 Date: Wed, 2 May 2018 14:21:57 +0800 Subject: [PATCH] Add export filter of additional property --- config/config.go | 9 +++++++++ config/types.go | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/config/config.go b/config/config.go index 2dee2b73..9aa4021d 100644 --- a/config/config.go +++ b/config/config.go @@ -35,6 +35,7 @@ func Merge(bytes []byte) error { func Export(private, full bool) (string, error) { rawCfg := loadRawConfig("", full) + rawCfg = filterAdditional(rawCfg) if !private { rawCfg = filterPrivateKeys(rawCfg) } @@ -50,6 +51,14 @@ func filterPrivateKeys(data map[interface{}]interface{}) map[interface{}]interfa return data } +func filterAdditional(data map[interface{}]interface{}) map[interface{}]interface{} { + for _, additional := range Additional { + _, data = filterKey(data, strings.Split(additional, ".")) + } + + return data +} + func Get(key string) (interface{}, error) { cfg := LoadConfig() diff --git a/config/types.go b/config/types.go index 64c7bb95..3d144264 100644 --- a/config/types.go +++ b/config/types.go @@ -67,6 +67,11 @@ var ( "rancher.docker.server_key", "rancher.docker.server_cert", } + Additional = []string{ + "rancher.password", + "rancher.autologin", + "EXTRA_CMDLINE", + } ) func init() {