Skip to content
This repository has been archived by the owner on Jan 19, 2023. It is now read-only.

Commit

Permalink
fix: Updated KubernetesClient to 7.2.19, fixed breaking binary change…
Browse files Browse the repository at this point in the history
…s in serialization. (#121)
  • Loading branch information
Silvenga committed May 16, 2022
1 parent 9447afb commit 7f409c5
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 138 deletions.
2 changes: 1 addition & 1 deletion src/DotnetKubernetesClient/DotnetKubernetesClient.csproj
Expand Up @@ -23,7 +23,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="KubernetesClient" Version="7.0.15" />
<PackageReference Include="KubernetesClient" Version="7.2.19" />
</ItemGroup>

</Project>
3 changes: 3 additions & 0 deletions src/DotnetKubernetesClient/Entities/EntityList.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
using k8s;
using k8s.Models;

Expand All @@ -7,7 +8,9 @@ namespace DotnetKubernetesClient.Entities;
public class EntityList<T> : KubernetesObject
where T : IKubernetesObject<V1ObjectMeta>
{
[JsonPropertyName("metadata")]
public V1ListMeta Metadata { get; set; } = new ();

[JsonPropertyName("items")]
public IList<T> Items { get; set; } = new List<T>();
}
17 changes: 6 additions & 11 deletions src/DotnetKubernetesClient/KubernetesClient.cs
Expand Up @@ -8,14 +8,9 @@
using System.Threading.Tasks;
using DotnetKubernetesClient.Entities;
using DotnetKubernetesClient.LabelSelectors;
using DotnetKubernetesClient.Serialization;
using k8s;
using k8s.Autorest;
using k8s.Models;
using Microsoft.Rest;
using Microsoft.Rest.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;

namespace DotnetKubernetesClient;

Expand Down Expand Up @@ -94,7 +89,7 @@ public Task<string> GetCurrentNamespace(string downwardApiEnvName = "POD_NAMESPA

if (result is JsonElement element)
{
return KubernetesJson.Deserialize<TResource>(element);
return element.Deserialize<TResource>();
}

return null;
Expand Down Expand Up @@ -127,7 +122,7 @@ public Task<string> GetCurrentNamespace(string downwardApiEnvName = "POD_NAMESPA

if (result is JsonElement element)
{
var list = KubernetesJson.Deserialize<EntityList<TResource>>(element);
var list = element.Deserialize<EntityList<TResource>>();
return list?.Items ?? throw new ArgumentException("Could not parse result");
}

Expand Down Expand Up @@ -177,7 +172,7 @@ public async Task<TResource> Create<TResource>(TResource resource)

if (result is JsonElement element)
{
return KubernetesJson.Deserialize<TResource>(element) ?? throw new ArgumentException("Could not parse result");
return element.Deserialize<TResource>() ?? throw new ArgumentException("Could not parse result");
}

throw new ArgumentException("Could not parse result");
Expand Down Expand Up @@ -205,7 +200,7 @@ public async Task<TResource> Update<TResource>(TResource resource)

if (result is JsonElement element)
{
return KubernetesJson.Deserialize<TResource>(element) ?? throw new ArgumentException("Could not parse result");
return element.Deserialize<TResource>() ?? throw new ArgumentException("Could not parse result");
}

throw new ArgumentException("Could not parse result");
Expand Down Expand Up @@ -233,7 +228,7 @@ public async Task UpdateStatus<TResource>(TResource resource)

if (result is JsonElement element)
{
var parsed = KubernetesJson.Deserialize<TResource>(element) ?? throw new ArgumentException("Could not parse result");
var parsed = element.Deserialize<TResource>() ?? throw new ArgumentException("Could not parse result");
resource.Metadata.ResourceVersion = parsed.Metadata.ResourceVersion;
return;
}
Expand Down
91 changes: 0 additions & 91 deletions src/DotnetKubernetesClient/Serialization/KubernetesJson.cs

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion tests/DotnetKubernetesClient.Test/KubernetesClient.Test.cs
Expand Up @@ -108,7 +108,7 @@ public async Task Should_Delete_Some_Object()
{
Kind = V1ConfigMap.KubeKind,
ApiVersion = V1ConfigMap.KubeApiVersion,
Metadata = new(name: "demo-config-two", namespaceProperty: "default"),
Metadata = new(name: RandomName(), namespaceProperty: "default"),
Data = new Dictionary<string, string> { { "Hello", "World" } },
});
_objects.Add(config1);
Expand Down

0 comments on commit 7f409c5

Please sign in to comment.