-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[Network] New Traffic Manager features #8188
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -737,6 +737,9 @@ def process_tm_endpoint_create_namespace(cmd, namespace): | |
| 'endpoint_location': '--endpoint-location', | ||
| 'geo_mapping': '--geo-mapping' | ||
| } | ||
| validate_subnet_ranges(namespace) | ||
| validate_custom_headers(namespace) | ||
|
|
||
| required_options = [] | ||
|
|
||
| # determine which options are required based on profile and routing method | ||
|
|
@@ -1280,6 +1283,72 @@ def validate_custom_error_pages(namespace): | |
| namespace.custom_error_pages = values | ||
|
|
||
|
|
||
| def validate_custom_headers(namespace): | ||
|
|
||
| if not namespace.monitor_custom_headers: | ||
| return | ||
|
|
||
| values = [] | ||
| for item in namespace.monitor_custom_headers: | ||
| try: | ||
| item_split = item.split('=', 1) | ||
| values.append({'name': item_split[0], 'value': item_split[1]}) | ||
| except IndexError: | ||
| raise CLIError('usage error: --custom-headers KEY=VALUE') | ||
|
|
||
| namespace.monitor_custom_headers = values | ||
|
|
||
|
|
||
| def validate_status_code_ranges(namespace): | ||
|
|
||
| if not namespace.status_code_ranges: | ||
| return | ||
|
|
||
| values = [] | ||
| for item in namespace.status_code_ranges: | ||
| item_split = item.split('-', 1) | ||
| usage_error = CLIError('usage error: --status-code-ranges VAL | --status-code-ranges MIN-MAX') | ||
|
Member
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. Are MIN and MAX inclusive or exclusive? As written, I assume inclusive.
Member
Author
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. The SDK is ambiguous on this, but yes I would assume inclusive. If you give a single value, it simply uses that value as both min and max. |
||
| try: | ||
| if len(item_split) == 1: | ||
| values.append({'min': int(item_split[0]), 'max': int(item_split[0])}) | ||
| elif len(item_split) == 2: | ||
| values.append({'min': int(item_split[0]), 'max': int(item_split[1])}) | ||
| else: | ||
| raise usage_error | ||
| except ValueError: | ||
| raise usage_error | ||
|
|
||
| namespace.status_code_ranges = values | ||
|
|
||
|
|
||
| def validate_subnet_ranges(namespace): | ||
|
|
||
| if not namespace.subnets: | ||
| return | ||
|
|
||
| values = [] | ||
| for item in namespace.subnets: | ||
| try: | ||
| item_split = item.split('-', 1) | ||
|
Member
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. Unlike above, I think subnet strings are constrained enough that I don't think it's a problem to just use a split. |
||
| if len(item_split) == 2: | ||
| values.append({'first': item_split[0], 'last': item_split[1]}) | ||
| continue | ||
| except ValueError: | ||
| pass | ||
|
|
||
| try: | ||
| item_split = item.split(':', 1) | ||
| if len(item_split) == 2: | ||
| values.append({'first': item_split[0], 'scope': item_split[1]}) | ||
| continue | ||
| except ValueError: | ||
| pass | ||
|
|
||
| values.append({'first': item}) | ||
|
|
||
| namespace.subnets = values | ||
|
|
||
|
|
||
| # pylint: disable=too-few-public-methods | ||
| class WafConfigExclusionAction(argparse.Action): | ||
| def __call__(self, parser, namespace, values, option_string=None): | ||
|
|
||
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.
If values are allowed to have escaped equals signs, then we'll need a more robust split strategy here. If it's always a base64 encoded or similar, then we're okay.
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.
This is the same strategy used that has always been used with
--tagsand we've not had complaints. I believe it is because of the simpler constraints on the key. If there's an equal sign in the value (escaped or not) it shouldn't be an issue.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.
Err, so I may not need to worry about this. If the headers have already been correctly URL encoded, any equal sign should just show up as
%3D. I imagine we're okay requiring properly encoded info here.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.
(sorry, looks like there was a race condition, and I didn't see your message when I was typing mine.)