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

Template Parameters Bug #156

Merged
merged 2 commits into from
Mar 11, 2024
Merged
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
16 changes: 14 additions & 2 deletions src/aosm/azext_aosm/inputs/vhd_file_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from typing import Any, Dict, Optional

from knack.log import get_logger

from azext_aosm.common.utils import snake_case_to_camel_case
from azext_aosm.common.constants import BASE_SCHEMA
from azext_aosm.inputs.base_input import BaseInput

Expand Down Expand Up @@ -51,7 +51,8 @@ def get_defaults(self) -> Dict[str, Any]:
:rtype: Dict[str, Any]
"""
logger.info("Getting default values for VHD file input")
default_config = self.default_config or {}
formatted_default_config = self._format_default_config()
default_config = formatted_default_config or {}
logger.debug(
"Default values for VHD file Input: %s",
json.dumps(default_config, indent=4),
Expand Down Expand Up @@ -82,3 +83,14 @@ def get_schema(self) -> Dict[str, Any]:

logger.debug("Schema for VHD file input: %s", json.dumps(schema, indent=4))
return copy.deepcopy(schema)

def _format_default_config(self):
print(self.default_config)
formatted_config = {}
for (key, value) in self.default_config.items():
# This must be an integer, but is a string in the input file
if key == "image_disk_size_GB":
value = int(value)
formatted_key = snake_case_to_camel_case(key)
formatted_config[formatted_key] = value
return formatted_config
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it not easier to do all this in the init(), perhaps like this:

         if "image_disk_size_GB" in self.default_config:
             self.default_config["imageDiskSizeGB"] = int(self.default_config["image_disk_size_GB"])
             del self.default_config["image_disk_size_GB"]

(and if we know we always have image_disk_size_GB, then we don't need the if statement)
(and if it doesn't matter if the old value sticks around, don't need the del either)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we dont always have disk size + i like having a separate dict returned so we dont have to worry about deleting things

Loading