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
Open
Changes from all commits
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
21 changes: 18 additions & 3 deletions kong/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,24 @@ func fillConfigRecord(schema gjson.Result, config Configuration, opts FillRecord
backwardTranslation := value.Get(fname + ".translate_backwards")

if !backwardTranslation.Exists() {
// This block attempts to fill defaults for deprecated fields.
// Thus, not erroring out here, as it is not vital.
return true
// Checking for replaced_with path if it exists in the deprecation block
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
}
}
}

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

backwardTranslation = replacePath
}

configPathForBackwardTranslation := make([]string, 0, len(backwardTranslation.Array()))
Expand Down
Loading