Replies: 3 comments
-
I just noticed your note on that older ticket referring to this library, investigating ... |
Beta Was this translation helpful? Give feedback.
0 replies
-
Ok, this is working, but is ... ugly, need to think about this on how it could be cleaned up. Still need to try out the JsonPatch.Net package.
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Ok, this JsonPatch.Net package really simplifies everything. I'm going to take a shot at a pull request adding something to the 'patch' example with:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've been using a V1Patch.PatchType.MergePatch to add labels to a secret, but when I tried the same technique to remove a label it didn't work. After some research I think I need to use a JsonPatch. Just changing MergePatch to JsonPatch resulted in an error. Found an older posting with some examples, and used those to try and get things working, #772.
Here's the latest iteration, not sure why it isn't working...
Initially, after acquiring "V1Secret secret", I'd remove the label with:
secret.SetLabel(key, null);
Then I displayed the secret labels to verify it was in fact removed:
Originally I was trying to do this, but it was erroring out:
My latest attempt is this:
This results in the following output & error:
I copy the patch string built up into 'json lint' and it shows as valid json. My tests are nearly identical to the article I found, so I think I've got the right technique?
I can see in the minikube testing on line 120 to 131 of seemingly exactly what I'm looking to do. I just tried to copy that technique and noticed that after doing a JsonSerializer.SerializeToDocument(secret) that the resulting variable doesn't have a .CreatePatch method.
Just found the article from Microsoft saying that System.Text.Json doesn't support Json Doc patching. Followed the section "Add support for JSON Patch when using System.Text.Json" tried the following, still no go:
Kubernetes v1.25.9
.NET 7
Beta Was this translation helpful? Give feedback.
All reactions