Merge pull request #2683 from Journera/ecs-td-add-network-mode
Store 'networkMode' in ECS Task Definitions instead of just throwing it away
This commit is contained in:
commit
dff1986801
@ -118,6 +118,7 @@ class TaskDefinition(BaseObject):
|
||||
revision,
|
||||
container_definitions,
|
||||
region_name,
|
||||
network_mode=None,
|
||||
volumes=None,
|
||||
tags=None,
|
||||
):
|
||||
@ -132,6 +133,10 @@ class TaskDefinition(BaseObject):
|
||||
self.volumes = []
|
||||
else:
|
||||
self.volumes = volumes
|
||||
if network_mode is None:
|
||||
self.network_mode = "bridge"
|
||||
else:
|
||||
self.network_mode = network_mode
|
||||
|
||||
@property
|
||||
def response_object(self):
|
||||
@ -553,7 +558,7 @@ class EC2ContainerServiceBackend(BaseBackend):
|
||||
raise Exception("{0} is not a cluster".format(cluster_name))
|
||||
|
||||
def register_task_definition(
|
||||
self, family, container_definitions, volumes, tags=None
|
||||
self, family, container_definitions, volumes=None, network_mode=None, tags=None
|
||||
):
|
||||
if family in self.task_definitions:
|
||||
last_id = self._get_last_task_definition_revision_id(family)
|
||||
@ -562,7 +567,13 @@ class EC2ContainerServiceBackend(BaseBackend):
|
||||
self.task_definitions[family] = {}
|
||||
revision = 1
|
||||
task_definition = TaskDefinition(
|
||||
family, revision, container_definitions, self.region_name, volumes, tags
|
||||
family,
|
||||
revision,
|
||||
container_definitions,
|
||||
self.region_name,
|
||||
volumes=volumes,
|
||||
network_mode=network_mode,
|
||||
tags=tags,
|
||||
)
|
||||
self.task_definitions[family][revision] = task_definition
|
||||
|
||||
|
@ -62,8 +62,13 @@ class EC2ContainerServiceResponse(BaseResponse):
|
||||
container_definitions = self._get_param("containerDefinitions")
|
||||
volumes = self._get_param("volumes")
|
||||
tags = self._get_param("tags")
|
||||
network_mode = self._get_param("networkMode")
|
||||
task_definition = self.ecs_backend.register_task_definition(
|
||||
family, container_definitions, volumes, tags
|
||||
family,
|
||||
container_definitions,
|
||||
volumes=volumes,
|
||||
network_mode=network_mode,
|
||||
tags=tags,
|
||||
)
|
||||
return json.dumps({"taskDefinition": task_definition.response_object})
|
||||
|
||||
|
@ -94,6 +94,7 @@ def test_register_task_definition():
|
||||
"logConfiguration": {"logDriver": "json-file"},
|
||||
}
|
||||
],
|
||||
networkMode="bridge",
|
||||
tags=[
|
||||
{"key": "createdBy", "value": "moto-unittest"},
|
||||
{"key": "foo", "value": "bar"},
|
||||
@ -124,6 +125,7 @@ def test_register_task_definition():
|
||||
response["taskDefinition"]["containerDefinitions"][0]["logConfiguration"][
|
||||
"logDriver"
|
||||
].should.equal("json-file")
|
||||
response["taskDefinition"]["networkMode"].should.equal("bridge")
|
||||
|
||||
|
||||
@mock_ecs
|
||||
|
Loading…
Reference in New Issue
Block a user