Skip to content
This repository was archived by the owner on Oct 9, 2020. It is now read-only.

Commit 1a949c6

Browse files
aiordacheglours
authored andcommitted
Set task tags
Signed-off-by: aiordache <[email protected]>
1 parent 10ca96f commit 1a949c6

File tree

2 files changed

+38
-8
lines changed

2 files changed

+38
-8
lines changed

pkg/amazon/backend/convert.go

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,29 @@ func Convert(project *types.Project, service types.ServiceConfig) (*ecs.TaskDefi
3737
fmt.Sprintf(" %s.local", project.Name),
3838
}))
3939

40+
tags := []tags.Tag{
41+
{
42+
Key: compose.ProjectTag,
43+
Value: project.Name,
44+
},
45+
{
46+
Key: compose.ServiceTag,
47+
Value: service.Name,
48+
},
49+
}
50+
tags = append(tags, toTags(service.Labels)...)
51+
4052
return &ecs.TaskDefinition{
4153
ContainerDefinitions: []ecs.TaskDefinition_ContainerDefinition{
4254
{
43-
Command: service.Command,
44-
DisableNetworking: service.NetworkMode == "none",
45-
DnsSearchDomains: service.DNSSearch,
46-
DnsServers: service.DNS,
47-
DockerLabels: nil,
55+
Command: service.Command,
56+
DisableNetworking: service.NetworkMode == "none",
57+
DnsSearchDomains: service.DNSSearch,
58+
DnsServers: service.DNS,
59+
DockerLabels: map[string]string{
60+
compose.ProjectTag: project.Name,
61+
compose.ServiceTag: service.Name,
62+
},
4863
DockerSecurityOptions: service.SecurityOpt,
4964
EntryPoint: service.Entrypoint,
5065
Environment: toKeyValuePair(service.Environment),
@@ -78,8 +93,9 @@ func Convert(project *types.Project, service types.ServiceConfig) (*ecs.TaskDefi
7893
SystemControls: toSystemControls(service.Sysctls),
7994
Ulimits: toUlimits(service.Ulimits),
8095
User: service.User,
81-
VolumesFrom: nil,
82-
WorkingDirectory: service.WorkingDir,
96+
97+
VolumesFrom: nil,
98+
WorkingDirectory: service.WorkingDir,
8399
},
84100
},
85101
Cpu: cpu,
@@ -91,7 +107,7 @@ func Convert(project *types.Project, service types.ServiceConfig) (*ecs.TaskDefi
91107
PlacementConstraints: toPlacementConstraints(service.Deploy),
92108
ProxyConfiguration: nil,
93109
RequiresCompatibilities: []string{ecsapi.LaunchTypeFargate},
94-
Tags: toTags(service.Labels),
110+
Tags: tags,
95111
}, nil
96112
}
97113

pkg/amazon/backend/testdata/simple/simple-cloudformation-conversion.golden

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@
219219
"Properties": {
220220
"ContainerDefinitions": [
221221
{
222+
"DockerLabels": {
223+
"com.docker.compose.project": "TestSimpleConvert",
224+
"com.docker.compose.service": "simple"
225+
},
222226
"Environment": [
223227
{
224228
"Name": "LOCALDOMAIN",
@@ -270,6 +274,16 @@
270274
"NetworkMode": "awsvpc",
271275
"RequiresCompatibilities": [
272276
"FARGATE"
277+
],
278+
"Tags": [
279+
{
280+
"Key": "com.docker.compose.project",
281+
"Value": "TestSimpleConvert"
282+
},
283+
{
284+
"Key": "com.docker.compose.service",
285+
"Value": "simple"
286+
}
273287
]
274288
},
275289
"Type": "AWS::ECS::TaskDefinition"

0 commit comments

Comments
 (0)