File tree Expand file tree Collapse file tree
internal/pkg/configmanager Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package configmanager
22
33import (
4+ "bytes"
45 "errors"
56 "fmt"
67 "io"
@@ -32,6 +33,9 @@ func (m *Manager) LoadConfig() (*Config, error) {
3233 if err != nil {
3334 return nil , err
3435 }
36+ // replace all "---"
37+ // otherwise yaml.Unmarshal can only read the content before the first "---"
38+ configBytesOrigin = bytes .Replace (configBytesOrigin , []byte ("---" ), []byte ("\n " ), - 1 )
3539
3640 // 2. get all globals vars
3741 globalVars , err := getVarsFromConfigBytes (configBytesOrigin )
@@ -40,7 +44,7 @@ func (m *Manager) LoadConfig() (*Config, error) {
4044 }
4145
4246 // 3. yaml unmarshal to get the whole config
43- var config ConfigRaw
47+ config := ConfigRaw {}
4448 err = yaml .Unmarshal (configBytesOrigin , & config )
4549 if err != nil {
4650 log .Errorf ("Please verify the format of your config. Error: %s." , err )
@@ -186,7 +190,7 @@ func (m *Manager) getWholeConfigBytes() ([]byte, error) {
186190 }
187191
188192 configBytesStr := string (configBytes )
189- log .Debugf ("The final whole config is: \n %s\n " , configBytesStr )
193+ log .Debugf ("The whole config without rendered is: \n %s\n " , configBytesStr )
190194
191195 return configBytes , nil
192196}
You can’t perform that action at this time.
0 commit comments