Kong / deck

decK: Configuration management and drift detection for Kong
https://docs.konghq.com/deck/overview
Apache License 2.0
445 stars 130 forks source link

deck file render removes tags of config_group scoped plugins #1417

Open mheap opened 1 month ago

mheap commented 1 month ago

Problem Statement:

When using deck file render using file which contains consumer_group scoped plugins which have tags defined, the output no longer has tags for those plugins.

Problem Analysis:

For some reason, the deck file render command does not keep tags on consumer_grpup scoped plugins kong config db_export produces a declarative config with tags on consumer_group scoped plugins so there does not seem to be a limitation with the declarative config that would prevent the tags to be created

Steps to Reproduce:

Create kong-rendered.json using this command:

deck file render kong-common-consumer-groups.yaml kong-plugin.yaml kong-service.yaml -o kong-rendered.json --format json
# kong-service.yaml
_format_version: "3.0"
services:
- connect_timeout: 60000
  enabled: true
  host: httpbin.org
  name: customerinfo-v3
  path: /anything
  port: 80
  protocol: http
  read_timeout: 60000
  retries: 5
  tags:
  - customerinfo-v3
  - ' manual'
  write_timeout: 60000
# kong-plugin.yaml
_format_version: "3.0"
_transform: true

# global plugins
plugins:
# global, tags remains
- name: request-transformer
  tags:
  - manual
  - global
  - kong-common-plugin-request-transformer
  config:
    add:
      headers:
      - Global:Demo
# per service, tags remain
- name: request-transformer #request-transformer-advanced
  service: customerinfo-v3
  tags:
  - customerinfo-v3
  - manual
  - kong-common-plugin-request-transformer
  config:
    add:
      headers:
      - Service:Demo

# per consumer_group, TAGS LOST in deck render
- name: request-transformer #request-transformer-advanced
  consumer_group: Silver
  #service: customerinfo-v3
  tags:
  - Silver
  - manual
  - kong-common-plugin-request-transformer
  config:
    add:
      headers:
      - CG-Silver:Demo

# per consumer_group, TAGS LOST in deck render
- name: request-transformer #request-transformer-advanced
  consumer_group: Bronze
  tags:
  - Bronze
  - manual
  - kong-common-plugin-request-transformer
  config:
    add:
      headers:
      - CG-Bronze:Demo

# per consumer_group, TAGS LOST in deck render
- name: request-transformer #request-transformer-advanced
  consumer_group: Gold
  tags:
  - Gold
  - manual
  - kong-common-plugin-request-transformer
  config:
    add:
      headers:
      - CG-Gold:Demo
# kong-common-consumer-groups.yaml
_format_version: "3.0"
_transform: true
consumer_groups:
- name: Gold
  tags:
  - ConsumerGroupGold
  - ConsumerGroup
  - Gold
- name: Silver
  tags:
  - ConsumerGroupSilver
  - ConsumerGroup
  - Silver
- name: Bronze
  tags:
  - ConsumerGroupBronze
  - ConsumerGroup
  - Bronze

Check the file to see that the consumer_group scoped plugins do not have the tags as defined in kong-plugin.yaml