zalando / skipper

An HTTP router and reverse proxy for service composition, including use cases like Kubernetes Ingress
https://opensource.zalando.com/skipper/
Other
3.05k stars 345 forks source link

Named arguments in eskip #3037

Open boopathi opened 2 months ago

boopathi commented 2 months ago

Is your feature request related to a problem? Please describe. The eskip file format includes only positional arguments. The eskip file format is used in places such as configuration files, web based editors, editors like vscode, and so on. It is often unintuitive to edit a filter / predicate arguments as we constantly refer to the documentation of the filter in different places - skipper docs for internal ones, other docs for custom ones. Matching filter signature manually is often painful, especially if there are multiple arguments.

Adding editor support (to show filter signature inline) to all places where eskip file format is used is complex and sometimes impossible (for example yaml configuration files). Instead, it would be beneficial to add named arguments to the eskip language directly.

Describe the solution you would like Support for named arguments syntax in predicates and filters. For example,

Path("foo")
  -> customFilter(a = 1, b = "str")
  -> otherFilter(foo = "bar", bar = "baz")

This way, we also eliminate the order in which the arguments appear.

Would you like to work on it? Yes if I find time

AlexanderYastrebov commented 2 months ago

Hello, for custom filters you may use flow style yaml and parse arguments yourself, see example https://github.com/zalando/skipper/pull/3020

jwtMetrics("{issuers: ['https://example.com', 'https://example.org'], optOutAnnotations: [oauth.disabled]}")

Of course this will not enable editor support. Maybe for editor support we can prepare machine-readable format of https://github.com/zalando/skipper/blob/master/docs/reference/filters.md

AlexanderYastrebov commented 2 months ago

For named arguments we would need to support another style of filter constructor https://github.com/zalando/skipper/blob/708e97af1d1e1511d7bc7803e1b2a0d5599df52b/filters/filters.go#L180-L190 as well as maybe change eskip Predicate/Filter interfaces https://github.com/zalando/skipper/blob/708e97af1d1e1511d7bc7803e1b2a0d5599df52b/eskip/eskip.go#L233-L262

Before we invest into this we need to understand how named arguments will help with outlined usecases, specifically given that

Adding editor support (to show filter signature inline) to all places where eskip file format is used is complex and sometimes impossible (for example yaml configuration files). Instead, it would be beneficial to add named arguments to the eskip language directly.

I think one would need to consult documentation anyway for parameter names.