Fix kubeconfig extension handling (#556)
Extensions on kubeconfig files are stored as a list of NamedExtension objects, not a dictionary.
This commit is contained in:
17
tests/KubernetesClient.Tests/KubernetesClientConfigurationTests.cs
Executable file → Normal file
17
tests/KubernetesClient.Tests/KubernetesClientConfigurationTests.cs
Executable file → Normal file
@@ -1,10 +1,11 @@
|
||||
using k8s.Exceptions;
|
||||
using k8s.KubeConfigModels;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using k8s.Exceptions;
|
||||
using k8s.KubeConfigModels;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
namespace k8s.Tests
|
||||
@@ -372,6 +373,14 @@ namespace k8s.Tests
|
||||
Assert.NotNull(cfg.Host);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ContextWithClusterExtensions()
|
||||
{
|
||||
var path = Path.GetFullPath("assets/kubeconfig.cluster-extensions.yml");
|
||||
|
||||
var cfg = await KubernetesClientConfiguration.BuildConfigFromConfigFileAsync(new FileInfo(path)).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensures Kube config file is loaded from explicit file
|
||||
/// </summary>
|
||||
@@ -525,8 +534,8 @@ namespace k8s.Tests
|
||||
new FileInfo(path), new FileInfo(path),
|
||||
});
|
||||
|
||||
Assert.Equal(1, cfg.Extensions.Count);
|
||||
Assert.Equal(1, cfg.Preferences.Count);
|
||||
Assert.Single(cfg.Extensions);
|
||||
Assert.Single(cfg.Preferences);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
apiVersion: v1
|
||||
clusters:
|
||||
- cluster:
|
||||
extensions:
|
||||
- extension:
|
||||
last-update: Wed, 27 Jan 2021 11:44:41 UTC
|
||||
provider: minikube.sigs.k8s.io
|
||||
version: v1.17.0
|
||||
name: cluster_info
|
||||
server: https://192.168.49.2:8443
|
||||
name: minikube
|
||||
contexts:
|
||||
- context:
|
||||
cluster: minikube
|
||||
extensions:
|
||||
- extension:
|
||||
last-update: Wed, 27 Jan 2021 11:44:41 UTC
|
||||
provider: minikube.sigs.k8s.io
|
||||
version: v1.17.0
|
||||
name: context_info
|
||||
namespace: default
|
||||
user: minikube
|
||||
name: minikube
|
||||
current-context: minikube
|
||||
kind: Config
|
||||
preferences: {}
|
||||
users:
|
||||
- name: minikube
|
||||
user:
|
||||
password: secret
|
||||
username: admin
|
||||
@@ -3,4 +3,6 @@ kind: Config
|
||||
preferences:
|
||||
colors: true
|
||||
extensions:
|
||||
foo: bar
|
||||
- name: foo
|
||||
extension:
|
||||
foo: bar
|
||||
|
||||
Reference in New Issue
Block a user