Skip to content

Commit 2008bb2

Browse files
authored
Merge pull request #71 from release-engineering/improve_collector
Adds cloud_info to the pushcollector's clouds.json
2 parents dc548fe + bae483a commit 2008bb2

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

src/pubtools/_marketplacesvm/tasks/community_push/command.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import logging
44
import os
55
from collections import namedtuple
6-
from typing import Any, Dict, Iterator, List, Optional, TypedDict, cast
6+
from typing import Any, Dict, Iterator, List, Optional, Tuple, TypedDict, cast
77

88
from attrs import asdict, evolve
99
from more_executors import Executors
@@ -358,7 +358,7 @@ def _upload(
358358
push_item: VMIPushItem,
359359
custom_tags: Optional[Dict[str, str]] = None,
360360
**kwargs,
361-
) -> VMIPushItem:
361+
) -> Tuple[VMIPushItem, str]:
362362
# First we do the AMI upload in a similar way of the base class
363363
ship = not self.args.pre_push
364364
container = "%s-%s" % (self.args.container_prefix, push_item.region)
@@ -395,7 +395,7 @@ def _upload(
395395
stack_info=True,
396396
)
397397
pi = evolve(push_item, state=State.UPLOADFAILED)
398-
return pi
398+
return pi, marketplace
399399

400400
# Then, if we're shipping the community image, we should update the RHSM
401401
# and change the the AWS group to "all" for the uploaded image
@@ -418,12 +418,12 @@ def _upload(
418418
except Exception as exc:
419419
log.exception("Failed to publish %s: %s", push_item.name, str(exc), stack_info=True)
420420
pi = evolve(push_item, state=State.NOTPUSHED)
421-
return pi
421+
return pi, marketplace
422422

423423
# Finally, if everything went well we return the updated push item
424424
log.info("Successfully uploaded %s [%s] [%s]", pi.name, pi.region, image.id)
425425
pi = evolve(pi, state=State.PUSHED)
426-
return pi
426+
return pi, marketplace
427427

428428
def _check_product_in_rhsm(self, enriched_push_items: List[EnrichedPushItem]) -> bool:
429429
for enriched_item in enriched_push_items:
@@ -466,8 +466,12 @@ def _push_to_community(self, push_queue: Iterator[UploadParams]) -> List[Dict[st
466466
"state": pi.state,
467467
"image_id": pi.image_id,
468468
"image_name": name_from_push_item(pi),
469+
"cloud_info": {
470+
"account": marketplace,
471+
"provider": "aws",
472+
},
469473
}
470-
for pi in upload_result
474+
for pi, marketplace in upload_result
471475
]
472476

473477
def _data_to_upload(

src/pubtools/_marketplacesvm/tasks/push/command.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,10 @@ async def push_function(mapped_item, marketplace, starmap_query) -> Dict[str, An
294294
return {
295295
"push_item": push_item_for_collection,
296296
"state": pi.state,
297-
"marketplace": marketplace,
297+
"cloud_info": {
298+
"account": marketplace,
299+
"provider": mapped_item.starmap_query_entity.cloud,
300+
},
298301
"destinations": mapped_item.starmap_query_entity.mappings[marketplace].destinations,
299302
"starmap_query": starmap_query,
300303
}
@@ -337,6 +340,8 @@ def convert(obj):
337340
res_dict = asdict(result["push_item"])
338341
if result.get("starmap_query"):
339342
res_dict["starmap_query"] = asdict(result["starmap_query"])
343+
if result.get("cloud_info"):
344+
res_dict["cloud_info"] = result["cloud_info"]
340345
# dict can't be modified during iteration.
341346
# so iterate over list of keys.
342347
for key in list(res_dict):

0 commit comments

Comments
 (0)