Skip to content
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

fix: infer default namespace unless provided by provider config #1896

Merged
merged 2 commits into from
Feb 3, 2022
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Unreleased

- Infer default namespace from kubeconfig when not configured via the provider (https://github.com/pulumi/pulumi-kubernetes/pull/1896)

## 3.15.1 (February 2, 2022)
- [Helm/Release] Add import docs (https://github.com/pulumi/pulumi-kubernetes/pull/1893)

Expand Down
12 changes: 6 additions & 6 deletions provider/pkg/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,6 @@ func (k *kubeProvider) Configure(_ context.Context, req *pulumirpc.ConfigureRequ
//
// Configure client-go using provided or ambient kubeconfig file.
//

if defaultNamespace := vars["kubernetes:config:namespace"]; defaultNamespace != "" {
k.defaultNamespace = defaultNamespace
}
Expand Down Expand Up @@ -609,6 +608,10 @@ func (k *kubeProvider) Configure(_ context.Context, req *pulumirpc.ConfigureRequ
loadingRules := clientcmd.NewDefaultClientConfigLoadingRules()
loadingRules.DefaultClientConfig = &clientcmd.DefaultClientConfig
kubeconfig = clientcmd.NewInteractiveDeferredLoadingClientConfig(loadingRules, overrides, os.Stdin)
configurationNamespace, _, err := kubeconfig.Namespace()
if err == nil {
k.defaultNamespace = configurationNamespace
}
}

var kubeClientSettings KubeClientSettings
Expand Down Expand Up @@ -683,17 +686,14 @@ func (k *kubeProvider) Configure(_ context.Context, req *pulumirpc.ConfigureRequ
}

var err error
namespace := "default"
if k.defaultNamespace != "" {
namespace = k.defaultNamespace
}

k.helmReleaseProvider, err = newHelmReleaseProvider(
k.host,
apiConfig,
overrides,
k.config,
k.helmDriver,
namespace,
k.defaultNamespace,
k.enableSecrets,
k.helmPluginsPath,
k.helmRegistryConfigPath,
Expand Down