Skip to content

Commit

Permalink
fix: handle none-type values more carefully
Browse files Browse the repository at this point in the history
In the event that an image does not have any gzipped layers, then no
uncompressed layer information will be handed to this tool and it will
pass on the None value to pyxis. That fails pyxis' input validation,
blocking containerImage creation.

In this change, simply drop these values if they happen to be none.

Signed-off-by: Ralph Bean <[email protected]>
  • Loading branch information
ralphbean committed Nov 11, 2024
1 parent 221d71a commit 0769f58
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
8 changes: 6 additions & 2 deletions pyxis/create_container_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,14 @@ def create_container_image(args, parsed_data: Dict[str, Any]):
"architecture": parsed_data["architecture"],
"parsed_data": parsed_data,
"sum_layer_size_bytes": sum_layer_size_bytes,
"top_layer_id": top_layer_id,
"uncompressed_top_layer_id": uncompressed_top_layer_id,
}

# Only supply these ids if they are not "None"
if top_layer_id:
container_image_payload["top_layer_id"] = top_layer_id
if uncompressed_top_layer_id:
container_image_payload["uncompressed_top_layer_id"] = uncompressed_top_layer_id

container_image_payload["repositories"][0].update(
repository_digest_values(args, docker_image_digest)
)
Expand Down
6 changes: 0 additions & 6 deletions pyxis/test_create_container_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,6 @@ def test_create_container_image(mock_datetime, mock_post):
"architecture": "ok",
"parsed_data": {"architecture": "ok"},
"sum_layer_size_bytes": 0,
"top_layer_id": None,
"uncompressed_top_layer_id": None,
},
)

Expand Down Expand Up @@ -246,8 +244,6 @@ def test_create_container_image_latest(mock_datetime, mock_post):
"architecture": "ok",
"parsed_data": {"architecture": "ok"},
"sum_layer_size_bytes": 0,
"top_layer_id": None,
"uncompressed_top_layer_id": None,
},
)

Expand Down Expand Up @@ -326,8 +322,6 @@ def test_create_container_image_rh_push_multiple_tags(mock_datetime, mock_post):
"architecture": "ok",
"parsed_data": {"architecture": "ok"},
"sum_layer_size_bytes": 0,
"top_layer_id": None,
"uncompressed_top_layer_id": None,
},
)

Expand Down

0 comments on commit 0769f58

Please sign in to comment.