@@ -29,6 +29,7 @@ import (
29
29
"time"
30
30
31
31
"github.com/google/renameio"
32
+ "github.com/haproxytech/client-native/v4/misc"
32
33
"github.com/haproxytech/client-native/v4/models"
33
34
"github.com/haproxytech/dataplaneapi/log"
34
35
)
@@ -105,7 +106,9 @@ func NewReloadAgent(params ReloadAgentParams) (*ReloadAgent, error) {
105
106
}
106
107
ra .delay = params .Delay
107
108
108
- ra .setLkgPath (params .ConfigFile , params .BackupDir )
109
+ if err := ra .setLkgPath (params .ConfigFile , params .BackupDir ); err != nil {
110
+ return nil , err
111
+ }
109
112
110
113
// create last known good file, assume it is valid when starting
111
114
if err := copyFile (ra .configFile , ra .lkgConfigFile ); err != nil {
@@ -117,12 +120,18 @@ func NewReloadAgent(params ReloadAgentParams) (*ReloadAgent, error) {
117
120
return ra , nil
118
121
}
119
122
120
- func (ra * ReloadAgent ) setLkgPath (configFile , path string ) {
123
+ func (ra * ReloadAgent ) setLkgPath (configFile , path string ) error {
121
124
if path != "" {
125
+ var err error
126
+ path , err = misc .CheckOrCreateWritableDirectory (path )
127
+ if err != nil {
128
+ return err
129
+ }
122
130
ra .lkgConfigFile = fmt .Sprintf ("%s/%s.lkg" , path , filepath .Base (configFile ))
123
- return
131
+ return nil
124
132
}
125
133
ra .lkgConfigFile = configFile + ".lkg"
134
+ return nil
126
135
}
127
136
128
137
func (ra * ReloadAgent ) handleReload (id string ) (string , error ) {
0 commit comments