Skip to content

Commit

Permalink
[Spring] Add new parameter for workload profile. (#6286)
Browse files Browse the repository at this point in the history
* Update mgmt sdk.

* [Spring] add parameter.

* Update version.

* revert back the version since still WIP.

* Add test cases.

---------

Co-authored-by: Raphael Yu <[email protected]>
  • Loading branch information
LGDoor and LGDoor authored May 17, 2023
1 parent 8fa8622 commit cc36ac9
Show file tree
Hide file tree
Showing 670 changed files with 71,588 additions and 46,226 deletions.
4 changes: 4 additions & 0 deletions src/spring/HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Release History
===============
1.12.0 (WIP)
---
* Add new parameter `--workload-profile` for `az spring app create` and `az spring app update`.

1.11.3
---
* Fix `az spring create` command with `--container-registry-server`, `--container-registry-username` and `--container-registry-password`.
Expand Down
2 changes: 1 addition & 1 deletion src/spring/azext_spring/_app_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# pylint: disable=wrong-import-order
from azure.cli.core.azclierror import FileOperationError, InvalidArgumentValueError
from .vendored_sdks.appplatform.v2023_03_01_preview import models
from .vendored_sdks.appplatform.v2023_05_01_preview import models
from azure.cli.core.util import get_file_json


Expand Down
2 changes: 2 additions & 0 deletions src/spring/azext_spring/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,8 @@ def prepare_logs_argument(c):
help="A space-separated string containing resource ids of certificates for client authentication. e.g: --client_auth_certs='id0 id1'. Use '' to clear existing certificates.")
c.argument('secrets', nargs='*', arg_group='StandardGen2',
help='A list of secret(s) for the app. Format "key[=value]" and separated by space.')
c.argument('workload_profile', arg_group='StandardGen2',
help='The workload profile used in the managed environment. Default to "Consumption".')

for scope in ['spring app update', 'spring app deployment create', 'spring app deploy', 'spring app create']:
with self.argument_context(scope) as c:
Expand Down
8 changes: 6 additions & 2 deletions src/spring/azext_spring/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ def app_create(cmd, client, resource_group, service, name,
scale_rule_http_concurrency=None,
scale_rule_metadata=None,
scale_rule_auth=None,
secrets=None):
secrets=None,
workload_profile=None):
'''app_create
Create app with an active deployment, deployment should be deployed with default banner
1. Create app
Expand Down Expand Up @@ -126,7 +127,8 @@ def app_create(cmd, client, resource_group, service, name,
'session_max_age': session_max_age,
'backend_protocol': backend_protocol,
'client_auth_certs': client_auth_certs,
'secrets': secrets
'secrets': secrets,
'workload_profile_name': workload_profile
}
create_deployment_kwargs = {
'cpu': cpu,
Expand Down Expand Up @@ -196,6 +198,7 @@ def app_update(cmd, client, resource_group, service, name,
session_max_age=None,
backend_protocol=None,
client_auth_certs=None,
workload_profile=None,
# deployment.source
runtime_version=None,
jvm_options=None,
Expand Down Expand Up @@ -263,6 +266,7 @@ def app_update(cmd, client, resource_group, service, name,
'backend_protocol': backend_protocol,
'client_auth_certs': client_auth_certs,
'secrets': secrets,
'workload_profile_name': workload_profile
}
if deployment is None:
updated_deployment_kwargs = {k: v for k, v in deployment_kwargs.items() if v}
Expand Down
10 changes: 9 additions & 1 deletion src/spring/azext_spring/tests/latest/test_asa_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,8 +604,12 @@ def test_app_i2a_tls(self):

self._execute('rg', 'asc', 'app', enable_ingress_to_app_tls=False, deployment=deployment)
resource = self.patch_app_resource
self.assertFalse(resource.properties.enable_end_to_end_tls)
self.assertFalse(resource.properties.enable_end_to_end_tls)

def test_update_workload_profile(self):
self._execute('rg', 'asc', 'app', workload_profile='w2')
resource = self.patch_app_resource
self.assertEqual('w2', resource.properties.workload_profile_name)

class TestAppCreate(BasicTest):
def __init__(self, methodName: str = ...):
Expand Down Expand Up @@ -736,6 +740,10 @@ def test_create_vnet_public_endpoint(self):
resource = self.put_app_resource
self.assertFalse(resource.properties.vnet_addons.public_endpoint)

def test_create_with_workload_profile(self):
self._execute('rg', 'asc', 'app', cpu='1', memory='1Gi', instance_count=1, workload_profile='w1')
resource = self.put_app_resource
self.assertEqual('w1', resource.properties.workload_profile_name)

class TestDeploymentCreate(BasicTest):
def __init__(self, methodName: str = ...):
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs):
if xml_desc.get("attr", False):
if xml_ns:
ET.register_namespace(xml_prefix, xml_ns)
xml_name = "{}{}".format(xml_ns, xml_name)
xml_name = "{{{}}}{}".format(xml_ns, xml_name)
serialized.set(xml_name, new_attr) # type: ignore
continue
if xml_desc.get("text", False):
Expand Down Expand Up @@ -1273,7 +1273,7 @@ def _extract_name_from_internal_type(internal_type):
xml_name = internal_type_xml_map.get("name", internal_type.__name__)
xml_ns = internal_type_xml_map.get("ns", None)
if xml_ns:
xml_name = "{}{}".format(xml_ns, xml_name)
xml_name = "{{{}}}{}".format(xml_ns, xml_name)
return xml_name


Expand All @@ -1297,7 +1297,7 @@ def xml_key_extractor(attr, attr_desc, data):
# Integrate namespace if necessary
xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None))
if xml_ns:
xml_name = "{}{}".format(xml_ns, xml_name)
xml_name = "{{{}}}{}".format(xml_ns, xml_name)

# If it's an attribute, that's simple
if xml_desc.get("attr", False):
Expand Down
Loading

0 comments on commit cc36ac9

Please sign in to comment.