1
0
mirror of https://github.com/helm/chart-testing.git synced 2026-02-05 09:45:14 +01:00

Fix parsing kubectl output with warnings (#470)

* Fix for getting deployments

Don't parse error output (e.g. deprecation warnings) when trying to list deployments.

Signed-off-by: Usman <akeju00+github@gmail.com>

* Fix more output parsing

Signed-off-by: usmonster <akeju00+github@gmail.com>

Signed-off-by: Usman <akeju00+github@gmail.com>
Signed-off-by: usmonster <akeju00+github@gmail.com>
This commit is contained in:
Usman
2022-12-12 10:08:52 +01:00
committed by GitHub
parent 905570c60f
commit 98f96d2064

View File

@@ -70,7 +70,7 @@ func (k Kubectl) DeleteNamespace(namespace string) {
func (k Kubectl) forceNamespaceDeletion(namespace string) error {
// Getting the namespace json to remove the finalizer
cmdOutput, err := k.exec.RunProcessAndCaptureOutput("kubectl",
cmdOutput, err := k.exec.RunProcessAndCaptureStdout("kubectl",
fmt.Sprintf("--request-timeout=%s", k.timeout),
"get", "namespace", namespace, "--output=json")
if err != nil {
@@ -146,7 +146,7 @@ func (k Kubectl) forceNamespaceDeletion(namespace string) error {
}
func (k Kubectl) WaitForDeployments(namespace string, selector string) error {
output, err := k.exec.RunProcessAndCaptureOutput("kubectl",
output, err := k.exec.RunProcessAndCaptureStdout("kubectl",
fmt.Sprintf("--request-timeout=%s", k.timeout),
"get", "deployments", "--namespace", namespace, "--selector", selector,
"--output", "jsonpath={.items[*].metadata.name}")
@@ -169,7 +169,7 @@ func (k Kubectl) WaitForDeployments(namespace string, selector string) error {
//
// Just after rollout, pods from the previous deployment revision may still be in a
// terminating state.
unavailable, err := k.exec.RunProcessAndCaptureOutput("kubectl",
unavailable, err := k.exec.RunProcessAndCaptureStdout("kubectl",
fmt.Sprintf("--request-timeout=%s", k.timeout),
"get", "deployment", deployment, "--namespace", namespace, "--output",
`jsonpath={.status.unavailableReplicas}`)
@@ -185,7 +185,7 @@ func (k Kubectl) WaitForDeployments(namespace string, selector string) error {
}
func (k Kubectl) GetPodsforDeployment(namespace string, deployment string) ([]string, error) {
jsonString, _ := k.exec.RunProcessAndCaptureOutput("kubectl",
jsonString, _ := k.exec.RunProcessAndCaptureStdout("kubectl",
fmt.Sprintf("--request-timeout=%s", k.timeout),
"get", "deployment", deployment, "--namespace", namespace, "--output=json")
var deploymentMap map[string]interface{}
@@ -211,7 +211,7 @@ func (k Kubectl) GetPodsforDeployment(namespace string, deployment string) ([]st
func (k Kubectl) GetPods(args ...string) ([]string, error) {
kubectlArgs := []string{"get", "pods"}
kubectlArgs = append(kubectlArgs, args...)
pods, err := k.exec.RunProcessAndCaptureOutput("kubectl",
pods, err := k.exec.RunProcessAndCaptureStdout("kubectl",
fmt.Sprintf("--request-timeout=%s", k.timeout), kubectlArgs)
if err != nil {
return nil, err