Skip to content

Commit 40dfe53

Browse files
committed
Add sparse option
1 parent 8a177de commit 40dfe53

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

driver/driver.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,24 @@ func (d Driver) Create(req *v.CreateRequest) error {
8080
size)
8181
}
8282

83+
sparse := false
84+
sparseStr, sparsePresent := req.Options["sparsePresent"]
85+
if sparsePresent {
86+
sparse, err = strconv.ParseBool(sparseStr)
87+
if err != nil {
88+
return errors.Wrapf(err,
89+
"Error creating volume '%s' - cannot parse 'sparse' option value '%s' as bool",
90+
req.Name, sparseStr)
91+
}
92+
}
93+
8394
uid := -1
8495
uidStr, uidPresent := req.Options["uid"]
8596
if uidPresent && len(uidStr) > 0 {
8697
uid, err = strconv.Atoi(uidStr)
8798
if err != nil {
8899
return errors.Wrapf(err,
89-
"Error creating volume '%s' - cannot parse 'uid' option '%s' as an integer",
100+
"Error creating volume '%s' - cannot parse 'uid' option value '%s' as an integer",
90101
req.Name, uidStr)
91102
}
92103
if uid < 0 {
@@ -106,7 +117,7 @@ func (d Driver) Create(req *v.CreateRequest) error {
106117
gid, err = strconv.Atoi(gidStr)
107118
if err != nil {
108119
return errors.Wrapf(err,
109-
"Error creating volume '%s' - cannot parse 'gid' option '%s' as an integer",
120+
"Error creating volume '%s' - cannot parse 'gid' option value '%s' as an integer",
110121
req.Name, gidStr)
111122
}
112123
if gid < 0 {
@@ -141,7 +152,7 @@ func (d Driver) Create(req *v.CreateRequest) error {
141152

142153
logger.Debug().Msg("starting creation")
143154

144-
err = d.manager.Create(req.Name, sizeInBytes, uid, gid, mode)
155+
err = d.manager.Create(req.Name, sizeInBytes, sparse, uid, gid, mode)
145156
if err != nil {
146157
return err
147158
}

0 commit comments

Comments
 (0)