GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix container exec · PastureStack/cli@287bf8a

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • cmd
    • exec.go
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎cmd/exec.go‎

Copy file name to clipboardExpand all lines: cmd/exec.go
+8-7Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ func execCommandInternal(ctx *cli.Context) error {
7171
return errors.New("not authorized to exec into this container")
7272
}
7373

74-
fmt.Println(execURL)
75-
7674
payload := execPayload{
7775
AttachStdin: true,
7876
AttachStdout: true,
@@ -181,24 +179,27 @@ func selectContainer(c *client.RancherClient, args []string) ([]string, string,
181179
}
182180

183181
var containerExecURL string
184-
if _, ok := resource.Links["instances"]; ok {
182+
if _, ok := resource.Actions["execute"]; ok {
183+
containerExecURL = resource.Actions["execute"]
184+
} else {
185185
var instances client.ContainerCollection
186186
if err := c.GetLink(*resource, "instances", &instances); err != nil {
187187
return nil, "", err
188188
}
189189

190-
containerExecURL, err = getContainerIDFromList(c, instances)
190+
containerExecURL, err = getContainerExecFromList(c, instances)
191191
if err != nil {
192192
return nil, "", err
193193
}
194-
} else {
195-
containerExecURL = resource.Actions["execute"]
196194
}
197195

198196
return newArgs, containerExecURL, nil
199197
}
200198

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) {
202203
if len(containers.Data) == 0 {
203204
return "", fmt.Errorf("failed to find a container")
204205
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.