Skip to content

Commit bee2245

Browse files
author
Lee Briggs
committed
Fix cli arg position issues
1 parent d5fb467 commit bee2245

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

commands.go

+5-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package flexvolume
33
import (
44
"encoding/json"
55
"fmt"
6-
76
"github.com/urfave/cli"
87
)
98

@@ -21,8 +20,7 @@ func Commands(fv FlexVolume) []cli.Command {
2120
Usage: "Attach the volume",
2221
Action: func(c *cli.Context) error {
2322
var opts map[string]string
24-
25-
if err := json.Unmarshal([]byte(c.Args().Get(1)), &opts); err != nil {
23+
if err := json.Unmarshal([]byte(c.Args().Get(0)), &opts); err != nil {
2624
return err
2725
}
2826

@@ -33,7 +31,7 @@ func Commands(fv FlexVolume) []cli.Command {
3331
Name: "detach",
3432
Usage: "Detach the volume",
3533
Action: func(c *cli.Context) error {
36-
return handle(fv.Detach(c.Args().Get(1)))
34+
return handle(fv.Detach(c.Args().Get(0)))
3735
},
3836
},
3937
{
@@ -42,18 +40,18 @@ func Commands(fv FlexVolume) []cli.Command {
4240
Action: func(c *cli.Context) error {
4341
var opts map[string]string
4442

45-
if err := json.Unmarshal([]byte(c.Args().Get(1)), &opts); err != nil {
43+
if err := json.Unmarshal([]byte(c.Args().Get(2)), &opts); err != nil {
4644
return err
4745
}
4846

49-
return handle(fv.Mount(c.Args().Get(1), c.Args().Get(2), opts))
47+
return handle(fv.Mount(c.Args().Get(0), c.Args().Get(1), opts))
5048
},
5149
},
5250
{
5351
Name: "umount",
5452
Usage: "Mount the volume",
5553
Action: func(c *cli.Context) error {
56-
return handle(fv.Unmount(c.Args().Get(1)))
54+
return handle(fv.Unmount(c.Args().Get(0)))
5755
},
5856
},
5957
}

types.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ package flexvolume
33
type Status string
44

55
const (
6-
StatusSuccess Status = "Success"
7-
StatusFailure Status = "Failure"
8-
StatusNotSupported Status = "Not Supported"
6+
StatusSuccess Status = "Success"
7+
StatusFailure Status = "Failure"
8+
StatusNotSupported Status = "Not Supported"
99
)
1010

1111
type FlexVolume interface {
@@ -19,5 +19,5 @@ type FlexVolume interface {
1919
type Response struct {
2020
Status Status `json:"status"`
2121
Message string `json:"message"`
22-
Device string `json:"device"`
22+
Device string `json:"device,omitempty"`
2323
}

0 commit comments

Comments
 (0)