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

Added new dapr component params. #150

Merged
merged 3 commits into from
Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 5 additions & 1 deletion src/containerapp/azext_containerapp/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@
"enabled": False,
"appId": None,
"appProtocol": None,
"appPort": None
"appPort": None,
"httpReadBufferSize": None,
"httpMaxRequestSize": None,
"logLevel": None,
"enableApiLogging": None
}

EnvironmentVar = {
Expand Down
4 changes: 4 additions & 0 deletions src/containerapp/azext_containerapp/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ def load_arguments(self, _):
c.argument('dapr_app_port', type=int, help="The port Dapr uses to talk to the application.")
c.argument('dapr_app_id', help="The Dapr application identifier.")
c.argument('dapr_app_protocol', arg_type=get_enum_type(['http', 'grpc']), help="The protocol Dapr uses to talk to the application.")
c.argument('dapr_http_read_buffer_size', options_list=['--dapr-http-read-buffer-size', '-dhrbs'], type=int, help="Dapr max size of http header read buffer in KB to handle when sending multi-KB headers..")
c.argument('dapr_http_max_request_size', options_list=['--dapr-http-max-request-size', '-dhmrs'], type=int, help="Increasing max size of request body http and grpc servers parameter in MB to handle uploading of big files.")
c.argument('dapr_log_level', arg_type=get_enum_type(["info", "debug", "warn", "error"]), help="Sets the log level for the Dapr sidecar.")
c.argument('dapr_enable_api_logging', options_list=['--dapr-enable-api-logging', '-dal'], help="Enables API logging for the Dapr sidecar.")

# Configuration
with self.argument_context('containerapp', arg_group='Configuration') as c:
Expand Down
30 changes: 29 additions & 1 deletion src/containerapp/azext_containerapp/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,10 @@ def create_containerapp(cmd,
dapr_app_port=None,
dapr_app_id=None,
dapr_app_protocol=None,
dapr_http_read_buffer_size=None,
dapr_http_max_request_size=None,
dapr_log_level=None,
dapr_enable_api_logging=False,
revision_suffix=None,
startup_command=None,
args=None,
Expand Down Expand Up @@ -412,6 +416,10 @@ def create_containerapp(cmd,
dapr_def["appId"] = dapr_app_id
dapr_def["appPort"] = dapr_app_port
dapr_def["appProtocol"] = dapr_app_protocol
dapr_def["httpReadBufferSize"] = dapr_http_read_buffer_size
dapr_def["httpMaxRequestSize"] = dapr_http_max_request_size
dapr_def["logLevel"] = dapr_log_level
dapr_def["enableApiLogging"] = dapr_enable_api_logging

config_def = ConfigurationModel
config_def["secrets"] = secrets_def
Expand Down Expand Up @@ -2081,7 +2089,15 @@ def set_secrets(cmd, name, resource_group_name, secrets,
handle_raw_exception(e)


def enable_dapr(cmd, name, resource_group_name, dapr_app_id=None, dapr_app_port=None, dapr_app_protocol=None, no_wait=False):
def enable_dapr(cmd, name, resource_group_name,
dapr_app_id=None,
dapr_app_port=None,
dapr_app_protocol=None,
dapr_http_read_buffer_size=None,
dapr_http_max_request_size=None,
dapr_log_level=None,
dapr_enable_api_logging=False,
no_wait=False):
_validate_subscription_registered(cmd, CONTAINER_APPS_RP)

containerapp_def = None
Expand Down Expand Up @@ -2110,6 +2126,18 @@ def enable_dapr(cmd, name, resource_group_name, dapr_app_id=None, dapr_app_port=
if dapr_app_protocol:
containerapp_def['properties']['configuration']['dapr']['appProtocol'] = dapr_app_protocol

if dapr_http_read_buffer_size:
containerapp_def['properties']['configuration']['dapr']['httpReadBufferSize'] = dapr_http_read_buffer_size

if dapr_http_max_request_size:
containerapp_def['properties']['configuration']['dapr']['httpMaxRequestSize'] = dapr_http_max_request_size

if dapr_log_level:
containerapp_def['properties']['configuration']['dapr']['logLevel'] = dapr_log_level

if dapr_enable_api_logging:
containerapp_def['properties']['configuration']['dapr']['enableApiLogging'] = dapr_enable_api_logging

containerapp_def['properties']['configuration']['dapr']['enabled'] = True

try:
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -351,34 +351,59 @@ def test_containerapp_dapr_e2e(self, resource_group):

create_containerapp_env(self, env_name, resource_group)

self.cmd('containerapp create -g {} -n {} --environment {}'.format(resource_group, ca_name, env_name))
self.cmd('containerapp create -g {} -n {} --environment {} --dapr-app-id containerapp --dapr-app-port 800 --dapr-app-protocol grpc -dhmrs 4 -dhrbs 50 --dapr-log-level debug --enable-dapr'.format(resource_group, ca_name, env_name), checks=[
JMESPathCheck('properties.configuration.dapr.appId', "containerapp"),
JMESPathCheck('properties.configuration.dapr.appPort', 800),
JMESPathCheck('properties.configuration.dapr.appProtocol', "grpc"),
JMESPathCheck('properties.configuration.dapr.enabled', True),
JMESPathCheck('properties.configuration.dapr.httpReadBufferSize', 50),
JMESPathCheck('properties.configuration.dapr.httpMaxRequestSize', 4),
JMESPathCheck('properties.configuration.dapr.logLevel', "debug"),
JMESPathCheck('properties.configuration.dapr.enableApiLogging', False),
])

self.cmd('containerapp dapr enable -g {} -n {} --dapr-app-id containerapp1 --dapr-app-port 80 --dapr-app-protocol http'.format(resource_group, ca_name, env_name), checks=[
self.cmd('containerapp dapr enable -g {} -n {} --dapr-app-id containerapp1 --dapr-app-port 80 --dapr-app-protocol http -dal -dhmrs 6 -dhrbs 60 --dapr-log-level warn'.format(resource_group, ca_name, env_name), checks=[
JMESPathCheck('appId', "containerapp1"),
JMESPathCheck('appPort', 80),
JMESPathCheck('appProtocol', "http"),
JMESPathCheck('enabled', True),
JMESPathCheck('httpReadBufferSize', 60),
JMESPathCheck('httpMaxRequestSize', 6),
JMESPathCheck('logLevel', "warn"),
JMESPathCheck('enableApiLogging', True),
])

self.cmd('containerapp show -g {} -n {}'.format(resource_group, ca_name), checks=[
JMESPathCheck('properties.configuration.dapr.appId', "containerapp1"),
JMESPathCheck('properties.configuration.dapr.appPort', 80),
JMESPathCheck('properties.configuration.dapr.appProtocol', "http"),
JMESPathCheck('properties.configuration.dapr.enabled', True),
JMESPathCheck('properties.configuration.dapr.httpReadBufferSize', 60),
JMESPathCheck('properties.configuration.dapr.httpMaxRequestSize', 6),
JMESPathCheck('properties.configuration.dapr.logLevel', "warn"),
JMESPathCheck('properties.configuration.dapr.enableApiLogging', True),
])

self.cmd('containerapp dapr disable -g {} -n {}'.format(resource_group, ca_name, env_name), checks=[
JMESPathCheck('appId', "containerapp1"),
JMESPathCheck('appPort', 80),
JMESPathCheck('appProtocol', "http"),
JMESPathCheck('enabled', False),
JMESPathCheck('httpReadBufferSize', 60),
JMESPathCheck('httpMaxRequestSize', 6),
JMESPathCheck('logLevel', "warn"),
JMESPathCheck('enableApiLogging', True),
])

self.cmd('containerapp show -g {} -n {}'.format(resource_group, ca_name), checks=[
JMESPathCheck('properties.configuration.dapr.appId', "containerapp1"),
JMESPathCheck('properties.configuration.dapr.appPort', 80),
JMESPathCheck('properties.configuration.dapr.appProtocol', "http"),
JMESPathCheck('properties.configuration.dapr.enabled', False),
JMESPathCheck('properties.configuration.dapr.httpReadBufferSize', 60),
JMESPathCheck('properties.configuration.dapr.httpMaxRequestSize', 6),
JMESPathCheck('properties.configuration.dapr.logLevel', "warn"),
JMESPathCheck('properties.configuration.dapr.enableApiLogging', True),
])


Expand Down