-
Notifications
You must be signed in to change notification settings - Fork 309
Add AddJsonOptions to KubernetesClientConfiguration and KubernetesJson #1257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
k8s-ci-robot
merged 22 commits into
kubernetes-client:master
from
luiscantero:luis/addjsonoptions_config
Apr 4, 2023
Merged
Changes from 19 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
467f49d
Use camelCase policy when serializing enums
luiscantero 62959fc
Merge branch 'kubernetes-client:master' into master
luiscantero e16df9e
Revert "Use camelCase policy when serializing enums"
luiscantero 59c3c73
Add jonSerializerOptions to GenericClient
luiscantero bf6d7a6
Add jsonSerializerOptions param
luiscantero e46c60e
Revert pass deserialization options in GenericClient
luiscantero ecd46a8
Add JsonSerializerOptions to KubernetesClientConfiguration
luiscantero 568534a
Use user JsonSerializerOptions in SendRequest and CreateResultAsync
luiscantero 47f3787
Improve comment
luiscantero 72dc77a
Remove JsonSerializerOptions
luiscantero f21e587
Cosmetic
luiscantero 277e788
Add AddJsonOptions
luiscantero 47662cc
Fix example
luiscantero 65a35a9
Fix test
luiscantero a7824f7
Add test
luiscantero 0218aae
Add summary
luiscantero 706d9c4
Improve summary
luiscantero e2a24ca
Remove configure from Kubernetes ctor and tests
luiscantero 80083a7
Add AddJsonOptions to config and test
luiscantero d0436c5
Support per client json serializer options
luiscantero 6a89ba2
Add ConfigureAwait for tests
luiscantero f315372
Check for nullargument
luiscantero File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| using k8s.Tests.Mock; | ||
| using System.Text.Json; | ||
| using System.Text.Json.Serialization; | ||
| using System.Threading.Tasks; | ||
| using Xunit; | ||
| using Xunit.Abstractions; | ||
|
|
||
| namespace k8s.Tests | ||
| { | ||
| public class SerializationTests | ||
| { | ||
| private readonly ITestOutputHelper testOutput; | ||
|
|
||
| private enum Animals | ||
| { | ||
| Dog, | ||
| Cat, | ||
| Mouse, | ||
| } | ||
|
|
||
| public SerializationTests(ITestOutputHelper testOutput) | ||
| { | ||
| this.testOutput = testOutput; | ||
| } | ||
|
|
||
| [Fact] | ||
| public async Task SerializeEnumUsingCamelCase() | ||
| { | ||
| using var server = new MockKubeApiServer(testOutput); | ||
|
|
||
| var config = new KubernetesClientConfiguration { Host = server.Uri.ToString() }; | ||
| config.AddJsonOptions(options => | ||
| { | ||
| // Insert the converter at the front of the list so it overrides | ||
| // the default JsonStringEnumConverter without namingPolicy. | ||
| options.Converters.Insert(index: 0, new JsonStringEnumConverter(JsonNamingPolicy.CamelCase)); | ||
| }); | ||
| var client = new Kubernetes(config); | ||
|
|
||
| var customObject = Animals.Dog; | ||
|
|
||
| var result = await client.CustomObjects.CreateNamespacedCustomObjectWithHttpMessagesAsync(customObject, "TestGroup", "TestVersion", "TestNamespace", "TestPlural").ConfigureAwait(false); | ||
| var content = await result.Request.Content.ReadAsStringAsync(); | ||
| Assert.Equal(@"""dog""", content); | ||
|
|
||
| string animal = KubernetesJson.Serialize(Animals.Cat); | ||
| Assert.Equal(@"""cat""", animal); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.