Skip to content

fix: update skaffold verify to respect deploy default namespace field #8660

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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