-
Notifications
You must be signed in to change notification settings - Fork 305
feat: allow overriding YamlDotNet settings #1335
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
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: IvanJosipovic The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe you want event?
Codecov Report
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. @@ Coverage Diff @@
## master #1335 +/- ##
=========================================
Coverage ? 69.74%
=========================================
Files ? 96
Lines ? 2720
Branches ? 0
=========================================
Hits ? 1897
Misses ? 823
Partials ? 0 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
I converted the logic to use an event. It can be tested like this: using k8s;
using System.Text.Json.Nodes;
using YamlDotNet.Serialization;
using YamlDotNet.System.Text.Json;
KubernetesYamlConfiguration.SeralizerEvent += KubernetesYamlConfiguration_SeralizerEvent;
void KubernetesYamlConfiguration_SeralizerEvent(object? sender, SerializerBuilder e)
{
e.WithTypeConverter(new SystemTextJsonYamlTypeConverter(true))
.WithTypeInspector(x => new SystemTextJsonTypeInspector(x));
}
KubernetesYamlConfiguration.DeseralizerEvent += KubernetesYamlConfiguration_DeseralizerEvent;
void KubernetesYamlConfiguration_DeseralizerEvent(object? sender, DeserializerBuilder e)
{
e.WithTypeConverter(new SystemTextJsonYamlTypeConverter())
.WithTypeInspector(x => new SystemTextJsonTypeInspector(x));
}
var obj = KubernetesYaml.LoadFromString<JsonObject>(File.ReadAllText("helm-release.yaml"));
var yaml = KubernetesYaml.Serialize(obj);
Console.ReadLine(); |
close as of #1498 |
@tg123, can we please re-open this PR? |
This PR allows overriding the default YamlDotNet settings by adding a new KubernetesYamlConfiguration class.
I'm not able to test this as its static.