Skip to content

Commit

Permalink
fix: update skaffold verify to respect deploy default namespace field (
Browse files Browse the repository at this point in the history
…#8660)

(cherry picked from commit 46e51fe)
  • Loading branch information
aaron-prindle committed Apr 11, 2023
1 parent 9dfd49b commit 701c45c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pkg/skaffold/runner/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func GetVerifier(ctx context.Context, runCtx *runcontext.RunContext, labeller *l
}

if len(kubernetesTestCases) != 0 {
nv, err := k8sjob.NewVerifier(ctx, runCtx, labeller, kubernetesTestCases, runCtx.Artifacts(), envMap)
nv, err := k8sjob.NewVerifier(ctx, runCtx, labeller, kubernetesTestCases, runCtx.Artifacts(), envMap, runCtx.GetNamespace())
if err != nil {
return nil, err
}
Expand Down
13 changes: 1 addition & 12 deletions pkg/skaffold/verify/k8sjob/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import (
"io"
"io/ioutil"
"math"
"os/exec"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -53,7 +51,6 @@ import (
"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/log"
"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/latest"
"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/status"
"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/util"
)

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

// NewVerifier returns a new Verifier for a VerifyConfig filled
// with the needed configuration for `kubectl apply`
func NewVerifier(ctx context.Context, cfg kubectl.Config, labeller *label.DefaultLabeller, testCases []*latest.VerifyTestCase, artifacts []*latest.Artifact, envMap map[string]string) (*Verifier, error) {
defaultNamespace := ""
b, err := (&util.Commander{}).RunCmdOut(context.Background(), exec.Command("kubectl", "config", "view", "--minify", "-o", "jsonpath='{..namespace}'"))
if err == nil {
defaultNamespace = strings.Trim(string(b), "'")
if defaultNamespace == "default" {
defaultNamespace = ""
}
}
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) {
kubectl := kubectl.NewCLI(cfg, latest.KubectlFlags{}, defaultNamespace)
// default namespace must be "default" not "" when used to create and stream logs from Job(s)
if defaultNamespace == "" {
Expand Down

0 comments on commit 701c45c

Please sign in to comment.