From 03c6613a68fb5f91d3eed07b6a3e808c83e9a014 Mon Sep 17 00:00:00 2001 From: Nino Miletich Date: Fri, 26 Feb 2021 10:38:16 +0000 Subject: [PATCH] fix: ensure file sync works in multi-ns environments --- pkg/skaffold/runner/util/util.go | 6 ++++-- pkg/skaffold/runner/util/util_test.go | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/skaffold/runner/util/util.go b/pkg/skaffold/runner/util/util.go index af359ff2c73..9bb09226094 100644 --- a/pkg/skaffold/runner/util/util.go +++ b/pkg/skaffold/runner/util/util.go @@ -38,11 +38,13 @@ func GetAllPodNamespaces(configNamespace string, pipelines []latest.Pipeline) ([ return nil, fmt.Errorf("getting k8s configuration: %w", err) } + // The empty string is here to ensure that the File Sync feature + // works with multi-namespace environments + nsMap[""] = true + context, ok := config.Contexts[config.CurrentContext] if ok { nsMap[context.Namespace] = true - } else { - nsMap[""] = true } } else { nsMap[configNamespace] = true diff --git a/pkg/skaffold/runner/util/util_test.go b/pkg/skaffold/runner/util/util_test.go index 28096d262cd..146edf963cd 100644 --- a/pkg/skaffold/runner/util/util_test.go +++ b/pkg/skaffold/runner/util/util_test.go @@ -42,7 +42,7 @@ func TestGetAllPodNamespaces(t *testing.T) { { description: "kube context's namespace", currentContext: "prod-context", - expected: []string{"prod"}, + expected: []string{"", "prod"}, }, { description: "default namespace",