Use value from ContextDetails to populate Namespace (#373)

* Use value from ContextDetails to populate Namespace

This is a fix for: #372

This change uses the value from ContextDetails.Namespace to populate
KubernetesClientConfiguration.Namespace.

The issue is there's a Namespace property on both Context and ContextDetails
 - The property on Context is used today
 - The property on ContextDetails is not
 - The property on ContextDetails maps to the actual yaml config

* Obsolete Context.Namespace

This property doesn't map to anything in the YAML and thus will never be
set. Other clients I checked (java, golang) don't look for a property
at this level.

I think this was likely a mistake, and it should be obsoleted because
it will never be populated.

Example:

```yaml
contexts:
- context:
    cluster: ...
    namespace: ... # this is ContextDetails.Namespace
    user: ...
  name: foo
```

```yaml
contexts:
- context:
    cluster: ...
    namespace: ...
    user: ...
  name: foo
  namespace: ... # this is Context.Namespace
```
This commit is contained in:
Ryan Nowak
2020-03-17 09:48:23 -07:00
committed by GitHub
parent c1bab3caed
commit da3bff5b3e
5 changed files with 66 additions and 4 deletions

View File

@@ -1,5 +1,6 @@
namespace k8s.KubeConfigModels
{
using System;
using YamlDotNet.Serialization;
/// <summary>
@@ -19,6 +20,7 @@ namespace k8s.KubeConfigModels
[YamlMember(Alias = "name")]
public string Name { get; set; }
[Obsolete("This property is not set by the YAML config. Use ContextDetails.Namespace instead.")]
[YamlMember(Alias = "namespace")]
public string Namespace { get; set; }
}