Skip to content

Commit 9bc95ee

Browse files
vgramermjuraga
authored andcommitted
BUG/MINOR: fix panic when trying to start with hcl configuration file
hcl format is not supported anymore. Only yaml format is supported. The problem was that storage was not initialized if the file format was not yaml. I kept the same behavior. If the file extension is not 'yaml' or 'yml', we still try to parse the configuration as a yaml file. Signed-off-by: Vincent Gramer <vgramer@haproxy.com>
1 parent 086fa7c commit 9bc95ee

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

configuration/configuration.go

+2-12
Original file line numberDiff line numberDiff line change
@@ -207,22 +207,12 @@ func (c *Configuration) Load() error {
207207
c.storage = &StorageDummy{}
208208
_ = c.storage.Load("")
209209
} else {
210-
ext := strings.ToLower(filepath.Ext(c.HAProxy.DataplaneConfig))
211-
212-
switch ext {
213-
case ".yml", ".yaml":
214-
c.storage = &StorageYML{}
215-
default:
216-
if err = (&StorageYML{}).Load(c.HAProxy.DataplaneConfig); err == nil {
217-
c.storage = &StorageYML{}
218-
break
219-
}
220-
}
210+
c.storage = &StorageYML{}
221211
if err = c.storage.Load(c.HAProxy.DataplaneConfig); err != nil {
222212
if errors.Is(err, fs.ErrNotExist) {
223213
log.Warningf("configuration file %s does not exists, creating one", c.HAProxy.DataplaneConfig)
224214
} else {
225-
return fmt.Errorf("configuration file %s not valid: %w", c.HAProxy.DataplaneConfig, err)
215+
return fmt.Errorf("configuration file %s not valid (only yaml format is supported): %w", c.HAProxy.DataplaneConfig, err)
226216
}
227217
}
228218
}

0 commit comments

Comments
 (0)