Limit robots displayed in entity search

Before, we'd load *all* the robots, which can be a huge issue in namespaces with a large number of robots. Now, we only load the top-20 robots (as per recency in login), and we also limit the information returned to the entity search to save some bandwidth.

Fixes https://jira.coreos.com/browse/QUAY-927
This commit is contained in:
Joseph Schorr 2018-05-14 16:27:16 -04:00
parent 7878435805
commit 5c50161d85
7 changed files with 121 additions and 26 deletions

View file

@ -55,10 +55,9 @@ class RobotWithPermissions(
:type description: string
"""
def to_dict(self):
return {
def to_dict(self, include_token=False):
data = {
'name': self.name,
'token': self.password,
'created': format_date(self.created) if self.created is not None else None,
'last_accessed': format_date(self.last_accessed) if self.last_accessed is not None else None,
'teams': [team.to_dict() for team in self.teams],
@ -66,6 +65,11 @@ class RobotWithPermissions(
'description': self.description,
}
if include_token:
data['token'] = self.password
return data
class Robot(
namedtuple('Robot', [
@ -86,15 +90,17 @@ class Robot(
:type unstructured_metadata: dict
"""
def to_dict(self, include_metadata=False):
def to_dict(self, include_metadata=False, include_token=False):
data = {
'name': self.name,
'token': self.password,
'created': format_date(self.created) if self.created is not None else None,
'last_accessed': format_date(self.last_accessed) if self.last_accessed is not None else None,
'description': self.description,
}
if include_token:
data['token'] = self.password
if include_metadata:
data['unstructured_metadata'] = self.unstructured_metadata
@ -171,7 +177,8 @@ class RobotInterface(object):
"""
@abstractmethod
def list_entity_robot_permission_teams(self, prefix, include_permissions=False):
def list_entity_robot_permission_teams(self, prefix, include_permissions=False,
include_token=False, limit=None):
"""
Returns: