Skip to content
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

[Containerapp] az containerapp create: Fix BadRequest Error about clientType with --bind #7045

Merged
merged 5 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/containerapp/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Release History
===============
upcoming
++++++
* 'az containerapp create': Fix BadRequest Error about the clientType with --bind
* 'az containerapp update': Fix bug for --min-replicas is not set when the value is 0

0.3.45
Expand Down
3 changes: 2 additions & 1 deletion src/containerapp/azext_containerapp/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ def process_service(cmd, resource_list, service_name, arg_dict, subscription_id,
service_bind = {
"serviceId": containerapp_def["id"],
"name": binding_name,
"clientType": arg_dict.get("clientType")
}
if arg_dict.get("clientType"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then how can customer clear clilent type?

Copy link
Contributor Author

@Greedygre Greedygre Nov 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the Cx want to clean the clientType, input clientType=none.

service_bind["clientType"] = arg_dict.get("clientType")
if customized_keys:
service_bind["customizedKeys"] = customized_keys
service_bindings_def_list.append(service_bind)
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,63 @@ def test_containerapp_up_dapr_e2e(self, resource_group):

class ContainerappServiceBindingTests(ScenarioTest):

@AllowLargeResponse(8192)
@ResourceGroupPreparer(location="eastus2")
def test_containerapp_dev_service_binding_none_client_type(self, resource_group):
self.cmd('configure --defaults location={}'.format(TEST_LOCATION))
ca_name = self.create_random_name(prefix='containerapp1', length=24)
redis_ca_name = 'redis'
postgres_ca_name = 'postgres'
kafka_ca_name = 'kafka'

env_id = prepare_containerapp_env_for_app_e2e_tests(self)
env_rg = parse_resource_id(env_id).get('resource_group')
env_name = parse_resource_id(env_id).get('name')

self.cmd('containerapp service redis create -g {} -n {} --environment {}'.format(env_rg, redis_ca_name, env_name), checks=[
JMESPathCheck('properties.provisioningState', "Succeeded")
])

self.cmd('containerapp service postgres create -g {} -n {} --environment {}'.format(env_rg, postgres_ca_name, env_name), checks=[
JMESPathCheck('properties.provisioningState', "Succeeded")
])
self.cmd('containerapp service kafka create -g {} -n {} --environment {}'.format(env_rg, kafka_ca_name, env_name), checks=[
JMESPathCheck('properties.provisioningState', "Succeeded")
])

self.cmd(
'containerapp create -n {} -g {} --environment {} --bind {},clientType=dotnet,resourcegroup={} {},clientType=none,resourcegroup={}'.format(
ca_name, resource_group, env_id, redis_ca_name, env_rg, postgres_ca_name, env_rg), expect_failure=False, checks=[
JMESPathCheck('properties.provisioningState', "Succeeded"),
JMESPathCheck('length(properties.template.serviceBinds)', 2),
JMESPathCheck('properties.template.serviceBinds[0].name', redis_ca_name),
JMESPathCheck('properties.template.serviceBinds[0].clientType', "dotnet"),
JMESPathCheck('properties.template.serviceBinds[1].name', postgres_ca_name),
JMESPathCheck('properties.template.serviceBinds[1].clientType', "none"),
])

# test clean clientType
self.cmd(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please also add test for update related scenario

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

'containerapp update -n {} -g {} --bind {},clientType=none,resourcegroup={}'.format(
ca_name, resource_group, redis_ca_name, env_rg), expect_failure=False, checks=[
JMESPathCheck('properties.provisioningState', "Succeeded"),
JMESPathCheck('length(properties.template.serviceBinds)', 2),
JMESPathCheck('properties.template.serviceBinds[0].name', redis_ca_name),
JMESPathCheck('properties.template.serviceBinds[0].clientType', "none"),
JMESPathCheck('properties.template.serviceBinds[1].name', postgres_ca_name),
JMESPathCheck('properties.template.serviceBinds[1].clientType', "none"),
])

self.cmd(
'containerapp create -n {} -g {} --environment {} --bind {},resourcegroup={}'.format(
ca_name, resource_group, env_id, kafka_ca_name, env_rg), expect_failure=False,
checks=[
JMESPathCheck('properties.provisioningState', "Succeeded"),
JMESPathCheck('length(properties.template.serviceBinds)', 1),
JMESPathCheck('properties.template.serviceBinds[0].name', kafka_ca_name),
JMESPathCheck('properties.template.serviceBinds[0].clientType', "none"),
])

@AllowLargeResponse(8192)
@ResourceGroupPreparer(location="eastus2")
def test_containerapp_dev_service_binding_customized_keys_yaml_e2e(self, resource_group):
Expand Down