Skip to content
This repository has been archived by the owner on Feb 5, 2021. It is now read-only.

Commit

Permalink
Add verbose mode for setup create gcp command
Browse files Browse the repository at this point in the history
  • Loading branch information
MadhukaHarith92 authored and Mirage20 committed Jun 26, 2019
1 parent 9747706 commit 6b11e93
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 29 deletions.
1 change: 1 addition & 0 deletions components/cli/pkg/kubectl/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func ApplyFileWithNamespace(file, namespace string) error {
file,
"-n", namespace,
)
displayVerboseOutput(cmd)
cmd.Stderr = os.Stderr
return cmd.Run()
}
Expand Down
3 changes: 3 additions & 0 deletions components/cli/pkg/kubectl/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func CreateFile(file string) error {
"-f",
file,
)
displayVerboseOutput(cmd)
cmd.Stderr = os.Stderr
return cmd.Run()
}
Expand All @@ -58,6 +59,7 @@ func CreateConfigMapWithNamespace(name, confFile, namespace string) error {
confFile,
"-n", namespace,
)
displayVerboseOutput(cmd)
cmd.Stderr = os.Stderr
return cmd.Run()
}
Expand Down Expand Up @@ -86,6 +88,7 @@ func CreateClusterRoleBinding(clusterRole, user string) error {
"--user",
user,
)
displayVerboseOutput(cmd)
cmd.Stderr = os.Stderr
return cmd.Run()
}
2 changes: 2 additions & 0 deletions components/cli/pkg/kubectl/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func DeleteFileWithNamespace(file, namespace string) error {
"--ignore-not-found",
"-n", namespace,
)
displayVerboseOutput(cmd)
cmd.Stderr = os.Stderr
return cmd.Run()
}
Expand All @@ -46,6 +47,7 @@ func DeleteFile(file string) error {
file,
"--ignore-not-found",
)
displayVerboseOutput(cmd)
cmd.Stderr = os.Stderr
return cmd.Run()
}
Expand Down
27 changes: 2 additions & 25 deletions components/cli/pkg/kubectl/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
package kubectl

import (
"bufio"
"fmt"
"os/exec"

"github.com/cellery-io/sdk/components/cli/pkg/constants"
Expand All @@ -35,27 +33,6 @@ func Describe(cellName string) error {
cellName,
)
displayVerboseOutput(cmd)
stdoutReader, _ := cmd.StdoutPipe()
stdoutScanner := bufio.NewScanner(stdoutReader)
go func() {
for stdoutScanner.Scan() {
fmt.Println(stdoutScanner.Text())
}
}()
stderrReader, _ := cmd.StderrPipe()
stderrScanner := bufio.NewScanner(stderrReader)
go func() {
for stderrScanner.Scan() {
fmt.Println(stderrScanner.Text())
}
}()
err := cmd.Start()
if err != nil {
return err
}
err = cmd.Wait()
if err != nil {
return err
}
return nil
_, err := printCommandOutput(cmd)
return err
}
13 changes: 11 additions & 2 deletions components/cli/pkg/kubectl/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,23 @@ func GetDeploymentNames(namespace string) ([]string, error) {
"-n", namespace,
)
out, err := cmd.Output()
displayVerboseOutput(cmd)
if err != nil {
return nil, err
}
return strings.Split(string(out), " "), nil
}

func GetMasterNodeName() (string, error) {
cmd := exec.Command(constants.KUBECTL, "get", "node", "--selector", "node-role.kubernetes.io/master",
"-o", "json")
cmd := exec.Command(constants.KUBECTL,
"get",
"node",
"--selector",
"node-role.kubernetes.io/master",
"-o",
"json",
)
displayVerboseOutput(cmd)
out, err := cmd.Output()
if err != nil {
return "", err
Expand All @@ -70,6 +78,7 @@ func GetNodes() (Node, error) {
"-o",
"json",
)
displayVerboseOutput(cmd)
cmd.Stderr = os.Stderr
out, err := cmd.Output()
jsonOutput := Node{}
Expand Down
2 changes: 1 addition & 1 deletion components/cli/pkg/kubectl/label.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func ApplyLable(itemType, itemName, labelName string, overWrite bool) error {
labelName,
)
}

displayVerboseOutput(cmd)
cmd.Stderr = os.Stderr
return cmd.Run()
}
7 changes: 6 additions & 1 deletion components/cli/pkg/kubectl/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ func WaitForCondition(condition string, timeoutSeconds int, resourceName string,
func WaitForCluster(timeout time.Duration) error {
exitCode := 0
for start := time.Now(); time.Since(start) < timeout; {
cmd := exec.Command(constants.KUBECTL, "get", "nodes", "--request-timeout=10s")
cmd := exec.Command(constants.KUBECTL,
"get",
"nodes",
"--request-timeout=10s",
)
displayVerboseOutput(cmd)
err := cmd.Run()
if err != nil {
if exitError, ok := err.(*exec.ExitError); ok {
Expand Down

0 comments on commit 6b11e93

Please sign in to comment.