-
Notifications
You must be signed in to change notification settings - Fork 40
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
base: main
Are you sure you want to change the base?
Conversation
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 ReportAttention: Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
LGTM, left a comment.
kong/utils.go
Outdated
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 | ||
} | ||
} | ||
} |
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.
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.
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