-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add support for 0.5 core / 512 Mi resource requests for spring-cloud deployments #3486
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
5e76306
c611c89
0f938bd
79175df
10eefe4
cd93f0c
0068a06
20cfeb8
e3e2426
c7a0ca5
d2c6d9b
890817e
34612c6
97eb952
ff31a01
d762944
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 |
|---|---|---|
| @@ -1,49 +1,58 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
| from azure.cli.core.commands.client_factory import get_mgmt_service_client | ||
| from azure.cli.core.profiles import ResourceType | ||
| from .vendored_sdks.appplatform.v2020_07_01 import AppPlatformManagementClient | ||
| from .vendored_sdks.appplatform.v2020_11_01_preview import AppPlatformManagementClient as AppPlatformManagementClient_20201101preview | ||
|
|
||
|
|
||
| def cf_spring_cloud(cli_ctx, *_): | ||
| return get_mgmt_service_client(cli_ctx, AppPlatformManagementClient) | ||
|
|
||
|
|
||
| def cf_spring_cloud_20201101preview(cli_ctx, *_): | ||
| return get_mgmt_service_client(cli_ctx, AppPlatformManagementClient_20201101preview) | ||
|
|
||
|
|
||
| def cf_resource_groups(cli_ctx, subscription_id=None): | ||
| return get_mgmt_service_client(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES, | ||
| subscription_id=subscription_id).resource_groups | ||
|
|
||
|
|
||
| def cf_app_services(cli_ctx, *_): | ||
| return cf_spring_cloud(cli_ctx).services | ||
|
|
||
|
|
||
| def cf_apps(cli_ctx, *_): | ||
| return cf_spring_cloud(cli_ctx).apps | ||
|
|
||
|
|
||
| def cf_deployments(cli_ctx, *_): | ||
| return cf_spring_cloud(cli_ctx).deployments | ||
|
|
||
|
|
||
| def cf_bindings(cli_ctx, *_): | ||
| return cf_spring_cloud(cli_ctx).bindings | ||
|
|
||
|
|
||
| def cf_config_servers(cli_ctx, *_): | ||
| return cf_spring_cloud(cli_ctx).config_servers | ||
|
|
||
|
|
||
| def cf_certificates(cli_ctx, *_): | ||
| return cf_spring_cloud(cli_ctx).certificates | ||
|
|
||
|
|
||
| def cf_custom_domains(cli_ctx, *_): | ||
| return cf_spring_cloud(cli_ctx).custom_domains | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
| from azure.cli.core.commands.client_factory import get_mgmt_service_client | ||
| from azure.cli.core.profiles import ResourceType | ||
| from .vendored_sdks.appplatform.v2020_07_01 import AppPlatformManagementClient | ||
| from .vendored_sdks.appplatform.v2020_11_01_preview import ( | ||
| AppPlatformManagementClient as AppPlatformManagementClient_20201101preview | ||
| ) | ||
| from .vendored_sdks.appplatform.v2021_06_01_preview import ( | ||
| AppPlatformManagementClient as AppPlatformManagementClient_20210601preview | ||
| ) | ||
|
|
||
|
|
||
| def cf_spring_cloud(cli_ctx, *_): | ||
| return get_mgmt_service_client(cli_ctx, AppPlatformManagementClient) | ||
|
|
||
|
|
||
| def cf_spring_cloud_20201101preview(cli_ctx, *_): | ||
| return get_mgmt_service_client(cli_ctx, AppPlatformManagementClient_20201101preview) | ||
|
|
||
|
|
||
| def cf_spring_cloud_20210601preview(cli_ctx, *_): | ||
| return get_mgmt_service_client(cli_ctx, AppPlatformManagementClient_20210601preview) | ||
|
|
||
|
|
||
| def cf_resource_groups(cli_ctx, subscription_id=None): | ||
| return get_mgmt_service_client(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES, | ||
| subscription_id=subscription_id).resource_groups | ||
|
|
||
|
|
||
| def cf_app_services(cli_ctx, *_): | ||
| return cf_spring_cloud(cli_ctx).services | ||
|
|
||
|
|
||
| def cf_apps(cli_ctx, *_): | ||
| return cf_spring_cloud(cli_ctx).apps | ||
|
|
||
|
|
||
| def cf_deployments(cli_ctx, *_): | ||
| return cf_spring_cloud(cli_ctx).deployments | ||
|
|
||
|
|
||
| def cf_bindings(cli_ctx, *_): | ||
| return cf_spring_cloud(cli_ctx).bindings | ||
|
|
||
|
|
||
| def cf_config_servers(cli_ctx, *_): | ||
| return cf_spring_cloud(cli_ctx).config_servers | ||
|
|
||
|
|
||
| def cf_certificates(cli_ctx, *_): | ||
| return cf_spring_cloud(cli_ctx).certificates | ||
|
|
||
|
|
||
| def cf_custom_domains(cli_ctx, *_): | ||
| return cf_spring_cloud(cli_ctx).custom_domains |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
|
|
||
| import re | ||
| from knack.log import get_logger | ||
| from azure.cli.core.azclierror import InvalidArgumentValueError | ||
|
|
||
|
|
||
| logger = get_logger(__name__) | ||
|
|
||
|
|
||
| def validate_cpu(cpu): | ||
| ''' | ||
| CPU quantity should be either integer, or millis. Currently, 500m (aka 0.5) is the only allowed fractional value. | ||
| Note that 1 can be represented as 1000m. | ||
| ''' | ||
| if cpu is None: | ||
| return None | ||
|
|
||
| # some digit(s) followed by an optional m | ||
| if not re.match(r"^\d+m?$", cpu): | ||
| raise InvalidArgumentValueError("CPU quantity should be millis (500m) or integer (1, 2, ...)") | ||
|
|
||
| return cpu | ||
|
|
||
|
|
||
| def validate_memory(memory): | ||
| ''' | ||
| Memory quantity should be in gigabytes (Gi) or megabytes (Mi). Currently, the only allowed fractional gigabytes | ||
| quantity is 512Mi. Note that 1Gi can be specified with 1024Mi. | ||
|
|
||
| In the legacy extension, gigabytes is specified with integer. This will generate a warning now. | ||
| ''' | ||
| if memory is None: | ||
| return None | ||
|
|
||
| unified = memory | ||
| try: | ||
| # For backward compatibility, convert integer value to value with Gi unit | ||
| int(memory) | ||
| logger.warning("Memory quantity [--memory] should be specified with unit, such as 512Mi, 1Gi. " | ||
| "Support for integer quantity will be dropped in future release.") | ||
| unified = memory + "Gi" | ||
| except ValueError: | ||
| pass | ||
|
|
||
| # Some digit(s) followed by explicit unit (Mi or Gi) | ||
| if not re.match(r"^\d+[MG]i$", unified): | ||
|
Contributor
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. Could you add some explanation for the function of the regular expression?
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. We allow the user to specify the memory quantity with either The regular expression here add some client side validation for the user input, to restrict it to be some digits followed by |
||
| raise InvalidArgumentValueError("Memory quantity should be integer followed by unit (Mi/Gi)") | ||
|
|
||
| return unified | ||
Uh oh!
There was an error while loading. Please reload this page.