Skip to content
This repository was archived by the owner on May 19, 2020. It is now read-only.

Commit e793091

Browse files
Merge pull request #3 from microparts/refactor_config_merge_result_echo
Hide merged config result for security reasons
2 parents 7a16554 + f5a4263 commit e793091

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

reader.go

+10-4
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,12 @@ func ReadConfigs(cfgPath string) ([]byte, error) {
6363
return nil, err
6464
}
6565

66-
iSay("Config files: `%+v`", fileList)
67-
6866
// check defaults config existence. Fall down if not
6967
if _, ok := fileList["defaults"]; !ok || len(fileList["defaults"]) == 0 {
7068
log.Fatal("[config] defaults config is not found! Fall down.")
7169
}
7270

71+
fileListResult := make(map[string][]string)
7372
configs := make(map[string]map[string]interface{})
7473
for folder, files := range fileList {
7574
for _, file := range files {
@@ -81,6 +80,11 @@ func ReadConfigs(cfgPath string) ([]byte, error) {
8180
log.Fatalf("[config] %s %s config read fal! Fall down.", folder, file)
8281
}
8382

83+
if _, ok := configFromFile[folder]; !ok {
84+
iSay("File %s excluded from %s (it is not for this stage)!", file, folder)
85+
continue
86+
}
87+
8488
if _, ok := configs[folder]; !ok {
8589
configs[folder] = configFromFile[folder]
8690
continue
@@ -91,9 +95,13 @@ func ReadConfigs(cfgPath string) ([]byte, error) {
9195
log.Fatalf("[config] merging files in folder error: %s", err)
9296
}
9397
configs[folder] = cc
98+
99+
fileListResult[folder] = append(fileListResult[folder], file)
94100
}
95101
}
96102

103+
iSay("Config files: `%+v`", fileListResult)
104+
97105
config := configs["defaults"]
98106
c, ok := configs[stage]
99107
if ok {
@@ -104,8 +112,6 @@ func ReadConfigs(cfgPath string) ([]byte, error) {
104112
iSay("Stage `%s` config is loaded and merged with `defaults`", stage)
105113
}
106114

107-
iSay("merged config content: `%+v`", config)
108-
109115
return yaml.Marshal(config)
110116
}
111117

0 commit comments

Comments
 (0)