-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
feat: allow to use environment variables for limit-count plugin settings #10607
Merged
monkeyDluffy6017
merged 11 commits into
apache:master
from
ikatlinsky:feat/add-env-vars-support-for-limit-count-plugin
Dec 18, 2023
Merged
Changes from 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4f7f55d
feat(limit-count): added support for environment variables for string…
ikatlinski f5bb533
chore(cleanup): remove redundant file
ikatlinski d685b8b
chore(docs): update limit-count docs with environment variables usage…
ikatlinski ce01c4d
fix(lint): applied correctl linting to test files
ikatlinski d073d8a
fix(typo): fix types in tests description
ikatlinski 3c2e146
fix: removed redis_usernmae from encrypted fields, fixed code style
ikatlinski 06e4aea
fix: revert encrypt_fields changes
ikatlinski 36ffede
fix: add empty lines for header in docs
ikatlinski a421800
Merge branch 'master' into feat/add-env-vars-support-for-limit-count-…
ikatlinski ec46abf
Merge branch 'master' into feat/add-env-vars-support-for-limit-count-…
ikatlinski 50cec33
chore: fix conflicats with master branch
ikatlinski 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 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
|
@@ -22,6 +22,8 @@ BEGIN { | |
$ENV{TEST_NGINX_USE_HUP} = 1; | ||
undef $ENV{TEST_NGINX_USE_STAP}; | ||
} | ||
|
||
$ENV{LIMIT_COUNT_KEY} = "remote_addr"; | ||
} | ||
|
||
use t::APISIX; | ||
|
@@ -89,3 +91,49 @@ remaining: 2 | |
remaining: 0 | ||
rejected | ||
rejected | ||
|
||
|
||
|
||
=== TEST 2: set route(id: 1) using environment variable for key | ||
--- config | ||
location /t { | ||
content_by_lua_block { | ||
local t = require("lib.test_admin").test | ||
local code, body = t('/apisix/admin/routes/1', | ||
ngx.HTTP_PUT, | ||
[[{ | ||
"methods": ["GET"], | ||
"plugins": { | ||
"limit-count": { | ||
"count": 2, | ||
"time_window": 60, | ||
"rejected_code": 503, | ||
"key": "$ENV://LIMIT_COUNT_KEY" | ||
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. ditto 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. same reasoning as above |
||
} | ||
}, | ||
"upstream": { | ||
"nodes": { | ||
"127.0.0.1:1980": 1 | ||
}, | ||
"type": "roundrobin" | ||
}, | ||
"uri": "/hello" | ||
}]] | ||
) | ||
|
||
if code >= 300 then | ||
ngx.status = code | ||
end | ||
ngx.say(body) | ||
} | ||
} | ||
--- response_body | ||
passed | ||
|
||
|
||
|
||
=== TEST 3: up the limit with environment variable for key | ||
--- pipelined_requests eval | ||
["GET /hello", "GET /hello", "GET /hello", "GET /hello"] | ||
--- error_code eval | ||
[200, 200, 503, 503] |
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.
I think this is not correct, please refer to https://github.com/apache/apisix/blob/master/apisix/plugins/kafka-proxy.lua#L36, and add a corresponding test case
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.
your are correct, that i am doing 2 different things in a single PR, let me ever this change