@@ -71,8 +71,6 @@ func execCommandInternal(ctx *cli.Context) error { |
71 | 71 | return errors.New("not authorized to exec into this container") |
72 | 72 | } |
73 | 73 |
|
74 | | - fmt.Println(execURL) |
75 | | - |
76 | 74 | payload := execPayload{ |
77 | 75 | AttachStdin: true, |
78 | 76 | AttachStdout: true, |
@@ -181,24 +179,27 @@ func selectContainer(c *client.RancherClient, args []string) ([]string, string, |
181 | 179 | } |
182 | 180 |
|
183 | 181 | var containerExecURL string |
184 | | - if _, ok := resource.Links["instances"]; ok { |
| 182 | + if _, ok := resource.Actions["execute"]; ok { |
| 183 | + containerExecURL = resource.Actions["execute"] |
| 184 | + } else { |
185 | 185 | var instances client.ContainerCollection |
186 | 186 | if err := c.GetLink(*resource, "instances", &instances); err != nil { |
187 | 187 | return nil, "", err |
188 | 188 | } |
189 | 189 |
|
190 | | - containerExecURL, err = getContainerIDFromList(c, instances) |
| 190 | + containerExecURL, err = getContainerExecFromList(c, instances) |
191 | 191 | if err != nil { |
192 | 192 | return nil, "", err |
193 | 193 | } |
194 | | - } else { |
195 | | - containerExecURL = resource.Actions["execute"] |
196 | 194 | } |
197 | 195 |
|
198 | 196 | return newArgs, containerExecURL, nil |
199 | 197 | } |
200 | 198 |
|
201 | | -func getContainerIDFromList(c *client.RancherClient, containers client.ContainerCollection) (string, error) { |
| 199 | +// getContainerExecFromList accepts a container collection, if there is more than |
| 200 | +// one it prints them to the screen, accepts user input then returns the execute |
| 201 | +// link for the user chosen container |
| 202 | +func getContainerExecFromList(c *client.RancherClient, containers client.ContainerCollection) (string, error) { |
202 | 203 | if len(containers.Data) == 0 { |
203 | 204 | return "", fmt.Errorf("failed to find a container") |
204 | 205 | } |
|