Skip to content

Commit

Permalink
feat: 🎸 Add tier validator
Browse files Browse the repository at this point in the history
  • Loading branch information
yuwzho committed Aug 11, 2021
1 parent 2066376 commit c13404a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/spring-cloud/azext_spring_cloud/_util_enterprise.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ def is_enterprise_tier(cmd, resource_group, name):
return resource.sku.name == 'E0'

def get_client(cmd):
return get_mgmt_service_client(cmd.cli_ctx, AppPlatformManagementClient)
return get_mgmt_service_client(cmd.cli_ctx, AppPlatformManagementClient)
12 changes: 12 additions & 0 deletions src/spring-cloud/azext_spring_cloud/_validators_enterprise.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,22 @@
from ._resource_quantity import (
validate_cpu as validate_and_normalize_cpu,
validate_memory as validate_and_normalize_memory)
from ._util_enterprise import (
is_enterprise_tier
)


logger = get_logger(__name__)

def only_support_enterprise(cmd, namespace):
if namespace.resource_group and namespace.service and not is_enterprise_tier(cmd, namespace.resource_group, namespace.service):
raise CLIError("'{}' only supports for Enterprise tier Spring instance.".format(namespace.command))


def not_support_enterprise(cmd, namespace):
if namespace.resource_group and namespace.service and is_enterprise_tier(cmd, namespace.resource_group, namespace.service):
raise CLIError("'{}' doesn't support for Enterprise tier Spring instance.".format(namespace.command))


def validate_cpu(namespace):
namespace.cpu = validate_and_normalize_cpu(namespace.cpu)
Expand Down

0 comments on commit c13404a

Please sign in to comment.