diff --git a/.gitignore b/.gitignore
index 800d87b..201f857 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,9 @@
.vs
obj/
bin/
+
+# User-specific VS files
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
diff --git a/README.md b/README.md
index 9f2fbd6..40404b2 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,6 @@
# csharp
Work In Progress
+Currently only supported on Linux
# Generating the client code
diff --git a/examples/simple/PodList.cs b/examples/simple/PodList.cs
index 9fa43a0..f65f8d1 100755
--- a/examples/simple/PodList.cs
+++ b/examples/simple/PodList.cs
@@ -1,18 +1,17 @@
-using System;
-
-using k8s;
-
-namespace simple
+namespace simple
{
+ using System;
+ using System.IO;
+ using k8s;
+
class PodList
{
static void Main(string[] args)
{
- IKubernetes client = new Kubernetes();
- client.BaseUri = new Uri("http://localhost:8001");
- var listTask = client.ListNamespacedPodWithHttpMessagesAsync("default");
- listTask.Wait();
- var list = listTask.Result.Body;
+ var k8sClientConfig = new KubernetesClientConfiguration();
+ IKubernetes client = new Kubernetes(k8sClientConfig);
+ var listTask = client.ListNamespacedPodWithHttpMessagesAsync("default").Result;
+ var list = listTask.Body;
foreach (var item in list.Items) {
Console.WriteLine(item.Metadata.Name);
}
diff --git a/examples/simple/simple.csproj b/examples/simple/simple.csproj
index e16c63b..b965b51 100755
--- a/examples/simple/simple.csproj
+++ b/examples/simple/simple.csproj
@@ -1,14 +1,14 @@
-
-
-
-
-
-
-
-
-
- Exe
- netcoreapp1.1
-
-
-
+
+
+
+
+
+
+
+
+
+ Exe
+ netcoreapp1.1
+
+
+
diff --git a/src/Exceptions/KubeConfigException.cs b/src/Exceptions/KubeConfigException.cs
new file mode 100644
index 0000000..534434a
--- /dev/null
+++ b/src/Exceptions/KubeConfigException.cs
@@ -0,0 +1,24 @@
+namespace k8s.Exceptions
+{
+ using System;
+
+ ///
+ /// The exception that is thrown when the kube config is invalid
+ ///
+ public class KubeConfigException : Exception
+ {
+ public KubeConfigException()
+ {
+ }
+
+ public KubeConfigException(string message)
+ : base(message)
+ {
+ }
+
+ public KubeConfigException(string message, Exception inner)
+ : base(message, inner)
+ {
+ }
+ }
+}
diff --git a/src/Exceptions/KubernetesClientException.cs b/src/Exceptions/KubernetesClientException.cs
new file mode 100644
index 0000000..765dfda
--- /dev/null
+++ b/src/Exceptions/KubernetesClientException.cs
@@ -0,0 +1,24 @@
+namespace k8s.Exceptions
+{
+ using System;
+
+ ///
+ /// The exception that is thrown when there is a client exception
+ ///
+ public class KubernetesClientException : Exception
+ {
+ public KubernetesClientException()
+ {
+ }
+
+ public KubernetesClientException(string message)
+ : base(message)
+ {
+ }
+
+ public KubernetesClientException(string message, Exception inner)
+ : base(message, inner)
+ {
+ }
+ }
+}
diff --git a/src/KubeConfigModels/Cluster.cs b/src/KubeConfigModels/Cluster.cs
new file mode 100644
index 0000000..9cd6d56
--- /dev/null
+++ b/src/KubeConfigModels/Cluster.cs
@@ -0,0 +1,13 @@
+namespace k8s.KubeConfigModels
+{
+ using YamlDotNet.Serialization;
+
+ public class Cluster
+ {
+ [YamlMember(Alias = "cluster")]
+ public ClusterEndpoint ClusterEndpoint { get; set; }
+
+ [YamlMember(Alias = "name")]
+ public string Name { get; set; }
+ }
+}
diff --git a/src/KubeConfigModels/ClusterEndpoint.cs b/src/KubeConfigModels/ClusterEndpoint.cs
new file mode 100644
index 0000000..fef1786
--- /dev/null
+++ b/src/KubeConfigModels/ClusterEndpoint.cs
@@ -0,0 +1,16 @@
+namespace k8s.KubeConfigModels
+{
+ using YamlDotNet.Serialization;
+
+ public class ClusterEndpoint
+ {
+ [YamlMember(Alias = "certificate-authority-data")]
+ public string CertificateAuthorityData { get; set; }
+
+ [YamlMember(Alias = "server")]
+ public string Server { get; set; }
+
+ [YamlMember(Alias = "insecure-skip-tls-verify")]
+ public bool SkipTlsVerify { get; set; }
+ }
+}
diff --git a/src/KubeConfigModels/Context.cs b/src/KubeConfigModels/Context.cs
new file mode 100644
index 0000000..73db6ba
--- /dev/null
+++ b/src/KubeConfigModels/Context.cs
@@ -0,0 +1,13 @@
+namespace k8s.KubeConfigModels
+{
+ using YamlDotNet.Serialization;
+
+ public class Context
+ {
+ [YamlMember(Alias = "context")]
+ public ContextDetails ContextDetails { get; set; }
+
+ [YamlMember(Alias = "name")]
+ public string Name { get; set; }
+ }
+}
diff --git a/src/KubeConfigModels/ContextDetails.cs b/src/KubeConfigModels/ContextDetails.cs
new file mode 100644
index 0000000..291f587
--- /dev/null
+++ b/src/KubeConfigModels/ContextDetails.cs
@@ -0,0 +1,17 @@
+namespace k8s.KubeConfigModels
+{
+ using YamlDotNet.RepresentationModel;
+ using YamlDotNet.Serialization;
+
+ public class ContextDetails
+ {
+ [YamlMember(Alias = "cluster")]
+ public string Cluster { get; set; }
+
+ [YamlMember(Alias = "user")]
+ public string User { get; set; }
+
+ [YamlMember(Alias = "namespace")]
+ public string Namespace { get; set; }
+ }
+}
diff --git a/src/KubeConfigModels/K8SConfiguration.cs b/src/KubeConfigModels/K8SConfiguration.cs
new file mode 100644
index 0000000..7c49098
--- /dev/null
+++ b/src/KubeConfigModels/K8SConfiguration.cs
@@ -0,0 +1,29 @@
+namespace k8s.KubeConfigModels
+{
+ using System.Collections.Generic;
+ using YamlDotNet.Serialization;
+
+ ///
+ /// kubeconfig configuration model
+ ///
+ public class K8SConfiguration
+ {
+ [YamlMember(Alias = "apiVersion")]
+ public string ApiVersion { get; set; }
+
+ [YamlMember(Alias = "kind")]
+ public string Kind { get; set; }
+
+ [YamlMember(Alias = "current-context")]
+ public string CurrentContext { get; set; }
+
+ [YamlMember(Alias = "contexts")]
+ public IEnumerable Contexts { get; set; }
+
+ [YamlMember(Alias = "clusters")]
+ public IEnumerable Clusters { get; set; }
+
+ [YamlMember(Alias = "users")]
+ public IEnumerable Users { get; set; }
+ }
+}
diff --git a/src/KubeConfigModels/User.cs b/src/KubeConfigModels/User.cs
new file mode 100644
index 0000000..2a3baa1
--- /dev/null
+++ b/src/KubeConfigModels/User.cs
@@ -0,0 +1,14 @@
+namespace k8s.KubeConfigModels
+{
+ using YamlDotNet.RepresentationModel;
+ using YamlDotNet.Serialization;
+
+ public class User
+ {
+ [YamlMember(Alias = "user")]
+ public UserCrednetials UserCredentials { get; set; }
+
+ [YamlMember(Alias = "name")]
+ public string Name { get; set; }
+ }
+}
diff --git a/src/KubeConfigModels/UserCrednetials.cs b/src/KubeConfigModels/UserCrednetials.cs
new file mode 100644
index 0000000..2078814
--- /dev/null
+++ b/src/KubeConfigModels/UserCrednetials.cs
@@ -0,0 +1,23 @@
+namespace k8s.KubeConfigModels
+{
+ using YamlDotNet.RepresentationModel;
+ using YamlDotNet.Serialization;
+
+ public class UserCrednetials
+ {
+ [YamlMember(Alias = "client-certificate-data")]
+ public string ClientCertificateData { get; set; }
+
+ [YamlMember(Alias = "client-key-data")]
+ public string ClientKeyData { get; set; }
+
+ [YamlMember(Alias = "token")]
+ public string Token { get; set; }
+
+ [YamlMember(Alias = "userName")]
+ public string UserName { get; set; }
+
+ [YamlMember(Alias = "password")]
+ public string Password { get; set; }
+ }
+}
diff --git a/src/Kubernetes.Auth.cs b/src/Kubernetes.Auth.cs
new file mode 100644
index 0000000..d372228
--- /dev/null
+++ b/src/Kubernetes.Auth.cs
@@ -0,0 +1,125 @@
+namespace k8s
+{
+ using System;
+ using System.Diagnostics.CodeAnalysis;
+ using System.Net.Http;
+ using System.Net.Security;
+ using System.Security.Cryptography.X509Certificates;
+ using System.Threading.Tasks;
+ using k8s.Exceptions;
+ using Microsoft.Rest;
+
+ public partial class Kubernetes : ServiceClient, IKubernetes
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ public Kubernetes(KubernetesClientConfiguration config)
+ {
+ this.Initialize();
+
+ this.CaCert = Utils.Base64Decode(config.SslCaCert);
+ this.BaseUri = new Uri(config.Host);
+
+ // ssl cert validation
+ Func