Skip to content
This repository was archived by the owner on Feb 6, 2026. It is now read-only.
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
6 changes: 3 additions & 3 deletions src/K8sOperator.NET/Models/CustomResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ public abstract class CustomResource<TSpec> : CustomResource, ISpec<TSpec>
/// </summary>
/// <typeparam name="TSpec">The type of the specification.</typeparam>
/// <typeparam name="TStatus">The type of the status.</typeparam>
public abstract class CustomResource<TSpec, TStatus> : CustomResource<TSpec>, IStatus<TStatus>
public abstract class CustomResource<TSpec, TStatus> : CustomResource<TSpec>, IStatus<TStatus?>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Breaking change: The interface implementation now uses nullable TStatus.

Changing from IStatus<TStatus> to IStatus<TStatus?> is a breaking change that affects API consumers. Any code that assumes Status is always initialized will need to be updated to handle potential null values. Consider documenting this change clearly in release notes or migration guides.

Also note that you've kept the where TStatus : new() constraint even though Status can now be null. This is fine but means that TStatus must still have a parameterless constructor even if we don't automatically use it.

where TSpec : new()
where TStatus : new()
where TStatus : class
{
/// <summary>
/// Gets or sets the status for the custom resource.
/// </summary>
[JsonPropertyName("status")]
public TStatus Status { get; set; } = new();
public TStatus? Status { get; set; }
}
9 changes: 4 additions & 5 deletions test/K8sOperator.NET.Tests/ControllerTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using K8sOperator.NET.Models;

namespace K8sOperator.NET.Tests;
namespace K8sOperator.NET.Tests;

public class ControllerTests
{
Expand Down Expand Up @@ -79,8 +77,9 @@ public async Task Overridden_AddOrModifyAsync_Should_Call_CustomImplementation()
// Act
await derivedController.AddOrModifyAsync(resource, CancellationToken.None);

// Assert
resource.Status.Status.Should().Be("Changed");

resource.Status.Should().NotBeNull();
resource.Status?.Status.Should().Be("Changed");
}

// You can also extend these tests for DeleteAsync, FinalizeAsync, BookmarkAsync, and ErrorAsync
Expand Down
Loading