Add familyPrefix option to ecs:ListTaskDefinitions

AWS defines this option as:
```
--family-prefix (string)
  The full family name with which to filter the ListTaskDefinitions
  results. Specifying a familyPrefix limits the listed task
  defini-tions to task definition revisions that belong to that
  family.
```

This option behaves differently than ecs:ListTaskDefinitionFamilies.
Instead of doing a comparison like `startswith`, it does a full string
comparison by matching the entire task definition family to the prefix.
For example, let's say there exists a task definition with the family
`super-cool-task-def`.

ListTaskDefinitionFamilies would look like this:

```
aws ecs list-task-definition-families --family-prefix super-cool
{
    "families": [
      "super-cool-task-def"
    ]
}
```

ListTaskDefinitions would look like this:

```
aws ecs list-task-definitions --family-prefix super-cool
{
    "taskDefinitionArns": []
}
```
This commit is contained in:
Alex Tareshawty 2019-11-26 09:17:54 -05:00
commit df2279d39c
3 changed files with 68 additions and 6 deletions

View file

@ -567,16 +567,14 @@ class EC2ContainerServiceBackend(BaseBackend):
return task_definition
def list_task_definitions(self):
"""
Filtering not implemented
"""
def list_task_definitions(self, family_prefix):
task_arns = []
for task_definition_list in self.task_definitions.values():
task_arns.extend(
[
task_definition.arn
for task_definition in task_definition_list.values()
if family_prefix is None or task_definition.family == family_prefix
]
)
return task_arns