Kong / docs.konghq.com

🦍 Source code for docs.konghq.com website.
https://docs.konghq.com
MIT License
195 stars 591 forks source link

Correct the Kubernetes example for Request Transformer Kong plugin #4509

Open anup-krai opened 1 year ago

anup-krai commented 1 year ago

Where is the problem?

https://docs.konghq.com/hub/kong-inc/request-transformer/

What happened?

The Example plugin configuration given for Kubernetes in Request Transformer plugin is little incorrect -

Docs link - https://docs.konghq.com/hub/kong-inc/request-transformer/

Field names like remove, rename, add etc should not repeat in yaml for headers, querystring or body

Current example -

apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
  name: request-transformer-example
config: 
  remove:
    headers:
    - x-toremove
    - x-another-one
  remove:
    querystring:
    - qs-old-name:qs-new-name
    - qs2-old-name:qs2-new-name
  remove:
    body:
    - formparam-toremove
    - formparam-another-one
  replace:
    body:
    - body-param1:new-value-1
    - body-param2:new-value-2
  rename:
    headers:
    - header-old-name:header-new-name
    - another-old-name:another-new-name
  rename:
    querystring:
    - qs-old-name:qs-new-name
    - qs2-old-name:qs2-new-name
  rename:
    body:
    - param-old:param-new
    - param2-old:param2-new
  add:
    headers:
    - x-new-header:value
    - x-another-header:something
  add:
    querystring:
    - new-param:some_value
    - another-param:some_value
  add:
    body:
    - new-form-param:some_value
    - another-form-param:some_value
plugin: request-transformer

Expected example -

apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
  name: request-transformer-example
config: 
  remove:
    headers:
    - x-toremove
    - x-another-one
    querystring:
    - qs-old-name:qs-new-name
    - qs2-old-name:qs2-new-name
    body:
    - formparam-toremove
    - formparam-another-one
  replace:
    body:
    - body-param1:new-value-1
    - body-param2:new-value-2
  rename:
    headers:
    - header-old-name:header-new-name
    - another-old-name:another-new-name
    querystring:
    - qs-old-name:qs-new-name
    - qs2-old-name:qs2-new-name
    body:
    - param-old:param-new
    - param2-old:param2-new
  add:
    headers:
    - x-new-header:value
    - x-another-header:something
    querystring:
    - new-param:some_value
    - another-param:some_value
    body:
    - new-form-param:some_value
    - another-form-param:some_value
plugin: request-transformer

Please let me know where can I update this change. I am not able to find it as these are picked from value_in_examples field under config.

What did you expect to happen?

The Kubernetes example needs to be corrected for this plugin.

Code of Conduct and Community Expectations

Guaris commented 1 year ago

Hey, the ability to do this was added in this PR https://github.com/Kong/docs.konghq.com/pull/4493/files

I can provide an example of what the syntax would look like tomorrow if you still want to tackle this task.