Skip to content

lua: allow setting complex values in dynamicMetadata#8306

Merged
dio merged 3 commits intoenvoyproxy:masterfrom
vmg:vmg/lua-met
Sep 30, 2019
Merged

lua: allow setting complex values in dynamicMetadata#8306
dio merged 3 commits intoenvoyproxy:masterfrom
vmg:vmg/lua-met

Conversation

@vmg
Copy link
Copy Markdown

@vmg vmg commented Sep 20, 2019

Description: This PR fixes a small TODO left by @dio: Allow to set dynamic metadata using a table. in the Lua API. Although the get function will convert any Protobuf::Value into its corresponding Lua type, the reverse set function would only allow plain strings to be passed as metadata.

The code turns out to be rather straightforward. The most controversial bit is the heuristic to detect whether a Lua table should be converted to a Protobuf Struct or ListValue. This heuristic is the one that most Lua JSON implementations use to decide whether a table is serialized as a JSON map or array.

Risk Level: Low
Testing: Unit tests for complex Lua structures & failure cases have been added
Docs Changes: The lua_filter.rst documentation has been updated to point out that other values besides strings can be passed as metadata.
Release Notes: Updated

cc @gorzell

Signed-off-by: Vicent Marti vmg@strn.cat

Signed-off-by: Vicent Marti <vmg@strn.cat>
@stale
Copy link
Copy Markdown

stale bot commented Sep 27, 2019

This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot added the stale stalebot believes this issue/PR has not been touched recently label Sep 27, 2019
@dio
Copy link
Copy Markdown
Member

dio commented Sep 30, 2019

@vmg Looks good, can you merge master?

@stale stale bot removed the stale stalebot believes this issue/PR has not been touched recently label Sep 30, 2019
Copy link
Copy Markdown
Member

@dio dio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome. Just a couple of nits and most of it are docs improvement! Thanks, @vmg!

(we also need you to merge master on this, since the CI seems stuck).

vmg added 2 commits September 30, 2019 01:01
Signed-off-by: Vicent Marti <vmg@strn.cat>
Signed-off-by: Vicent Marti <vmg@strn.cat>
@vmg
Copy link
Copy Markdown
Author

vmg commented Sep 30, 2019

@dio: fixed all your comments and merged master.

Copy link
Copy Markdown
Member

@dio dio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work! Thanks!

@vmg
Copy link
Copy Markdown
Author

vmg commented Sep 30, 2019

🙇 Thank you so much!

@dio dio merged commit 3a4e276 into envoyproxy:master Sep 30, 2019
danzh2010 pushed a commit to danzh2010/envoy that referenced this pull request Oct 4, 2019
Description: This PR fixes a small TODO left by @dio: `Allow to set dynamic metadata using a table.` in the Lua API. Although the `get` function will convert any `Protobuf::Value` into its corresponding Lua type, the reverse `set` function would only allow plain strings to be passed as metadata.

The code turns out to be rather straightforward. The most controversial bit is the heuristic to detect whether a Lua table should be converted to a Protobuf `Struct` or `ListValue`. This heuristic is the one that most Lua JSON implementations use to decide whether a table is serialized as a JSON map or array.

Risk Level: Low
Testing: Unit tests for complex Lua structures & failure cases have been added
Docs Changes: The `lua_filter.rst` documentation has been updated to point out that other values besides strings can be passed as metadata.
Release Notes: Updated

Signed-off-by: Vicent Marti <vmg@strn.cat>
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.

2 participants