@@ -63,13 +63,12 @@ func ReadConfigs(cfgPath string) ([]byte, error) {
63
63
return nil , err
64
64
}
65
65
66
- iSay ("Config files: `%+v`" , fileList )
67
-
68
66
// check defaults config existence. Fall down if not
69
67
if _ , ok := fileList ["defaults" ]; ! ok || len (fileList ["defaults" ]) == 0 {
70
68
log .Fatal ("[config] defaults config is not found! Fall down." )
71
69
}
72
70
71
+ fileListResult := make (map [string ][]string )
73
72
configs := make (map [string ]map [string ]interface {})
74
73
for folder , files := range fileList {
75
74
for _ , file := range files {
@@ -81,6 +80,11 @@ func ReadConfigs(cfgPath string) ([]byte, error) {
81
80
log .Fatalf ("[config] %s %s config read fal! Fall down." , folder , file )
82
81
}
83
82
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
+
84
88
if _ , ok := configs [folder ]; ! ok {
85
89
configs [folder ] = configFromFile [folder ]
86
90
continue
@@ -91,9 +95,13 @@ func ReadConfigs(cfgPath string) ([]byte, error) {
91
95
log .Fatalf ("[config] merging files in folder error: %s" , err )
92
96
}
93
97
configs [folder ] = cc
98
+
99
+ fileListResult [folder ] = append (fileListResult [folder ], file )
94
100
}
95
101
}
96
102
103
+ iSay ("Config files: `%+v`" , fileListResult )
104
+
97
105
config := configs ["defaults" ]
98
106
c , ok := configs [stage ]
99
107
if ok {
@@ -104,8 +112,6 @@ func ReadConfigs(cfgPath string) ([]byte, error) {
104
112
iSay ("Stage `%s` config is loaded and merged with `defaults`" , stage )
105
113
}
106
114
107
- iSay ("merged config content: `%+v`" , config )
108
-
109
115
return yaml .Marshal (config )
110
116
}
111
117
0 commit comments