@@ -19,8 +19,9 @@ func ExecuteResourceCommand(r *api.Resource, args []string) (*http.Request, stri
1919 var parents []* string
2020
2121 i := 1
22- for i < len (r .PatternElems )- 1 {
23- p := r .PatternElems [i ]
22+ patternElems := r .PatternElems ()
23+ for i < len (patternElems )- 1 {
24+ p := patternElems [i ]
2425 flagName := p [1 : len (p )- 1 ]
2526 var flagValue string
2627 parents = append (parents , & flagValue )
@@ -31,9 +32,9 @@ func ExecuteResourceCommand(r *api.Resource, args []string) (*http.Request, stri
3132
3233 withPrefix := func (path string ) string {
3334 pElems := []string {}
34- for i , p := range r . PatternElems {
35+ for i , p := range patternElems {
3536 // last element, we assume this was handled by the caller.
36- if i == len (r . PatternElems )- 1 {
37+ if i == len (patternElems )- 1 {
3738 continue
3839 }
3940 if i % 2 == 0 {
@@ -46,10 +47,10 @@ func ExecuteResourceCommand(r *api.Resource, args []string) (*http.Request, stri
4647 return fmt .Sprintf ("%s%s" , prefix , path )
4748 }
4849
49- if r .CreateMethod != nil {
50+ if r .Methods . Create != nil {
5051 use := "create [id]"
5152 args := cobra .ExactArgs (1 )
52- if ! r .CreateMethod .SupportsUserSettableCreate {
53+ if ! r .Methods . Create .SupportsUserSettableCreate {
5354 use = "create"
5455 args = cobra .ExactArgs (0 )
5556 }
@@ -60,7 +61,7 @@ func ExecuteResourceCommand(r *api.Resource, args []string) (*http.Request, stri
6061 Args : args ,
6162 Run : func (cmd * cobra.Command , args []string ) {
6263 p := withPrefix ("" )
63- if r .CreateMethod .SupportsUserSettableCreate {
64+ if r .Methods . Create .SupportsUserSettableCreate {
6465 id := args [0 ]
6566 p = withPrefix (fmt .Sprintf ("?id=%s" , id ))
6667 }
@@ -78,7 +79,7 @@ func ExecuteResourceCommand(r *api.Resource, args []string) (*http.Request, stri
7879 c .AddCommand (createCmd )
7980 }
8081
81- if r .GetMethod != nil {
82+ if r .Methods . Get != nil {
8283 getCmd := & cobra.Command {
8384 Use : "get [id]" ,
8485 Short : fmt .Sprintf ("Get a %v" , strings .ToLower (r .Singular )),
@@ -92,7 +93,7 @@ func ExecuteResourceCommand(r *api.Resource, args []string) (*http.Request, stri
9293 c .AddCommand (getCmd )
9394 }
9495
95- if r .UpdateMethod != nil {
96+ if r .Methods . Update != nil {
9697
9798 updateArgs := map [string ]interface {}{}
9899 updateCmd := & cobra.Command {
@@ -116,7 +117,7 @@ func ExecuteResourceCommand(r *api.Resource, args []string) (*http.Request, stri
116117 c .AddCommand (updateCmd )
117118 }
118119
119- if r .DeleteMethod != nil {
120+ if r .Methods . Delete != nil {
120121
121122 deleteCmd := & cobra.Command {
122123 Use : "delete [id]" ,
@@ -131,7 +132,7 @@ func ExecuteResourceCommand(r *api.Resource, args []string) (*http.Request, stri
131132 c .AddCommand (deleteCmd )
132133 }
133134
134- if r .ListMethod != nil {
135+ if r .Methods . List != nil {
135136
136137 listCmd := & cobra.Command {
137138 Use : "list" ,
0 commit comments