@@ -17,14 +17,11 @@ package handlers
17
17
18
18
import (
19
19
"fmt"
20
- "path"
21
20
22
21
"github.com/go-openapi/runtime/middleware"
23
22
"github.com/google/renameio"
24
23
client_native "github.com/haproxytech/client-native/v2"
25
- "github.com/haproxytech/client-native/v2/misc"
26
24
"github.com/haproxytech/client-native/v2/models"
27
- "github.com/haproxytech/client-native/v2/storage"
28
25
29
26
"github.com/haproxytech/dataplaneapi/configuration"
30
27
"github.com/haproxytech/dataplaneapi/haproxy"
@@ -104,28 +101,11 @@ func (h *CreateClusterHandlerImpl) Handle(params cluster.PostClusterParams, prin
104
101
if err != nil {
105
102
return h .err406 (err , nil )
106
103
}
107
- storageDir := key ["storage-dir" ]
108
- if storageDir != "" {
109
- _ , errStorage := misc .CheckOrCreateWritableDirectory (storageDir )
110
- if errStorage != nil {
111
- return h .err409 (errStorage , nil )
112
- }
113
- dirs := []storage.FileType {
114
- storage .BackupsType , storage .MapsType , storage .SSLType ,
115
- storage .SpoeTransactionsType , storage .SpoeType ,
116
- storage .TransactionsType ,
117
- storage .FileType ("certs-cluster" ),
118
- }
119
- for _ , dir := range dirs {
120
- _ , errStorage := misc .CheckOrCreateWritableDirectory (path .Join (storageDir , string (dir )))
121
- if errStorage != nil {
122
- return h .err409 (errStorage , nil )
123
- }
124
- }
125
- h .Config .Cluster .StorageDir .Store (storageDir )
126
- h .Config .HAProxy .ClusterTLSCertDir = path .Join (storageDir , "certs-cluster" )
127
- h .Config .Cluster .CertificateDir .Store (path .Join (storageDir , "certs-cluster" ))
104
+ errStorageDir := configuration .CheckIfStorageDirIsOK (key ["storage-dir" ], h .Config )
105
+ if errStorageDir != nil {
106
+ return h .err409 (errStorageDir , nil )
128
107
}
108
+
129
109
// enforcing API advertising options
130
110
if a := params .AdvertisedAddress ; a != nil {
131
111
h .Config .APIOptions .APIAddress = * a
0 commit comments