@@ -11,6 +11,7 @@ import (
11
11
"syscall"
12
12
13
13
"github.com/pkg/errors"
14
+ "github.com/sirupsen/logrus"
14
15
15
16
"github.com/longhorn/longhorn-share-manager/pkg/util"
16
17
)
@@ -67,12 +68,12 @@ func (e *Exporter) GetExportMap() ExportMap {
67
68
defer e .mapMutex .RUnlock ()
68
69
69
70
volToID := map [string ]uint16 {}
70
- for vol , id := range e .ExportMap . volumeToid {
71
+ for vol , id := range e .volumeToid {
71
72
volToID [vol ] = id
72
73
}
73
74
74
75
idToVol := map [uint16 ]string {}
75
- for id , vol := range e .ExportMap . idToVolume {
76
+ for id , vol := range e .idToVolume {
76
77
idToVol [id ] = vol
77
78
}
78
79
@@ -223,7 +224,11 @@ func (e *Exporter) addToConfig(block string) error {
223
224
if err != nil {
224
225
return err
225
226
}
226
- defer config .Close ()
227
+ defer func () {
228
+ if errClose := config .Close (); errClose != nil {
229
+ logrus .WithError (errClose ).Error ("Failed to close config file" )
230
+ }
231
+ }()
227
232
228
233
if _ , err = config .WriteString (block ); err != nil {
229
234
return err
@@ -243,7 +248,7 @@ func (e *Exporter) removeFromConfig(block string) error {
243
248
return err
244
249
}
245
250
246
- newConfig := strings .Replace (string (config ), block , "" , - 1 )
251
+ newConfig := strings .ReplaceAll (string (config ), block , "" )
247
252
err = os .WriteFile (e .configPath , []byte (newConfig ), 0 )
248
253
if err != nil {
249
254
return err
0 commit comments