Skip to content

Commit

Permalink
Fixed command processing when container is empty (#59)
Browse files Browse the repository at this point in the history
* Fixed command processing when container is empty

* update version number
  • Loading branch information
axia-wish authored Apr 8, 2022
1 parent f76bb14 commit 9c8d8dc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 11 additions & 6 deletions cmd/cp.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package cmd
import (
"errors"
"fmt"
"os"
"os/exec"
"strings"

"github.com/spf13/cobra"
"github.com/wish/ctl/cmd/util/parsing"
"github.com/wish/ctl/pkg/client"
v1 "k8s.io/api/core/v1"
"os"
"os/exec"
"strings"
)

// func cpTest() {
Expand Down Expand Up @@ -57,7 +58,7 @@ If no container is set, it will use the first one.`,
user = strings.ToLower(user)
podName := fmt.Sprintf("%s-%s", appName, user)
lm, _ := parsing.LabelMatch(fmt.Sprintf("name=%s", podName))
options := client.ListOptions{LabelMatch:lm}
options := client.ListOptions{LabelMatch: lm}

pod, _, _, err := c.FindAdhocPodAndAppDetails(appName, options)
if err != nil {
Expand Down Expand Up @@ -97,11 +98,15 @@ If no container is set, it will use the first one.`,
// Print out useful info for users
fmt.Printf("\nCopying files from: %s\n", source)
fmt.Printf("Placing them in: %v\n", out)
command := exec.Command("kubectl", "cp", sourceFiles, outputFiles, context, container)
var command *exec.Cmd
if container == "" {
command = exec.Command("kubectl", "cp", sourceFiles, outputFiles, context)
} else {
command = exec.Command("kubectl", "cp", sourceFiles, outputFiles, context, container)
}
command.Stdout = os.Stdout
command.Stderr = os.Stderr
command.Stdin = os.Stdin

// Build command
return command.Run()
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

// Version set default value
var Version = "v14.4.0"
var Version = "v14.4.1"

func versionCmd(*client.Client) *cobra.Command {
return &cobra.Command{
Expand Down

0 comments on commit 9c8d8dc

Please sign in to comment.