Skip to content

Commit f6f2196

Browse files
derekbitmergify[bot]
authored andcommitted
fix: fix validation errors
Signed-off-by: Derek Su <[email protected]>
1 parent ec0321a commit f6f2196

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

pkg/server/nfs/export.go

+9-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"syscall"
1212

1313
"github.com/pkg/errors"
14+
"github.com/sirupsen/logrus"
1415

1516
"github.com/longhorn/longhorn-share-manager/pkg/util"
1617
)
@@ -67,12 +68,12 @@ func (e *Exporter) GetExportMap() ExportMap {
6768
defer e.mapMutex.RUnlock()
6869

6970
volToID := map[string]uint16{}
70-
for vol, id := range e.ExportMap.volumeToid {
71+
for vol, id := range e.volumeToid {
7172
volToID[vol] = id
7273
}
7374

7475
idToVol := map[uint16]string{}
75-
for id, vol := range e.ExportMap.idToVolume {
76+
for id, vol := range e.idToVolume {
7677
idToVol[id] = vol
7778
}
7879

@@ -223,7 +224,11 @@ func (e *Exporter) addToConfig(block string) error {
223224
if err != nil {
224225
return err
225226
}
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+
}()
227232

228233
if _, err = config.WriteString(block); err != nil {
229234
return err
@@ -243,7 +248,7 @@ func (e *Exporter) removeFromConfig(block string) error {
243248
return err
244249
}
245250

246-
newConfig := strings.Replace(string(config), block, "", -1)
251+
newConfig := strings.ReplaceAll(string(config), block, "")
247252
err = os.WriteFile(e.configPath, []byte(newConfig), 0)
248253
if err != nil {
249254
return err

0 commit comments

Comments
 (0)