mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 05:57:25 +00:00
substitute gcloud regex with regexp
This commit is contained in:
parent
7a03564bb6
commit
6e31263115
@ -616,17 +616,22 @@ func gcloudList(resource, regex, project string, out interface{}) {
|
|||||||
// so we only look at stdout.
|
// so we only look at stdout.
|
||||||
command := []string{
|
command := []string{
|
||||||
"compute", resource, "list",
|
"compute", resource, "list",
|
||||||
fmt.Sprintf("--regex=%v", regex),
|
fmt.Sprintf("--regexp=%v", regex),
|
||||||
fmt.Sprintf("--project=%v", project),
|
fmt.Sprintf("--project=%v", project),
|
||||||
"-q", "--format=json",
|
"-q", "--format=json",
|
||||||
}
|
}
|
||||||
output, err := exec.Command("gcloud", command...).Output()
|
output, err := exec.Command("gcloud", command...).Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errCode := -1
|
errCode := -1
|
||||||
|
errMsg := ""
|
||||||
if exitErr, ok := err.(utilexec.ExitError); ok {
|
if exitErr, ok := err.(utilexec.ExitError); ok {
|
||||||
errCode = exitErr.ExitStatus()
|
errCode = exitErr.ExitStatus()
|
||||||
|
errMsg = exitErr.Error()
|
||||||
|
if osExitErr, ok := err.(*exec.ExitError); ok {
|
||||||
|
errMsg = fmt.Sprintf("%v, stderr %v", errMsg, string(osExitErr.Stderr))
|
||||||
}
|
}
|
||||||
framework.Logf("Error running gcloud command 'gcloud %s': err: %v, output: %v, status: %d", strings.Join(command, " "), err, string(output), errCode)
|
}
|
||||||
|
framework.Logf("Error running gcloud command 'gcloud %s': err: %v, output: %v, status: %d, msg: %v", strings.Join(command, " "), err, string(output), errCode, errMsg)
|
||||||
}
|
}
|
||||||
if err := json.Unmarshal([]byte(output), out); err != nil {
|
if err := json.Unmarshal([]byte(output), out); err != nil {
|
||||||
framework.Logf("Error unmarshalling gcloud output for %v: %v, output: %v", resource, err, string(output))
|
framework.Logf("Error unmarshalling gcloud output for %v: %v, output: %v", resource, err, string(output))
|
||||||
|
Loading…
Reference in New Issue
Block a user