Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/buildtest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
dotnet-version: |
8.0.x
9.0.x
10.0.x
- name: Build
run: dotnet build --configuration Release
- name: Test
Expand Down Expand Up @@ -46,7 +47,7 @@ jobs:
- name: Setup dotnet SDK
uses: actions/setup-dotnet@v5
with:
dotnet-version: '9.0.x'
dotnet-version: '10.0.x'
- name: Restore nugets (msbuild)
run: msbuild .\src\KubernetesClient\ -t:restore -p:RestorePackagesConfig=true
- name: Build (msbuild)
Expand All @@ -64,6 +65,7 @@ jobs:
dotnet-version: |
8.0.x
9.0.x
10.0.x
- name: Minikube
run: minikube start
- name: Test
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
dotnet-version: |
8.0.x
9.0.x
10.0.x

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/docfx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
dotnet-version: |
8.0.x
9.0.x
10.0.x

- name: Build
run: dotnet build -c Release
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/draft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
dotnet-version: |
8.0.x
9.0.x
10.0.x

- name: dotnet restore
run: dotnet restore --verbosity minimal --configfile nuget.config
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/nuget.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
dotnet-version: |
8.0.x
9.0.x
10.0.x

- name: dotnet restore
run: dotnet restore --verbosity minimal --configfile nuget.config
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ ${GEN_DIR}/openapi/csharp.sh ${REPO_DIR}/src/KubernetesClient ${REPO_DIR}/csharp

| SDK Version | Kubernetes Version | .NET Targeting |
|-------------|--------------------|-----------------------------------------------------|
| 18.0 | 1.34 | net8.0;net9.0;net48*;netstandard2.0* |
| 18.0 | 1.34 | net8.0;net9.0;net10.0;net48*;netstandard2.0* |
| 17.0 | 1.33 | net8.0;net9.0;net48*;netstandard2.0* |
| 16.0 | 1.32 | net8.0;net9.0;net48*;netstandard2.0* |
| 15.0 | 1.31 | net6.0;net8.0;net48*;netstandard2.0* |
Expand Down
2 changes: 1 addition & 1 deletion src/KubernetesClient.Aot/KubernetesClient.Aot.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
<RootNamespace>k8s</RootNamespace>
<PublishAot>true</PublishAot>
<IsAotCompatible>true</IsAotCompatible>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>k8s.kubectl</RootNamespace>
Expand Down
2 changes: 1 addition & 1 deletion src/KubernetesClient/KubernetesClient.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
<RootNamespace>k8s</RootNamespace>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
</PropertyGroup>
Expand Down
20 changes: 14 additions & 6 deletions src/KubernetesClient/KubernetesJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,20 @@ public override void Write(Utf8JsonWriter writer, DateTimeOffset value, JsonSeri
// Output as RFC3339Micro
var date = value.ToUniversalTime();

var basePart = date.ToString("yyyy-MM-dd'T'HH:mm:ss", CultureInfo.InvariantCulture);
var frac = date.ToString(".ffffff", CultureInfo.InvariantCulture)
.TrimEnd('0')
.TrimEnd('.');

writer.WriteStringValue(basePart + frac + "Z");
// Check if there are any fractional seconds
var ticks = date.Ticks % TimeSpan.TicksPerSecond;
if (ticks == 0)
{
// No fractional seconds - use format without fractional part
var basePart = date.ToString("yyyy-MM-dd'T'HH:mm:ss", CultureInfo.InvariantCulture);
writer.WriteStringValue(basePart + "Z");
}
else
{
// Has fractional seconds - always use exactly 6 decimal places
var formatted = date.ToString(RFC3339MicroFormat, CultureInfo.InvariantCulture);
writer.WriteStringValue(formatted);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/E2E.Tests/E2E.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<IsPackable>false</IsPackable>
<RootNamespace>k8s.E2E</RootNamespace>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion tests/Kubectl.Tests/Kubectl.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<PropertyGroup>
<IsPackable>false</IsPackable>
<RootNamespace>k8s.Tests</RootNamespace>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">net8.0;net9.0</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">net8.0;net9.0;net48</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">net8.0;net9.0;net10.0</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">net8.0;net9.0;net10.0;net48</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion tests/KubernetesClient.Tests/KubernetesClient.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<IsPackable>false</IsPackable>
<RootNamespace>k8s.Tests</RootNamespace>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
27 changes: 27 additions & 0 deletions tests/KubernetesClient.Tests/KubernetesJsonTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,31 @@ public void ReadWriteDatesJson()

Assert.Equal(kManifest, jsonFromObj2);
}

[Fact]
public void DateTimeWithFractionalSecondsAlwaysHasSixDigits()
{
// Test that datetime fields with fractional seconds always output exactly 6 decimal places
// This is required by Kubernetes API which expects RFC3339Micro format

// Create a datetime with 5 digits of precision (962170 microseconds = .96217 seconds)
var dt = new DateTime(2025, 11, 17, 22, 52, 34, 962, DateTimeKind.Utc).AddTicks(1700);

var secret = new V1Secret
{
Metadata = new V1ObjectMeta
{
Name = "test-secret",
CreationTimestamp = dt,
},
};

var json = KubernetesJson.Serialize(secret);

// Verify the datetime is serialized with exactly 6 decimal places
Assert.Contains("2025-11-17T22:52:34.962170Z", json);

// Also verify it doesn't have 5 digits (which would fail in Kubernetes)
Assert.DoesNotContain("2025-11-17T22:52:34.96217Z", json);
}
}