Skip to content

Commit d5fb467

Browse files
committed
Update example
1 parent 6b8d65e commit d5fb467

File tree

1 file changed

+44
-47
lines changed

1 file changed

+44
-47
lines changed

README.md

+44-47
Original file line numberDiff line numberDiff line change
@@ -17,73 +17,70 @@ The following example should demonstate:
1717
package main
1818

1919
import (
20-
"os"
21-
"os/exec"
20+
"os"
2221

23-
"github.com/nickschuch/flexvolume"
24-
"github.com/urfave/cli"
22+
"github.com/nickschuch/flexvolume"
23+
"github.com/urfave/cli"
2524
)
2625

2726
func main() {
28-
app := cli.NewApp()
29-
app.Commands = flexvolume.Commands(Mock{})
30-
app.Run(os.Args)
27+
app := cli.NewApp()
28+
app.Commands = flexvolume.Commands(Mock{})
29+
app.Run(os.Args)
3130
}
3231

3332
type Mock struct {}
3433

3534
func (m Mock) Init() flexvolume.Response {
36-
return flexvolume.Response{
37-
Status: flexvolume.StatusSuccess,
38-
Message: "Mock is available",
39-
}
35+
return flexvolume.Response{
36+
Status: flexvolume.StatusSuccess,
37+
Message: "Mock is available",
38+
}
4039
}
4140

4241
func (m Mock) Attach(options map[string]string) flexvolume.Response {
43-
return flexvolume.Response{
44-
Status: flexvolume.StatusSuccess,
45-
Message: "Successfully attached the mock volume",
46-
}
42+
return flexvolume.Response{
43+
Status: flexvolume.StatusSuccess,
44+
Message: "Successfully attached the mock volume",
45+
}
4746
}
4847

4948
func (m Mock) Detach(device string) flexvolume.Response {
50-
return flexvolume.Response{
51-
Status: flexvolume.StatusSuccess,
52-
Message: "Successfully detached the mock volume",
53-
}
49+
return flexvolume.Response{
50+
Status: flexvolume.StatusSuccess,
51+
Message: "Successfully detached the mock volume",
52+
}
5453
}
5554

5655
func (m Mock) Mount(target, device string, options map[string]string) flexvolume.Response {
57-
device := "/dev/sdb1"
58-
59-
err := os.MkdirAll(target, 0755)
60-
if err != nil {
61-
return flexvolume.Response{
62-
Status: flexvolume.StatusFailure,
63-
Message: err.Error(),
64-
Device: device,
65-
}
66-
}
67-
68-
return flexvolume.Response{
69-
Status: flexvolume.StatusSuccess,
70-
Message: "Successfully mounted the mock volume",
71-
Device: device,
72-
}
56+
err := os.MkdirAll(target, 0755)
57+
if err != nil {
58+
return flexvolume.Response{
59+
Status: flexvolume.StatusFailure,
60+
Message: err.Error(),
61+
Device: "/dev/sdb1",
62+
}
63+
}
64+
65+
return flexvolume.Response{
66+
Status: flexvolume.StatusSuccess,
67+
Message: "Successfully mounted the mock volume",
68+
Device: "/dev/sdb1",
69+
}
7370
}
7471

7572
func (m Mock) Unmount(mount string) flexvolume.Response {
76-
err := os.RemoveAll(mount)
77-
if err != nil {
78-
return flexvolume.Response{
79-
Status: flexvolume.StatusFailure,
80-
Message: err.Error(),
81-
}
82-
}
83-
84-
return flexvolume.Response{
85-
Status: flexvolume.StatusSuccess,
86-
Message: "Successfully unmounted the mock volume",
87-
}
73+
err := os.RemoveAll(mount)
74+
if err != nil {
75+
return flexvolume.Response{
76+
Status: flexvolume.StatusFailure,
77+
Message: err.Error(),
78+
}
79+
}
80+
81+
return flexvolume.Response{
82+
Status: flexvolume.StatusSuccess,
83+
Message: "Successfully unmounted the mock volume",
84+
}
8885
}
8986
```

0 commit comments

Comments
 (0)