Skip to content

Commit f46c02f

Browse files
Merge pull request #60 from tg123/v1.8
generate from V1.8.4
2 parents 2fdf22b + a04e6d2 commit f46c02f

File tree

461 files changed

+90294
-27856
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

461 files changed

+90294
-27856
lines changed

csharp.settings

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export KUBERNETES_BRANCH=master
1+
export KUBERNETES_BRANCH=v1.8.4
22
export CLIENT_VERSION=0.0.1
33
export PACKAGE_NAME=k8s

examples/namespace/Namespace.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ private static void Main(string[] args)
5454

5555
ListNamespaces(client);
5656

57-
var ns = new Corev1Namespace
57+
var ns = new V1Namespace
5858
{
5959
Metadata = new V1ObjectMeta
6060
{
@@ -71,7 +71,7 @@ private static void Main(string[] args)
7171

7272
if (status.HasObject)
7373
{
74-
var obj = status.ObjectView<Corev1Namespace>();
74+
var obj = status.ObjectView<V1Namespace>();
7575
Console.WriteLine(obj.Status.Phase);
7676

7777
Delete(client, ns.Metadata.Name, 3 * 1000);

examples/simple/PodList.cs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1+
using System;
2+
using k8s;
3+
14
namespace simple
25
{
3-
using System;
4-
using System.IO;
5-
using k8s;
6-
7-
class PodList
6+
internal class PodList
87
{
9-
static void Main(string[] args)
8+
private static void Main(string[] args)
109
{
11-
var k8sClientConfig = KubernetesClientConfiguration.BuildConfigFromConfigFile();
12-
IKubernetes client = new Kubernetes(k8sClientConfig);
10+
var config = KubernetesClientConfiguration.BuildConfigFromConfigFile();
11+
IKubernetes client = new Kubernetes(config);
1312
Console.WriteLine("Starting Request!");
14-
var listTask = client.ListNamespacedPodWithHttpMessagesAsync("default").Result;
15-
var list = listTask.Body;
16-
foreach (var item in list.Items) {
13+
14+
var list = client.ListNamespacedPod("default");
15+
foreach (var item in list.Items)
16+
{
1717
Console.WriteLine(item.Metadata.Name);
1818
}
19-
if (list.Items.Count == 0) {
19+
if (list.Items.Count == 0)
20+
{
2021
Console.WriteLine("Empty!");
2122
}
2223
}

examples/watch/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ private static void Main(string[] args)
1414
IKubernetes client = new Kubernetes(config);
1515

1616
var podlistResp = client.ListNamespacedPodWithHttpMessagesAsync("default", watch: true).Result;
17-
using (podlistResp.Watch<Corev1Pod>((type, item) =>
17+
using (podlistResp.Watch<V1Pod>((type, item) =>
1818
{
1919
Console.WriteLine("==on watch event==");
2020
Console.WriteLine(type);

src/IntOrString.cs

Lines changed: 0 additions & 56 deletions
This file was deleted.

src/IntstrIntOrString.cs

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
using System;
2+
using Newtonsoft.Json;
3+
4+
namespace k8s.Models
5+
{
6+
internal class IntOrStringConverter : JsonConverter
7+
{
8+
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
9+
{
10+
var s = (value as IntstrIntOrString)?.Value;
11+
12+
if (int.TryParse(s, out var intv))
13+
{
14+
serializer.Serialize(writer, intv);
15+
return;
16+
}
17+
18+
serializer.Serialize(writer, s);
19+
}
20+
21+
public override object ReadJson(JsonReader reader, Type objectType, object existingValue,
22+
JsonSerializer serializer)
23+
{
24+
return (IntstrIntOrString) serializer.Deserialize<string>(reader);
25+
}
26+
27+
public override bool CanConvert(Type objectType)
28+
{
29+
return objectType == typeof(int) || objectType == typeof(string);
30+
}
31+
}
32+
33+
[JsonConverter(typeof(IntOrStringConverter))]
34+
public partial class IntstrIntOrString
35+
{
36+
public static implicit operator int(IntstrIntOrString v)
37+
{
38+
return int.Parse(v.Value);
39+
}
40+
41+
public static implicit operator IntstrIntOrString(int v)
42+
{
43+
return new IntstrIntOrString(Convert.ToString(v));
44+
}
45+
46+
public static implicit operator string(IntstrIntOrString v)
47+
{
48+
return v.Value;
49+
}
50+
51+
public static implicit operator IntstrIntOrString(string v)
52+
{
53+
return new IntstrIntOrString(v);
54+
}
55+
56+
protected bool Equals(IntstrIntOrString other)
57+
{
58+
return string.Equals(Value, other.Value);
59+
}
60+
61+
public override bool Equals(object obj)
62+
{
63+
if (ReferenceEquals(null, obj)) return false;
64+
if (ReferenceEquals(this, obj)) return true;
65+
if (obj.GetType() != this.GetType()) return false;
66+
return Equals((IntstrIntOrString) obj);
67+
}
68+
69+
public override int GetHashCode()
70+
{
71+
return (Value != null ? Value.GetHashCode() : 0);
72+
}
73+
}
74+
}

0 commit comments

Comments
 (0)