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

Merged
merged 3 commits into from
Oct 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion kong/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,12 +452,27 @@ func fillConfigRecord(schema gjson.Result, config Configuration, opts FillRecord
// the defaults for deprecated fields from the already formed default config
backwardTranslation := value.Get(fname + ".translate_backwards")

if !backwardTranslation.Exists() {
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
}
}
}
Prashansa-K marked this conversation as resolved.
Show resolved Hide resolved

if !backwardTranslation.Exists() && !replacePath.Exists() {
// This block attempts to fill defaults for deprecated fields.
// Thus, not erroring out here, as it is not vital.
return true
}

if !backwardTranslation.Exists() {
backwardTranslation = replacePath
}

configPathForBackwardTranslation := make([]string, 0, len(backwardTranslation.Array()))
for _, value := range backwardTranslation.Array() {
configPathForBackwardTranslation = append(configPathForBackwardTranslation, value.Str)
Expand Down
Loading