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

Fix exceptions with --yaml in create/update #49

Merged
merged 1 commit into from
Mar 23, 2022
Merged
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
14 changes: 10 additions & 4 deletions src/containerapp/azext_containerapp/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,14 @@ def _add_or_update_tags(containerapp_def, tags):


def _object_to_dict(obj):
import json
return json.loads(json.dumps(obj, default=lambda o: o.__dict__))
import json, datetime

def default_handler(x):
if isinstance(x, datetime.datetime):
return x.isoformat()
return x.__dict__

return json.loads(json.dumps(obj, default=default_handler))


def _to_camel_case(snake_str):
Expand Down Expand Up @@ -499,10 +505,10 @@ def _remove_dapr_readonly_attributes(daprcomponent_def):

def update_nested_dictionary(orig_dict, new_dict):
# Recursively update a nested dictionary. If the value is a list, replace the old list with new list
import collections
from collections.abc import Mapping

for key, val in new_dict.items():
if isinstance(val, collections.Mapping):
if isinstance(val, Mapping):
tmp = update_nested_dictionary(orig_dict.get(key, {}), val)
orig_dict[key] = tmp
elif isinstance(val, list):
Expand Down