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

adding a couple bug fixes for using sha hashes #19

Merged
merged 1 commit into from
Mar 13, 2023
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
16 changes: 11 additions & 5 deletions src/confcom/azext_confcom/template_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,26 @@ def case_insensitive_dict_get(dictionary, search_key) -> Any:
return None


def image_has_hash(image: str) -> bool:
return "@sha256:" in image


def get_image_info(progress, message_queue, tar_mapping, image):
image_info = None
raw_image = None
tar = False
if not image.base:
eprint("Image name cannot be empty")
image_name = f"{image.base}:{image.tag}"
if len(image.tag.split(":")) > 1:
eprint(
f"The image name: {image.tag} cannot have the digest present to use a tarball as the image source"
)

# only try to grab the info locally if that's absolutely what
# we want to do
if tar_mapping:
if image_has_hash(image_name):
progress.close()
eprint(
f"The image name: {image_name} cannot have the digest present to use a tarball as the image source"
)
tar_location = get_tar_location_from_mapping(tar_mapping, image_name)
# if we have a tar location, we can try to get the image info
if tar_location:
Expand Down Expand Up @@ -103,7 +109,7 @@ def get_image_info(progress, message_queue, tar_mapping, image):
# pull image to local daemon (if not in local
# daemon)
if not raw_image:
raw_image = client.images.pull(image.base, image.tag)
raw_image = client.images.pull(image_name)
image_info = raw_image.attrs.get("Config")
except (docker.errors.ImageNotFound, docker.errors.NotFound):
progress.close()
Expand Down