@@ -481,6 +481,46 @@ def fill_from_dict(
481481
482482 return self
483483
484+ async def _get_latest_docker_tag (
485+ self , * , synapse_client : Optional [Synapse ] = None
486+ ) -> Optional [dict ]:
487+ """
488+ Fetch the latest Docker tag information for a Docker repository entity.
489+
490+ Arguments:
491+ synapse_client: If not passed in and caching was not disabled by
492+ `Synapse.allow_client_caching(False)` this will use the last created
493+ instance from the Synapse class constructor.
494+
495+ Returns:
496+ Dictionary containing the latest Docker tag information, or None if no tags found.
497+
498+ Raises:
499+ Exception: If there's an error fetching the Docker tag information.
500+ """
501+ from synapseclient .api import docker_commit_services
502+
503+ docker_tag_response = await docker_commit_services .get_docker_tag (
504+ entity_id = self .entity_id , synapse_client = synapse_client
505+ )
506+
507+ # Get the latest digest from the docker tag results
508+ if "results" in docker_tag_response and docker_tag_response ["results" ]:
509+ # Sort by createdOn timestamp to get the latest entry
510+ # Convert ISO timestamp strings to datetime objects for comparison
511+ from datetime import datetime
512+
513+ latest_result = max (
514+ docker_tag_response ["results" ],
515+ key = lambda x : datetime .fromisoformat (
516+ x ["createdOn" ].replace ("Z" , "+00:00" )
517+ ),
518+ )
519+
520+ return latest_result
521+
522+ return None
523+
484524 async def _fetch_latest_entity (
485525 self , * , synapse_client : Optional [Synapse ] = None
486526 ) -> dict :
@@ -523,25 +563,13 @@ async def _fetch_latest_entity(
523563 from synapseclient .core .constants .concrete_types import DOCKER_REPOSITORY
524564
525565 if entity_info .get ("concreteType" ) == DOCKER_REPOSITORY :
526- docker_tag_response = await client . rest_get_async (
527- f"/entity/ { self . entity_id } /dockerTag"
566+ latest_docker_tag = await self . _get_latest_docker_tag (
567+ synapse_client = client
528568 )
529569
530- # Get the latest digest from the docker tag results
531- if "results" in docker_tag_response and docker_tag_response ["results" ]:
532- # Sort by createdOn timestamp to get the latest entry
533- # Convert ISO timestamp strings to datetime objects for comparison
534- from datetime import datetime
535-
536- latest_result = max (
537- docker_tag_response ["results" ],
538- key = lambda x : datetime .fromisoformat (
539- x ["createdOn" ].replace ("Z" , "+00:00" )
540- ),
541- )
542-
570+ if latest_docker_tag :
543571 # Add the latest result to entity_info
544- entity_info .update (latest_result )
572+ entity_info .update (latest_docker_tag )
545573
546574 return entity_info
547575 except Exception as e :
0 commit comments