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: correctly fill plugins with arbitrary map fields #258

Merged
merged 3 commits into from
Jan 12, 2023

Conversation

GGabriele
Copy link
Collaborator

Kong plugin schemas support different type of fields, including maps. Moreover, these can either be arbitrary maps, or maps with their own subschema.

go-kong already supports well the second case, but it falls short with arbitrary maps. An example of arbitrary map field is the custom_fields_by_lua from the http-log plugin, which is defined as follows:

{
  "custom_fields_by_lua": {
    "keys": {
      "len_min": 1,
      "type": "string"
    },
    "type": "map",
    "values": {
      "len_min": 1,
      "type": "string"
    }
  }
}

This commit makes sure that go-kong is able to correctly handle such schemas as well.

@GGabriele GGabriele requested a review from a team as a code owner December 22, 2022 15:36
@GGabriele GGabriele force-pushed the fix/fill-config-for-arbitrary-map branch from 3e42cb8 to b5c669d Compare December 22, 2022 15:43
Kong plugin schemas support different type of fields,
including maps. Moreover, these can either be arbitrary
maps, or maps with their own subschema.

go-kong already supports well the second case, but it
falls short with arbitrary maps. An example of arbitrary
map field is the `custom_fields_by_lua` from the `http-log`
plugin, which is defined as follows:

```
{
  "custom_fields_by_lua": {
    "keys": {
      "len_min": 1,
      "type": "string"
    },
    "type": "map",
    "values": {
      "len_min": 1,
      "type": "string"
    }
  }
}
```

This commit makes sure that go-kong is able to correctly
handle such schemas as well.
@GGabriele GGabriele force-pushed the fix/fill-config-for-arbitrary-map branch from b5c669d to 6c81ce5 Compare December 22, 2022 17:04
@rainest rainest enabled auto-merge (squash) January 5, 2023 19:30
@codecov-commenter
Copy link

codecov-commenter commented Jan 5, 2023

Codecov Report

Base: 52.32% // Head: 52.43% // Increases project coverage by +0.11% 🎉

Coverage data is based on head (2f9ab6d) compared to base (669d55b).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #258      +/-   ##
==========================================
+ Coverage   52.32%   52.43%   +0.11%     
==========================================
  Files          51       51              
  Lines        4610     4621      +11     
==========================================
+ Hits         2412     2423      +11     
  Misses       1670     1670              
  Partials      528      528              
Flag Coverage Δ
2.1.4 35.29% <0.00%> (-1.67%) ⬇️
2.2.1.3 45.27% <0.00%> (-0.11%) ⬇️
2.2.2 35.29% <0.00%> (-1.67%) ⬇️
2.3.3 37.02% <71.42%> (+0.06%) ⬆️
2.3.3.4 45.27% <0.00%> (-0.11%) ⬇️
2.4.0 37.11% <100.00%> (+0.15%) ⬆️
2.4.1.3 45.27% <0.00%> (-0.11%) ⬇️
2.5.1 37.11% <100.00%> (+0.15%) ⬆️
2.5.1.2 45.27% <0.00%> (-0.11%) ⬇️
2.6.0 37.11% <100.00%> (+0.15%) ⬆️
2.6.0.2 45.27% <0.00%> (-0.11%) ⬇️
2.7.0 37.11% <100.00%> (+0.15%) ⬆️
2.7.0.0 46.95% <0.00%> (-0.12%) ⬇️
2.8.0 37.11% <100.00%> (+0.15%) ⬆️
2.8.2.2 46.95% <0.00%> (-0.12%) ⬇️
3.0.1 36.50% <100.00%> (+0.15%) ⬆️
3.0.1.0 47.45% <0.00%> (-0.12%) ⬇️
3.1.0 38.15% <100.00%> (+0.14%) ⬆️
3.1.0.0 49.10% <0.00%> (-0.12%) ⬇️
community 38.75% <100.00%> (+0.14%) ⬆️
enterprise 49.70% <0.00%> (-0.12%) ⬇️
integration 52.43% <100.00%> (+0.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
kong/utils.go 86.36% <100.00%> (+0.50%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@GGabriele
Copy link
Collaborator Author

@Kong/team-k8s this PR is approved (but merge is blocked) and decK is already using this code. Can someone take a look please?

@rainest rainest merged commit e0fcd03 into main Jan 12, 2023
@rainest rainest deleted the fix/fill-config-for-arbitrary-map branch January 12, 2023 21:02
@pmalek
Copy link
Member

pmalek commented Jan 12, 2023

@Kong/team-k8s this PR is approved (but merge is blocked) and decK is already using this code. Can someone take a look please?

Done :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants