-
Notifications
You must be signed in to change notification settings - Fork 41
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
fix(utils): support record-level default schema values #431
Conversation
|
f68d1af
to
e1234b7
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #431 +/- ##
==========================================
- Coverage 59.32% 57.92% -1.41%
==========================================
Files 69 69
Lines 4219 4223 +4
==========================================
- Hits 2503 2446 -57
- Misses 1134 1206 +72
+ Partials 582 571 -11
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
e1234b7
to
fa2ff62
Compare
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.
Minor nits regarding tests. Please rebase against latest main
to pull in the changes in CI that test against 3.5 and 3.6
Before this change, during the process of filling default configuration values, if a record existed in the schema with a structure similar to the following: ``` { "default": { "some_field": "record_level_default" }, "fields": [ { "some_field": { "type": "string", "default": "field_level_default" } } ] } ``` the value `record_level_default` would be ignored and the field set to the `field_level_default` value. Similarly, in case of no field-level default, the field would be set to `null`. This commit modifies the utils/fillConfigRecord logic to assign fields with record-level default values when available. Example of default configuration values that were previously ignored: https://github.com/Kong/kong/blob/8fe14097a17cf904676672fc8cdaabe5e02e4a2d/kong/plugins/opentelemetry/schema.lua#L49 https://github.com/Kong/kong/blob/8fe14097a17cf904676672fc8cdaabe5e02e4a2d/kong/plugins/opentelemetry/schema.lua#L90
fa2ff62
to
e544d45
Compare
Before this change, during the process of filling default configuration values, if a record existed in the schema with a structure similar to the following:
the value
record_level_default
would be ignored and the field set to thefield_level_default
value. Similarly, in case of no field-level default, the field would be set tonull
.This commit modifies the utils/fillConfigRecord logic to assign fields with record-level default values when available.
Example of default configuration values that were previously ignored: https://github.com/Kong/kong/blob/8fe14097a17cf904676672fc8cdaabe5e02e4a2d/kong/plugins/opentelemetry/schema.lua#L49 https://github.com/Kong/kong/blob/8fe14097a17cf904676672fc8cdaabe5e02e4a2d/kong/plugins/opentelemetry/schema.lua#L90
fixes: KAG-4149