-
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: don't overwrite fields set to empty arrays when default exists #374
Conversation
This commit fixes a bug preventing users to set fields to emtpy arrays when a default for those fields exist. For example, imagine we have an `openid-connect` plugin configured via the UI having the `login_tokens` set to an empty array (note: this field has a default value of `["id_token"]`: ``` $ http :8001/plugins/$id | jq .config.login_tokens [] ``` If we do a `deck dump`, the configuration will be reflected into a local state file: ``` $ deck dump --yes $ cat kong.yaml | grep login_tokens login_tokens: [] ``` But, if we now run `deck diff` we see that decK will detect a difference because of the `login_tokens` field's default value: ``` $ deck diff updating plugin openid-connect (global) { "config": { "anonymous": null, ... ... "login_redirect_mode": "fragment", "login_redirect_uri": null, "login_tokens": [ + "id_token" ], "logout_methods": [ "POST", "DELETE" ], ... ... } Summary: Created: 0 Updated: 1 Deleted: 0 ``` This commit corrects this defect by allowing decK to set empty arrays when default values exist for a given field.
Codecov ReportAll modified lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #374 +/- ##
==========================================
- Coverage 53.06% 53.05% -0.01%
==========================================
Files 69 69
Lines 5201 5200 -1
==========================================
- Hits 2760 2759 -1
Misses 1857 1857
Partials 584 584
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.
Some nits, but overall 👍
I believe we want to add a changelog entry for this, right?
This commit fixes a bug preventing users to set fields to emtpy arrays when a default for those fields exist. For example, imagine we have an
openid-connect
plugin configured via the UI having thelogin_tokens
set to an empty array (note: this field has a default value of["id_token"]
:If we do a
deck dump
, the configuration will be reflected into a local state file:But, if we now run
deck diff
we see that decK will detect a difference because of thelogin_tokens
field's default value:This commit corrects this defect by allowing decK to set empty arrays when default values exist for a given field.