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

Lower case acr names #112

Merged
merged 3 commits into from
Oct 9, 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
13 changes: 13 additions & 0 deletions src/aosm/azext_aosm/_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,19 @@ class CNFImageConfig:
source_registry_namespace: str = ""
source_local_docker_image: str = ""

def __post_init__(self):
"""
Ensure that all config is lower case.

ACR names can be uppercase but the login server is always lower case and docker
and az acr import commands require lower case. Might as well do the namespace
and docker image too although much less likely that the user has accidentally
pasted these with upper case.
"""
self.source_registry = self.source_registry.lower()
self.source_registry_namespace = self.source_registry_namespace.lower()
self.source_local_docker_image = self.source_local_docker_image.lower()

@classmethod
def helptext(cls) -> "CNFImageConfig":
"""
Expand Down
32 changes: 13 additions & 19 deletions src/aosm/azext_aosm/generate_nfd/cnf_nfd_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -731,24 +731,11 @@ def _replace_values_with_deploy_params(
"""
logger.debug("Replacing values with deploy parameters")
final_values_mapping_dict: Dict[Any, Any] = {}
for k, v in values_yaml_dict.items():
for k, v in values_yaml_dict.items(): # pylint: disable=too-many-nested-blocks
# if value is a string and contains deployParameters.
logger.debug("Processing key %s", k)
param_name = k if param_prefix is None else f"{param_prefix}_{k}"
if isinstance(v, (str, int, bool)):
# Replace the parameter with {deploymentParameter.keyname}
if self.interactive:
# Interactive mode. Prompt user to include or exclude parameters
# This requires the enter key after the y/n input which isn't ideal
if not input_ack("y", f"Expose parameter {param_name}? y/n "):
logger.debug("Excluding parameter %s", param_name)
final_values_mapping_dict.update({k: v})
continue
replacement_value = f"{{deployParameters.{param_name}}}"

# add the schema for k (from the big schema) to the (smaller) schema
final_values_mapping_dict.update({k: replacement_value})
elif isinstance(v, dict):
if isinstance(v, dict):
final_values_mapping_dict[k] = self._replace_values_with_deploy_params(
v, param_name
)
Expand All @@ -764,18 +751,25 @@ def _replace_values_with_deploy_params(
final_values_mapping_dict[k].append(
self._replace_values_with_deploy_params(item, param_name)
)
elif isinstance(item, (str, int, bool)) or not v:
elif isinstance(item, (str, int, bool)) or not item:
if self.interactive:
if not input_ack(
"y", f"Expose parameter {param_name}? y/n "
):
logger.debug("Excluding parameter %s", param_name)
final_values_mapping_dict[k].append(item)
continue
replacement_value = f"{{deployParameters.{param_name}}}"
final_values_mapping_dict[k].append(replacement_value)
else:
raise ValueError(
f"Found an unexpected type {type(item)} of key {k} in "
"values.yaml, cannot generate values mapping file."
)
elif not v:
# V is blank so we don't know what type it is. Assuming it is an
# empty string (but do this after checking for dict and list)
elif isinstance(v, (str, int, bool)) or not v:
# Replace the parameter with {deploymentParameter.keyname}
# If v is blank we don't know what type it is. Assuming it is an
# empty string (but do this after checking for dict and list)
if self.interactive:
# Interactive mode. Prompt user to include or exclude parameters
# This requires the enter key after the y/n input which isn't ideal
Expand Down