Add support Namespace in the kubeconfig file. (#72)
This commit is contained in:
@@ -9,5 +9,8 @@
|
||||
|
||||
[YamlMember(Alias = "name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[YamlMember(Alias = "namespace")]
|
||||
public string Namespace { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,13 +53,11 @@ namespace k8s
|
||||
var k8SConfiguration = new KubernetesClientConfiguration();
|
||||
|
||||
currentContext = currentContext ?? k8SConfig.CurrentContext;
|
||||
|
||||
// only init context if context if set
|
||||
if (currentContext != null)
|
||||
{
|
||||
k8SConfiguration.InitializeContext(k8SConfig, currentContext);
|
||||
}
|
||||
|
||||
k8SConfiguration.InitializeContext(k8SConfig, currentContext);
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(masterUrl))
|
||||
{
|
||||
k8SConfiguration.Host = masterUrl;
|
||||
@@ -68,8 +66,8 @@ namespace k8s
|
||||
if (string.IsNullOrWhiteSpace(k8SConfiguration.Host))
|
||||
{
|
||||
throw new KubeConfigException("Cannot infer server host url either from context or masterUrl");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return k8SConfiguration;
|
||||
}
|
||||
|
||||
@@ -96,6 +94,9 @@ namespace k8s
|
||||
|
||||
// user
|
||||
SetUserDetails(k8SConfig, activeContext);
|
||||
|
||||
// namespace
|
||||
Namespace = activeContext.Namespace;
|
||||
}
|
||||
|
||||
private void SetClusterDetails(K8SConfiguration k8SConfig, Context activeContext)
|
||||
@@ -122,8 +123,7 @@ namespace k8s
|
||||
var uri = new Uri(Host);
|
||||
if (uri.Scheme == "https")
|
||||
{
|
||||
|
||||
// check certificate for https
|
||||
// check certificate for https
|
||||
if (!clusterDetails.ClusterEndpoint.SkipTlsVerify &&
|
||||
string.IsNullOrWhiteSpace(clusterDetails.ClusterEndpoint.CertificateAuthorityData) &&
|
||||
string.IsNullOrWhiteSpace(clusterDetails.ClusterEndpoint.CertificateAuthority))
|
||||
|
||||
@@ -7,6 +7,11 @@ namespace k8s
|
||||
/// </summary>
|
||||
public partial class KubernetesClientConfiguration
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets current namespace
|
||||
/// </summary>
|
||||
public string Namespace { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets Host
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user