Skip to content

Commit 46e51fe

Browse files
fix: update skaffold verify to respect deploy default namespace field (#8660)
1 parent d39e853 commit 46e51fe

File tree

2 files changed

+2
-13
lines changed

2 files changed

+2
-13
lines changed

pkg/skaffold/runner/verifier.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func GetVerifier(ctx context.Context, runCtx *runcontext.RunContext, labeller *l
5353
}
5454

5555
if len(kubernetesTestCases) != 0 {
56-
nv, err := k8sjob.NewVerifier(ctx, runCtx, labeller, kubernetesTestCases, runCtx.Artifacts(), envMap)
56+
nv, err := k8sjob.NewVerifier(ctx, runCtx, labeller, kubernetesTestCases, runCtx.Artifacts(), envMap, runCtx.GetNamespace())
5757
if err != nil {
5858
return nil, err
5959
}

pkg/skaffold/verify/k8sjob/verify.go

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ import (
2222
"io"
2323
"io/ioutil"
2424
"math"
25-
"os/exec"
26-
"strings"
2725
"sync"
2826
"time"
2927

@@ -53,7 +51,6 @@ import (
5351
"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/log"
5452
"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/latest"
5553
"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/status"
56-
"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/util"
5754
)
5855

5956
// Verifier verifies deployments using kubernetes libs/CLI.
@@ -75,15 +72,7 @@ type Verifier struct {
7572

7673
// NewVerifier returns a new Verifier for a VerifyConfig filled
7774
// with the needed configuration for `kubectl apply`
78-
func NewVerifier(ctx context.Context, cfg kubectl.Config, labeller *label.DefaultLabeller, testCases []*latest.VerifyTestCase, artifacts []*latest.Artifact, envMap map[string]string) (*Verifier, error) {
79-
defaultNamespace := ""
80-
b, err := (&util.Commander{}).RunCmdOut(context.Background(), exec.Command("kubectl", "config", "view", "--minify", "-o", "jsonpath='{..namespace}'"))
81-
if err == nil {
82-
defaultNamespace = strings.Trim(string(b), "'")
83-
if defaultNamespace == "default" {
84-
defaultNamespace = ""
85-
}
86-
}
75+
func NewVerifier(ctx context.Context, cfg kubectl.Config, labeller *label.DefaultLabeller, testCases []*latest.VerifyTestCase, artifacts []*latest.Artifact, envMap map[string]string, defaultNamespace string) (*Verifier, error) {
8776
kubectl := kubectl.NewCLI(cfg, latest.KubectlFlags{}, defaultNamespace)
8877
// default namespace must be "default" not "" when used to create and stream logs from Job(s)
8978
if defaultNamespace == "" {

0 commit comments

Comments
 (0)