-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
Fixes #24575 This upgrade involves a workaround for a grammar conflict introduced in [this PR](https://github.com/antonmedv/expr/pull/382/files). `pkg/stanza` previously added a custom function to the syntax called `env()`, which allows users to fetch values from OS environment variables. The latest version of the `expr` module introduced its own keyword `env`, but the meaning and usage were different. Still, the overlap was enough to cause failures in the compilation and rendering of expressions. The new syntax was introduced as a [Membership Operator](https://expr.medv.io/docs/Language-Definition#membership-operator), which means that the proper way to use it is with square brackets, `env[]`. This resulted in our custom `env()` syntax being flagged as invalid. More importantly, the meaning of the new `env[]` is not the same. While we use `env()` to lookup values from the OS environment, `env[]` is meant to pull values from an in-memory map. This map allows for customizations of the syntax, such as those that allow users to reference "body" or "attributes" within an expression, but it does not contain OS environment variables. Therefore, accessing it with the new syntax is of limited value to users. The solution used here is a [Patch](https://github.com/antonmedv/expr/blob/d2100ece96affe6766d97e2cf0e4ca4d145f0d30/expr.go#L98) option which allows us to inspect and modify elements of the grammar as an expression is being compiled. Fortunately, `env()` is understood to be a function call, while `env[]` is otherwise. This makes it possible to detect usage of our custom syntax and rename the function internally without any impact to the user. The PR also standardizes all uses of `expr.Compile` within `pkg/stanza` to ensure they are using the new patch option.
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.