Kong / go-kong

Go binding for Kong's admin API
Apache License 2.0
88 stars 40 forks source link

fix: fill config values and defaults in shorthand fields #458

Closed Prashansa-K closed 3 months ago

Prashansa-K commented 3 months ago

As of now, deprecated fields are renamed to shorthand_fields in all schemas, as per the conventions. Till now, we do not fill any values for these fields while attempting to fill config records for plugins. This creates a visualisation problem in decK. Everytime, a deck diff or deck sync command is issued, it shows that the deprecated field values are changed and need to be updated, thus running an unnecessary update process each time and also confusing end users.

Check https://github.com/Kong/deck/issues/1251 for details.

This fix attempts to fill defaults for the shorthand_fields, retaining their values, if passed. Also, since shorthand_fields take priority over normal/nested fields in the gateway, if any changes are detected in shorthand_fields, it is backfilled to nested fields as well.

CLAassistant commented 3 months ago

CLA assistant check
All committers have signed the CLA.

CLAassistant commented 3 months ago

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

codecov-commenter commented 3 months ago

Codecov Report

Attention: Patch coverage is 77.55102% with 11 lines in your changes missing coverage. Please review.

Project coverage is 59.79%. Comparing base (a9ec2d5) to head (3a072ec).

Files Patch % Lines
kong/utils.go 77.55% 6 Missing and 5 partials :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #458 +/- ## ========================================== + Coverage 59.61% 59.79% +0.17% ========================================== Files 71 71 Lines 4408 4455 +47 ========================================== + Hits 2628 2664 +36 - Misses 1166 1172 +6 - Partials 614 619 +5 ``` | [Flag](https://app.codecov.io/gh/Kong/go-kong/pull/458/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kong) | Coverage Δ | | |---|---|---| | [2.1](https://app.codecov.io/gh/Kong/go-kong/pull/458/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kong) | `36.25% <77.55%> (+0.43%)` | :arrow_up: | | [2.2](https://app.codecov.io/gh/Kong/go-kong/pull/458/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kong) | `48.64% <77.55%> (+0.29%)` | :arrow_up: | | [2.3](https://app.codecov.io/gh/Kong/go-kong/pull/458/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kong) | `49.27% <77.55%> (+0.29%)` | :arrow_up: | | [2.4](https://app.codecov.io/gh/Kong/go-kong/pull/458/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kong) | `49.31% <77.55%> (+0.29%)` | :arrow_up: | | [2.5](https://app.codecov.io/gh/Kong/go-kong/pull/458/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kong) | `49.31% <77.55%> (+0.29%)` | :arrow_up: | | [2.6](https://app.codecov.io/gh/Kong/go-kong/pull/458/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kong) | `49.31% <77.55%> (+0.29%)` | :arrow_up: | | [2.7](https://app.codecov.io/gh/Kong/go-kong/pull/458/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kong) | `50.86% <77.55%> (+0.13%)` | :arrow_up: | | [2.8](https://app.codecov.io/gh/Kong/go-kong/pull/458/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kong) | `50.99% <77.55%> (+0.27%)` | :arrow_up: | | [3.0](https://app.codecov.io/gh/Kong/go-kong/pull/458/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kong) | `54.43% <77.55%> (-0.47%)` | :arrow_down: | | [3.1](https://app.codecov.io/gh/Kong/go-kong/pull/458/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kong) | `56.74% <77.55%> (+0.21%)` | :arrow_up: | | [3.2](https://app.codecov.io/gh/Kong/go-kong/pull/458/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kong) | `56.74% <77.55%> (+0.21%)` | :arrow_up: | | [3.3](https://app.codecov.io/gh/Kong/go-kong/pull/458/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kong) | `56.74% <77.55%> (+0.21%)` | :arrow_up: | | [3.4](https://app.codecov.io/gh/Kong/go-kong/pull/458/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kong) | `59.10% <77.55%> (+0.18%)` | :arrow_up: | | [3.5](https://app.codecov.io/gh/Kong/go-kong/pull/458/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kong) | `56.92% <77.55%> (+0.20%)` | :arrow_up: | | [3.6](https://app.codecov.io/gh/Kong/go-kong/pull/458/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kong) | `56.22% <77.55%> (-0.49%)` | :arrow_down: | | [community](https://app.codecov.io/gh/Kong/go-kong/pull/458/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kong) | `44.01% <77.55%> (+0.34%)` | :arrow_up: | | [enterprise](https://app.codecov.io/gh/Kong/go-kong/pull/458/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kong) | `58.22% <77.55%> (+0.19%)` | :arrow_up: | | [integration](https://app.codecov.io/gh/Kong/go-kong/pull/458/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kong) | `59.79% <77.55%> (+0.17%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kong#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

Prashansa-K commented 3 months ago

Added a unit test for the recent changes @GGabriele.