Add support for setting tags on ecs task definitions
This also implements the ecs.list_tags_for_resources, although the resources it checks for are currently only the task definitions
This commit is contained in:
parent
feef7b2b5a
commit
64e2a74e8c
4 changed files with 99 additions and 6 deletions
|
|
@ -94,6 +94,10 @@ def test_register_task_definition():
|
|||
}],
|
||||
'logConfiguration': {'logDriver': 'json-file'}
|
||||
}
|
||||
],
|
||||
tags=[
|
||||
{'key': 'createdBy', 'value': 'moto-unittest'},
|
||||
{'key': 'foo', 'value': 'bar'},
|
||||
]
|
||||
)
|
||||
type(response['taskDefinition']).should.be(dict)
|
||||
|
|
@ -2304,3 +2308,52 @@ def test_create_service_load_balancing():
|
|||
response['service']['status'].should.equal('ACTIVE')
|
||||
response['service']['taskDefinition'].should.equal(
|
||||
'arn:aws:ecs:us-east-1:012345678910:task-definition/test_ecs_task:1')
|
||||
|
||||
|
||||
@mock_ecs
|
||||
def test_list_tags_for_resource():
|
||||
client = boto3.client('ecs', region_name='us-east-1')
|
||||
response = client.register_task_definition(
|
||||
family='test_ecs_task',
|
||||
containerDefinitions=[
|
||||
{
|
||||
'name': 'hello_world',
|
||||
'image': 'docker/hello-world:latest',
|
||||
'cpu': 1024,
|
||||
'memory': 400,
|
||||
'essential': True,
|
||||
'environment': [{
|
||||
'name': 'AWS_ACCESS_KEY_ID',
|
||||
'value': 'SOME_ACCESS_KEY'
|
||||
}],
|
||||
'logConfiguration': {'logDriver': 'json-file'}
|
||||
}
|
||||
],
|
||||
tags=[
|
||||
{'key': 'createdBy', 'value': 'moto-unittest'},
|
||||
{'key': 'foo', 'value': 'bar'},
|
||||
]
|
||||
)
|
||||
type(response['taskDefinition']).should.be(dict)
|
||||
response['taskDefinition']['revision'].should.equal(1)
|
||||
response['taskDefinition']['taskDefinitionArn'].should.equal(
|
||||
'arn:aws:ecs:us-east-1:012345678910:task-definition/test_ecs_task:1')
|
||||
|
||||
task_definition_arn = response['taskDefinition']['taskDefinitionArn']
|
||||
response = client.list_tags_for_resource(resourceArn=task_definition_arn)
|
||||
|
||||
type(response['tags']).should.be(list)
|
||||
response['tags'].should.equal([
|
||||
{'key': 'createdBy', 'value': 'moto-unittest'},
|
||||
{'key': 'foo', 'value': 'bar'},
|
||||
])
|
||||
|
||||
|
||||
@mock_ecs
|
||||
def test_list_tags_for_resource_unknown():
|
||||
client = boto3.client('ecs', region_name='us-east-1')
|
||||
task_definition_arn = 'arn:aws:ecs:us-east-1:012345678910:task-definition/unknown:1'
|
||||
try:
|
||||
client.list_tags_for_resource(resourceArn=task_definition_arn)
|
||||
except ClientError as err:
|
||||
err.response['Error']['Code'].should.equal('ClientException')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue