Skip to content

Commit d12570b

Browse files
committed
fix parse dynconfig
1 parent 1001f1b commit d12570b

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

api/v1alpha1/configuration.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,6 @@ func tryFillMissingSections(
9090
}
9191

9292
func buildConfiguration(cr *Storage, crDB *Database) (string, error) {
93-
config := make(map[string]interface{})
94-
9593
// If any kind of configuration exists on Database object, then
9694
// it will be used to fully override storage object.
9795
// This is a temporary solution that should go away when it would
@@ -105,12 +103,14 @@ func buildConfiguration(cr *Storage, crDB *Database) (string, error) {
105103

106104
dynconfig, err := TryParseDynconfig(rawYamlConfiguration)
107105
if err == nil {
108-
config = dynconfig.Config
109-
} else {
110-
err := yaml.Unmarshal([]byte(rawYamlConfiguration), &config)
111-
if err != nil {
112-
return "", err
113-
}
106+
config, err := yaml.Marshal(dynconfig.Config)
107+
return string(config), err
108+
}
109+
110+
config := make(map[string]interface{})
111+
err = yaml.Unmarshal([]byte(rawYamlConfiguration), &config)
112+
if err != nil {
113+
return "", err
114114
}
115115

116116
generatedConfig := generateSomeDefaults(cr, crDB)
@@ -125,10 +125,10 @@ func buildConfiguration(cr *Storage, crDB *Database) (string, error) {
125125
}
126126

127127
func TryParseDynconfig(rawYamlConfiguration string) (schema.Dynconfig, error) {
128-
dynConfig := schema.Dynconfig{}
129-
err := yaml.Unmarshal([]byte(rawYamlConfiguration), &dynConfig)
128+
dynconfig := schema.Dynconfig{}
129+
err := yaml.Unmarshal([]byte(rawYamlConfiguration), &dynconfig)
130130
if err != nil {
131131
return schema.Dynconfig{}, err
132132
}
133-
return dynConfig, nil
133+
return dynconfig, nil
134134
}

0 commit comments

Comments
 (0)