Skip to content
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: use replaced_with to check for deprecated fields #472

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Prashansa-K
Copy link
Collaborator

@Prashansa-K Prashansa-K commented Oct 17, 2024

In schemas, shorthand_fields that are deprecated
will use "replaced_with" going forward to convey the new fields that would be used in place of the old ones. Earlier, "translate_backwards" was used for the same.

This change ensures that both of the above mentioned fields can be used to find the new path that leads to the new values for comparison purposes. This will help tools like deck to show diff between syncs.

Fixes deck #1440
Corresponding PR: Kong/kong#13768

In schemas, shorthand_fields that are deprecated
will use "replaced_with" going forward to convey the
new fields that would be used in place of the old ones.
Earlier, "translate_backwards" was used for the same.

This change ensures that both of the above mentioned fields
can be used to find the new path that leads to the new values
for comparison purposes. This will help tools like deck
to show diff between syncs.
@codecov-commenter
Copy link

codecov-commenter commented Oct 17, 2024

Codecov Report

Attention: Patch coverage is 0% with 14 lines in your changes missing coverage. Please review.

Project coverage is 54.04%. Comparing base (5a089c7) to head (0a8022c).

Files with missing lines Patch % Lines
kong/utils.go 0.00% 14 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #472      +/-   ##
==========================================
- Coverage   59.93%   54.04%   -5.90%     
==========================================
  Files          71       71              
  Lines        4463     5599    +1136     
==========================================
+ Hits         2675     3026     +351     
- Misses       1169     1954     +785     
  Partials      619      619              
Flag Coverage Δ
2.1 33.54% <0.00%> (-2.90%) ⬇️
2.2 44.18% <0.00%> (-4.62%) ⬇️
2.3 44.75% <0.00%> (-4.68%) ⬇️
2.4 44.82% <0.00%> (-4.65%) ⬇️
2.5 44.82% <0.00%> (-4.65%) ⬇️
2.6 44.82% <0.00%> (-4.65%) ⬇️
2.7 46.32% <0.00%> (-4.83%) ⬇️
2.8 46.32% <0.00%> (-4.83%) ⬇️
3.0 49.93% <0.00%> (-5.34%) ⬇️
3.1 51.29% <0.00%> (-5.60%) ⬇️
3.2 51.29% <0.00%> (-5.60%) ⬇️
3.3 51.29% <0.00%> (-5.60%) ⬇️
3.4 53.34% <0.00%> (-5.90%) ⬇️
3.5 51.47% <0.00%> (-5.60%) ⬇️
3.6 51.47% <0.00%> (-5.60%) ⬇️
community 40.34% <0.00%> (-3.84%) ⬇️
enterprise 52.61% <0.00%> (-5.76%) ⬇️
integration 54.04% <0.00%> (-5.90%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@samugi samugi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, left a comment.

kong/utils.go Outdated
Comment on lines 455 to 464
var replacePath gjson.Result
replacedWith := value.Get(fname + ".deprecation.replaced_with")
if replacedWith.IsArray() {
for _, item := range replacedWith.Array() {
if pathArray := item.Get("path"); pathArray.Exists() && pathArray.IsArray() {
replacePath = pathArray
break
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like we don't need to run any of this code if backwardTranslation.Exists() so we could execute this conditionally to backwardTranslation not existing.

I think we may also simplify and just reassign backwardTranslation = pathArray here if the item is found, so we wouldn't need the replacePath variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

deck diff shows a diff for shorthand fields
3 participants