fix: file conversion from 2.8 to 3.4 for post-function plugin#1974
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1974 +/- ##
==========================================
- Coverage 32.88% 32.72% -0.16%
==========================================
Files 77 77
Lines 6988 7046 +58
==========================================
+ Hits 2298 2306 +8
- Misses 4506 4545 +39
- Partials 184 195 +11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
1b817b1 to
beb9839
Compare
| - /r1 | ||
| plugins: | ||
| - config: | ||
| # Both legacy and new fields are non empty |
There was a problem hiding this comment.
This config should have resulted in an error, right?
We have set errorExpected: false and the tests pass.
There was a problem hiding this comment.
Yes - I wanted to check with you about this - during conversion of plugin config as of now in other functions, the errors are printed to console, but execution is not halted - https://github.com/Kong/deck/blob/main/convert/plugin_updates.go#L243
Shall I modify the function signature and return error instead?
This is what the output looks like
> go run main.go file convert --from 2.8 --to 3.4 --input-file x.yaml -o y.yaml
From the 'x.yaml' config file,
the _format_version field has been migrated from '1.1' to '3.0'.
Error: both legacy configuration field "functions" and new field "access" have values in plugin post-function, please remove the legacy field
Automatically converted legacy configuration field "functions" to the new field "access" in plugin post-function
There was a problem hiding this comment.
We should halt the conversion and show the error. Otherwise, the error output would get mixed with other information printed. It would be hard to spot the error as the file size increases and there's too much info on the screen and a non-zero exit code won't give any feedback to our users to check for the printed warnings..
Shall I modify the function signature and return error instead?
Yes.
There was a problem hiding this comment.
Makes sense, will update.
75311be to
f743756
Compare
Summary
Referring to https://developer.konghq.com/gateway/upgrade/lts-upgrade-28-34/, if the 2.8 config has both
functions(deprecated) andaccesskeys in the plugin config, we will modify logic to replace the legacy key with new key.New approach:
How 2.8 used to work with
functionsandaccessBased on https://legacy-gateway-2-8--kongdocs.netlify.app/hub/kong-inc/post-function/how-to/phases/ - the fields
functionsandaccessrefer to the different phases in which we can configure the plugin to execute.In kong 3.0,
functionswas removed, andaccessphase was to be used instead.Even in 2.8 -
functionsandaccessare treated as mutually exclusive - sync fails if both are present in config and are non-empty.Fixes #1933