Fix examples by re-adding the no-arg config file builder. (#137)
This commit is contained in:
@@ -3,10 +3,10 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using k8s.Exceptions;
|
||||
using k8s.KubeConfigModels;
|
||||
|
||||
|
||||
namespace k8s
|
||||
{
|
||||
public partial class KubernetesClientConfiguration
|
||||
@@ -29,7 +29,7 @@ namespace k8s
|
||||
/// </summary>
|
||||
/// <param name="masterUrl">kube api server endpoint</param>
|
||||
/// <param name="kubeconfigPath">Explicit file path to kubeconfig. Set to null to use the default file path</param>
|
||||
public static KubernetesClientConfiguration BuildConfigFromConfigFile(string kubeconfigPath,
|
||||
public static KubernetesClientConfiguration BuildConfigFromConfigFile(string kubeconfigPath = null,
|
||||
string currentContext = null, string masterUrl = null)
|
||||
{
|
||||
return BuildConfigFromConfigFile(new FileInfo(kubeconfigPath ?? KubeConfigDefaultLocation), null,
|
||||
@@ -240,30 +240,30 @@ namespace k8s
|
||||
throw new KubeConfigException(
|
||||
$"User: {userDetails.Name} does not have appropriate auth credentials in kubeconfig");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads entire Kube Config from default or explicit file path
|
||||
/// </summary>
|
||||
/// <param name="kubeconfigPath">Explicit file path to kubeconfig. Set to null to use the default file path</param>
|
||||
/// <returns></returns>
|
||||
public static async Task<K8SConfiguration> LoadKubeConfigAsync(string kubeconfigPath = null)
|
||||
{
|
||||
var fileInfo = new FileInfo(kubeconfigPath ?? KubeConfigDefaultLocation);
|
||||
|
||||
return await LoadKubeConfigAsync(fileInfo);
|
||||
}
|
||||
|
||||
/// <returns></returns>
|
||||
public static async Task<K8SConfiguration> LoadKubeConfigAsync(string kubeconfigPath = null)
|
||||
{
|
||||
var fileInfo = new FileInfo(kubeconfigPath ?? KubeConfigDefaultLocation);
|
||||
|
||||
return await LoadKubeConfigAsync(fileInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads entire Kube Config from default or explicit file path
|
||||
/// </summary>
|
||||
/// <param name="kubeconfigPath">Explicit file path to kubeconfig. Set to null to use the default file path</param>
|
||||
/// <returns></returns>
|
||||
public static K8SConfiguration LoadKubeConfig(string kubeconfigPath = null)
|
||||
{
|
||||
return LoadKubeConfigAsync(kubeconfigPath).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
/// <returns></returns>
|
||||
public static K8SConfiguration LoadKubeConfig(string kubeconfigPath = null)
|
||||
{
|
||||
return LoadKubeConfigAsync(kubeconfigPath).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
// <summary>
|
||||
/// Loads Kube Config
|
||||
/// </summary>
|
||||
@@ -274,10 +274,10 @@ namespace k8s
|
||||
if (!kubeconfig.Exists)
|
||||
{
|
||||
throw new KubeConfigException($"kubeconfig file not found at {kubeconfig.FullName}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
using (var stream = kubeconfig.OpenRead())
|
||||
{
|
||||
{
|
||||
return await Yaml.LoadFromStreamAsync<K8SConfiguration>(stream);
|
||||
}
|
||||
}
|
||||
@@ -288,17 +288,17 @@ namespace k8s
|
||||
/// <param name="kubeconfig">Kube config file contents</param>
|
||||
/// <returns>Instance of the <see cref="K8SConfiguration"/> class</returns>
|
||||
public static K8SConfiguration LoadKubeConfig(FileInfo kubeconfig)
|
||||
{
|
||||
{
|
||||
return LoadKubeConfigAsync(kubeconfig).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// <summary>
|
||||
/// Loads Kube Config
|
||||
/// </summary>
|
||||
/// <param name="kubeconfigStream">Kube config file contents stream</param>
|
||||
/// <returns>Instance of the <see cref="K8SConfiguration"/> class</returns>
|
||||
public static async Task<K8SConfiguration> LoadKubeConfigAsync(Stream kubeconfigStream)
|
||||
{
|
||||
{
|
||||
return await Yaml.LoadFromStreamAsync<K8SConfiguration>(kubeconfigStream);
|
||||
}
|
||||
|
||||
@@ -308,7 +308,7 @@ namespace k8s
|
||||
/// <param name="kubeconfig">Kube config file contents stream</param>
|
||||
/// <returns>Instance of the <see cref="K8SConfiguration"/> class</returns>
|
||||
public static K8SConfiguration LoadKubeConfig(Stream kubeconfigStream)
|
||||
{
|
||||
{
|
||||
return LoadKubeConfigAsync(kubeconfigStream).GetAwaiter().GetResult();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user