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} raise ValidationError when value in --yaml is None #6693

Merged
merged 6 commits into from
Aug 28, 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 @@ -13,6 +13,7 @@ upcoming
* 'az containerapp list-usages': list usages in subscription
* 'az containerapp env list-usages': list usages in environment
* 'az containerapp update': --yaml support property additionalPortMappings for api-version 2023-05-02-preview
* 'az containerapp create/update': raise ValidationError when value in --yaml is None

0.3.37
++++++
Expand Down
2 changes: 2 additions & 0 deletions src/containerapp/azext_containerapp/_decorator_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def create_deserializer(models):


def process_loaded_yaml(yaml_containerapp):
if type(yaml_containerapp) != dict: # pylint: disable=unidiomatic-typecheck
raise ValidationError('Invalid YAML provided. Please see https://aka.ms/azure-container-apps-yaml for a valid containerapps YAML spec.')
if not yaml_containerapp.get('properties'):
yaml_containerapp['properties'] = {}

Expand Down
10 changes: 2 additions & 8 deletions src/containerapp/azext_containerapp/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@

# These properties should be under the "properties" attribute. Move the properties under "properties" attribute
def process_loaded_yaml(yaml_containerapp):
if type(yaml_containerapp) != dict: # pylint: disable=unidiomatic-typecheck
Greedygre marked this conversation as resolved.
Show resolved Hide resolved
raise ValidationError('Invalid YAML provided. Please see https://aka.ms/azure-container-apps-yaml for a valid containerapps YAML spec.')
if not yaml_containerapp.get('properties'):
yaml_containerapp['properties'] = {}

Expand Down Expand Up @@ -249,8 +251,6 @@ def delete_mariadb_service(cmd, service_name, resource_group_name, no_wait=False

def update_containerapp_yaml(cmd, name, resource_group_name, file_name, from_revision=None, no_wait=False):
yaml_containerapp = process_loaded_yaml(load_yaml_file(file_name))
if type(yaml_containerapp) != dict: # pylint: disable=unidiomatic-typecheck
raise ValidationError('Invalid YAML provided. Please see https://aka.ms/azure-container-apps-yaml for a valid containerapps YAML spec.')

if not yaml_containerapp.get('name'):
yaml_containerapp['name'] = name
Expand Down Expand Up @@ -339,8 +339,6 @@ def update_containerapp_yaml(cmd, name, resource_group_name, file_name, from_rev

def create_containerapp_yaml(cmd, name, resource_group_name, file_name, no_wait=False):
yaml_containerapp = process_loaded_yaml(load_yaml_file(file_name))
if type(yaml_containerapp) != dict: # pylint: disable=unidiomatic-typecheck
raise ValidationError('Invalid YAML provided. Please see https://aka.ms/azure-container-apps-yaml for a valid containerapps YAML spec.')

if not yaml_containerapp.get('name'):
yaml_containerapp['name'] = name
Expand Down Expand Up @@ -1286,8 +1284,6 @@ def update_containerappsjob_logic(cmd,

def create_containerappsjob_yaml(cmd, name, resource_group_name, file_name, no_wait=False):
yaml_containerappsjob = process_loaded_yaml(load_yaml_file(file_name))
if type(yaml_containerappsjob) != dict: # pylint: disable=unidiomatic-typecheck
raise ValidationError('Invalid YAML provided. Please see https://aka.ms/azure-container-apps-yaml for a valid YAML spec.')

if not yaml_containerappsjob.get('name'):
yaml_containerappsjob['name'] = name
Expand Down Expand Up @@ -1374,8 +1370,6 @@ def create_containerappsjob_yaml(cmd, name, resource_group_name, file_name, no_w

def update_containerappjob_yaml(cmd, name, resource_group_name, file_name, from_revision=None, no_wait=False):
yaml_containerappsjob = process_loaded_yaml(load_yaml_file(file_name))
if type(yaml_containerappsjob) != dict: # pylint: disable=unidiomatic-typecheck
raise ValidationError('Invalid YAML provided. Please see https://aka.ms/azure-container-apps-yaml for a valid YAML spec.')

if not yaml_containerappsjob.get('name'):
yaml_containerappsjob['name'] = name
Expand Down
Loading