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: don't overwrite fields set to empty arrays when default exists #374

Merged
merged 2 commits into from
Oct 17, 2023

Commits on Oct 17, 2023

  1. fix: don't overwrite fields set to empty arrays when default exists

    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.
    GGabriele committed Oct 17, 2023
    Configuration menu
    Copy the full SHA
    04f9441 View commit details
    Browse the repository at this point in the history
  2. addressing comments

    GGabriele committed Oct 17, 2023
    Configuration menu
    Copy the full SHA
    1457275 View commit details
    Browse the repository at this point in the history