Skip to content

Commit 9312370

Browse files
Fix examples by re-adding the no-arg config file builder. (#137)
1 parent 8544e08 commit 9312370

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

src/KubernetesClient/KubernetesClientConfiguration.ConfigFile.cs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
using System.Linq;
44
using System.Runtime.InteropServices;
55
using System.Security.Cryptography.X509Certificates;
6-
using System.Threading.Tasks;
6+
using System.Threading.Tasks;
77
using k8s.Exceptions;
88
using k8s.KubeConfigModels;
9-
9+
1010
namespace k8s
1111
{
1212
public partial class KubernetesClientConfiguration
@@ -29,7 +29,7 @@ public partial class KubernetesClientConfiguration
2929
/// </summary>
3030
/// <param name="masterUrl">kube api server endpoint</param>
3131
/// <param name="kubeconfigPath">Explicit file path to kubeconfig. Set to null to use the default file path</param>
32-
public static KubernetesClientConfiguration BuildConfigFromConfigFile(string kubeconfigPath,
32+
public static KubernetesClientConfiguration BuildConfigFromConfigFile(string kubeconfigPath = null,
3333
string currentContext = null, string masterUrl = null)
3434
{
3535
return BuildConfigFromConfigFile(new FileInfo(kubeconfigPath ?? KubeConfigDefaultLocation), null,
@@ -240,30 +240,30 @@ private void SetUserDetails(K8SConfiguration k8SConfig, Context activeContext)
240240
throw new KubeConfigException(
241241
$"User: {userDetails.Name} does not have appropriate auth credentials in kubeconfig");
242242
}
243-
}
244-
243+
}
244+
245245
/// <summary>
246246
/// Loads entire Kube Config from default or explicit file path
247247
/// </summary>
248248
/// <param name="kubeconfigPath">Explicit file path to kubeconfig. Set to null to use the default file path</param>
249-
/// <returns></returns>
250-
public static async Task<K8SConfiguration> LoadKubeConfigAsync(string kubeconfigPath = null)
251-
{
252-
var fileInfo = new FileInfo(kubeconfigPath ?? KubeConfigDefaultLocation);
253-
254-
return await LoadKubeConfigAsync(fileInfo);
255-
}
256-
249+
/// <returns></returns>
250+
public static async Task<K8SConfiguration> LoadKubeConfigAsync(string kubeconfigPath = null)
251+
{
252+
var fileInfo = new FileInfo(kubeconfigPath ?? KubeConfigDefaultLocation);
253+
254+
return await LoadKubeConfigAsync(fileInfo);
255+
}
256+
257257
/// <summary>
258258
/// Loads entire Kube Config from default or explicit file path
259259
/// </summary>
260260
/// <param name="kubeconfigPath">Explicit file path to kubeconfig. Set to null to use the default file path</param>
261-
/// <returns></returns>
262-
public static K8SConfiguration LoadKubeConfig(string kubeconfigPath = null)
263-
{
264-
return LoadKubeConfigAsync(kubeconfigPath).GetAwaiter().GetResult();
265-
}
266-
261+
/// <returns></returns>
262+
public static K8SConfiguration LoadKubeConfig(string kubeconfigPath = null)
263+
{
264+
return LoadKubeConfigAsync(kubeconfigPath).GetAwaiter().GetResult();
265+
}
266+
267267
// <summary>
268268
/// Loads Kube Config
269269
/// </summary>
@@ -274,10 +274,10 @@ public static async Task<K8SConfiguration> LoadKubeConfigAsync(FileInfo kubeconf
274274
if (!kubeconfig.Exists)
275275
{
276276
throw new KubeConfigException($"kubeconfig file not found at {kubeconfig.FullName}");
277-
}
278-
277+
}
278+
279279
using (var stream = kubeconfig.OpenRead())
280-
{
280+
{
281281
return await Yaml.LoadFromStreamAsync<K8SConfiguration>(stream);
282282
}
283283
}
@@ -288,17 +288,17 @@ public static async Task<K8SConfiguration> LoadKubeConfigAsync(FileInfo kubeconf
288288
/// <param name="kubeconfig">Kube config file contents</param>
289289
/// <returns>Instance of the <see cref="K8SConfiguration"/> class</returns>
290290
public static K8SConfiguration LoadKubeConfig(FileInfo kubeconfig)
291-
{
291+
{
292292
return LoadKubeConfigAsync(kubeconfig).GetAwaiter().GetResult();
293-
}
294-
293+
}
294+
295295
// <summary>
296296
/// Loads Kube Config
297297
/// </summary>
298298
/// <param name="kubeconfigStream">Kube config file contents stream</param>
299299
/// <returns>Instance of the <see cref="K8SConfiguration"/> class</returns>
300300
public static async Task<K8SConfiguration> LoadKubeConfigAsync(Stream kubeconfigStream)
301-
{
301+
{
302302
return await Yaml.LoadFromStreamAsync<K8SConfiguration>(kubeconfigStream);
303303
}
304304

@@ -308,7 +308,7 @@ public static async Task<K8SConfiguration> LoadKubeConfigAsync(Stream kubeconfig
308308
/// <param name="kubeconfig">Kube config file contents stream</param>
309309
/// <returns>Instance of the <see cref="K8SConfiguration"/> class</returns>
310310
public static K8SConfiguration LoadKubeConfig(Stream kubeconfigStream)
311-
{
311+
{
312312
return LoadKubeConfigAsync(kubeconfigStream).GetAwaiter().GetResult();
313313
}
314314
}

0 commit comments

Comments
 (0)