Skip to content

Commit e647d7e

Browse files
authored
fix: Set PatchType Correctly (Next) (#447)
* Do not set patch type when patch is empty. * Correctly handle PatchType with no changes.
1 parent a8e559a commit e647d7e

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/KubeOps/Operator/Webhooks/AdmissionResponse.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ internal sealed class AdmissionResponse
2020
public string[] Warnings { get; init; } = Array.Empty<string>();
2121

2222
[JsonPropertyName("patchType")]
23-
public string? PatchType { get; set; } = JsonPatch;
23+
public string? PatchType { get; set; }
2424

2525
[JsonPropertyName("patch")]
2626
public string? Patch { get; set; }

src/KubeOps/Operator/Webhooks/IMutationWebhook{TEntity}.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ AdmissionResponse IAdmissionWebhook<TEntity, MutationResult>.TransformResult(Mut
7777

7878
var patch = KubernetesJsonDiffer.DiffObjects(from, to);
7979
response.Patch = Convert.ToBase64String(Encoding.UTF8.GetBytes(patch.ToString()));
80+
response.PatchType = AdmissionResponse.JsonPatch;
8081
}
8182

8283
return response;

0 commit comments

Comments
 (0)