Skip to content

Commit

Permalink
Merge pull request Azure#23 from daniv-msft/harrli/lint-fix
Browse files Browse the repository at this point in the history
Addressed comment and fixed bug
  • Loading branch information
daniv-msft authored May 17, 2023
2 parents d2a892c + 7914e8e commit 5d15930
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/containerapp/azext_containerapp/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2053,7 +2053,7 @@ def parse_oryx_mariner_tag(tag: str) -> OryxMarinerRunImgTagProperty:
# "support": "lts"}
version_re = r"(\d+\.\d+(\.\d+)?).*?(cbl-mariner(\d+\.\d+))"
re_matches = re.findall(version_re, tag)
if re_matches.count == 0:
if len(re_matches) == 0:
tag_obj = None
else:
tag_obj = dict(fullTag=tag, version=SemVer.parse(re_matches[0][0]), framework=tag_split[2], marinerVersion=re_matches[0][2], architectures=None, support="lts")
Expand Down
26 changes: 13 additions & 13 deletions src/containerapp/azext_containerapp/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -4497,27 +4497,30 @@ def patch_list(cmd, resource_group_name=None, managed_env=None, show_all=False):
pack_exec_path = get_pack_exec_path()
if pack_exec_path is None:
return
print("\rListing container apps...", end="", flush=True)
logger.warning("Listing container apps...")
ca_list = list_containerapp(cmd, resource_group_name, managed_env)
imgs = []
if ca_list:
for ca in ca_list:
resource_group_name = re.search('/subscriptions/[^/]+/resourceGroups/([^/]+)/', ca["id"]).group(1)
managed_env_name = ca["properties"]["managedEnvironmentId"].split('/')[-1]
containers = ca["properties"]["template"]["containers"]
id_parts = parse_resource_id(ca["id"])
resource_group_name = id_parts.get('resource_group')
container_app_name = id_parts.get('name')
managed_env_id_parts = parse_resource_id(ca["properties"]["managedEnvironmentId"])
managed_env_name = managed_env_id_parts.get('name')
containers = safe_get(ca, "properties", "template", "containers")
for container in containers:
result = dict(
imageName=container["image"],
targetContainerName=container["name"],
targetContainerAppName=ca["name"],
targetContainerAppName=container_app_name,
targetContainerAppEnvironmentName=managed_env_name,
targetResourceGroup=resource_group_name)
imgs.append(result)
# Inspect the images
results = []
inspect_results = []
# Multi-worker
print("\rInspecting container apps images...", end="", flush=True)
logger.warning("Inspecting container apps images...")
with ThreadPoolExecutor(max_workers=10) as executor:
[executor.submit(patch_get_image_inspection, pack_exec_path, img, inspect_results) for img in imgs]

Expand All @@ -4528,7 +4531,7 @@ def patch_list(cmd, resource_group_name=None, managed_env=None, show_all=False):
mcr_check_reason = "Image not from mcr.microsoft.com/oryx/builder"
results = []
# Start checking if the images are based on Mariner
print("\rChecking for patches...", end="", flush=True)
logger.warning("Checking for patches...")
for inspect_result in inspect_results:
if inspect_result["remote_info"] == 401:
results.append(dict(
Expand Down Expand Up @@ -4585,8 +4588,6 @@ def patch_list(cmd, resource_group_name=None, managed_env=None, show_all=False):
newRunImage=None,
id=None,
reason=mcr_check_reason))
# Make sure that we clear the first line before showing the new output
print("\r \r", end="", flush=True)
if show_all is False:
results = [result for result in results if result["id"] is not None]
if not results:
Expand Down Expand Up @@ -4642,7 +4643,7 @@ def patch_interactive(cmd, resource_group_name=None, managed_env=None, show_all=
without_unpatchable_results = [result for result in patchable_check_results if result["id"] is not None]
if without_unpatchable_results == [] and (patchable_check_results is None or show_all is False):
return
print(patchable_check_results_json)
logger.warning(patchable_check_results_json)
if without_unpatchable_results == []:
return
user_input = input("Do you want to apply all the patches or specify by id? (y/n/id)\n")
Expand All @@ -4664,7 +4665,7 @@ def patch_apply(cmd, resource_group_name=None, managed_env=None, show_all=False)
without_unpatchable_results = [result for result in patchable_check_results if result["id"] is not None]
if without_unpatchable_results == [] and (patchable_check_results is None or show_all is False):
return
print(patchable_check_results_json)
logger.warning(patchable_check_results_json)
if without_unpatchable_results == []:
return
patch_apply_handle_input(cmd, patchable_check_results, "y", pack_exec_path)
Expand Down Expand Up @@ -4708,7 +4709,6 @@ def patch_apply_handle_input(cmd, patch_check_list, method, pack_exec_path):
else:
telemetry_record_method = "invalid"
logger.error("Invalid patch method or id.")

patch_apply_properties = {
'Context.Default.AzureCLI.PatchUserResponse': telemetry_record_method,
'Context.Default.AzureCLI.PatchApplyCount': patch_apply_count
Expand Down Expand Up @@ -4737,7 +4737,7 @@ def patch_cli_call(cmd, resource_group, container_app_name, container_name, targ
resource_group_name=resource_group,
container_name=container_name,
image=new_target_image_name)
print(json.dumps(update_info_json, indent=2))
logger.warning(json.dumps(update_info_json, indent=2))
logger.warning("Container app revision created successfully from the patched image.")
return
except Exception:
Expand Down

0 comments on commit 5d15930

Please sign in to comment.