-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: adds support for nginx variables in service_name param #12187
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
Open
undying
wants to merge
14
commits into
apache:master
Choose a base branch
from
undying:upstreams_variable_support
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+24
−2
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
90b3c13
adds support of variables into upstream module
undying 9def4fb
move local upper from if
undying cfea8d8
linter fixes
undying 3b90fe2
Merge branch 'master' into upstreams_variable_support
undying ac76dd7
bump build
undying 2160c51
new line
undying e8e086c
Merge branch 'master' into upstreams_variable_support
undying 5a907fa
removes is_nginx_variable
undying ab7bc5d
Merge branch 'upstreams_variable_support' of github.com:undying/apisi…
undying 3a623bc
new line
undying 5b457df
up
undying b661517
check for empty string in service name
undying 5f19d54
newline
undying 7548cf8
use resolve_var in error message
undying File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -337,6 +337,24 @@ do | |
end | ||
end | ||
-- Resolve ngx.var in the given string | ||
-- @function core.utils.resolve_var | ||
-- @tparam string tpl The template string to resolve variables in | ||
-- @tparam table ctx The context table containing variables | ||
-- @tparam function escaper Optional function to escape resolved values | ||
-- @treturn string The resolved string | ||
-- @treturn string|nil Error message if any | ||
-- @treturn number Number of variables replaced | ||
-- @usage | ||
-- local utils = require("apisix.core.utils") | ||
-- | ||
-- -- Usage examples: | ||
-- local res = utils.resolve_var("$host", ctx.var) -- "example.com" | ||
-- local res = utils.resolve_var("${host}", ctx.var) -- "example.com" | ||
-- local res = utils.resolve_var("TMP_${VAR1}_${VAR2}", ctx.var) -- "TMP_value1_value2" | ||
-- local res = utils.resolve_var("\\$host", ctx.var) -- "$host" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have you already confirmed this? I mean, do the escaping. |
||
-- | ||
-- -- Usage in APISIX context: | ||
-- local service_name = utils.resolve_var(up_conf.service_name, api_ctx.var) | ||
Comment on lines
+356
to
+357
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove it and the IDE will tell us the reference without having to document it. |
||
_M.resolve_var = resolve_var | ||
|
||
|
||
|
@@ -461,5 +479,4 @@ function _M.check_tls_bool(fields, conf, plugin_name) | |
end | ||
end | ||
|
||
|
||
return _M |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these comments necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added comments from the approach in order to generate documentation for the methods later.
If there are no such plans, I can remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can keep it, but we need to make sure it's correct.