Skip to content

Commit ed3f39b

Browse files
committed
BUG/MAJOR: create a configuration file if file does not exists
1 parent 58608bf commit ed3f39b

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

configuration/configuration.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
petname "github.com/dustinkirkland/golang-petname"
2929
"github.com/haproxytech/client-native/v2/models"
3030
apache_log "github.com/lestrrat-go/apache-logformat"
31+
log "github.com/sirupsen/logrus"
3132
)
3233

3334
var (
@@ -230,7 +231,7 @@ func (c *Configuration) Load() error {
230231
c.storage = &StorageHCL{}
231232
}
232233
if err = c.storage.Load(c.HAProxy.DataplaneConfig); err != nil {
233-
return err
234+
log.Warnf("configuration file %s does not exists, creating one", c.HAProxy.DataplaneConfig)
234235
}
235236
}
236237
copyToConfiguration(c)

configuration/file-storage-hcl.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ func (s *StorageHCL) Load(filename string) error {
4646
}
4747

4848
func (s *StorageHCL) Get() *StorageDataplaneAPIConfiguration {
49+
if s.cfg == nil {
50+
s.cfg = &StorageDataplaneAPIConfiguration{}
51+
}
4952
return s.cfg
5053
}
5154

configuration/file-storage-yml.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ func (s *StorageYML) Load(filename string) error {
4646
}
4747

4848
func (s *StorageYML) Get() *StorageDataplaneAPIConfiguration {
49+
if s.cfg == nil {
50+
s.cfg = &StorageDataplaneAPIConfiguration{}
51+
}
4952
return s.cfg
5053
}
5154

0 commit comments

Comments
 (0)