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

Commit

Permalink
Set task tags
Browse files Browse the repository at this point in the history
Signed-off-by: aiordache <anca.iordache@docker.com>
  • Loading branch information
aiordache authored and glours committed Jul 27, 2020
1 parent 10ca96f commit 1a949c6
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 8 deletions.
32 changes: 24 additions & 8 deletions pkg/amazon/backend/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,29 @@ func Convert(project *types.Project, service types.ServiceConfig) (*ecs.TaskDefi
fmt.Sprintf(" %s.local", project.Name),
}))

tags := []tags.Tag{
{
Key: compose.ProjectTag,
Value: project.Name,
},
{
Key: compose.ServiceTag,
Value: service.Name,
},
}
tags = append(tags, toTags(service.Labels)...)

return &ecs.TaskDefinition{
ContainerDefinitions: []ecs.TaskDefinition_ContainerDefinition{
{
Command: service.Command,
DisableNetworking: service.NetworkMode == "none",
DnsSearchDomains: service.DNSSearch,
DnsServers: service.DNS,
DockerLabels: nil,
Command: service.Command,
DisableNetworking: service.NetworkMode == "none",
DnsSearchDomains: service.DNSSearch,
DnsServers: service.DNS,
DockerLabels: map[string]string{
compose.ProjectTag: project.Name,
compose.ServiceTag: service.Name,
},
DockerSecurityOptions: service.SecurityOpt,
EntryPoint: service.Entrypoint,
Environment: toKeyValuePair(service.Environment),
Expand Down Expand Up @@ -78,8 +93,9 @@ func Convert(project *types.Project, service types.ServiceConfig) (*ecs.TaskDefi
SystemControls: toSystemControls(service.Sysctls),
Ulimits: toUlimits(service.Ulimits),
User: service.User,
VolumesFrom: nil,
WorkingDirectory: service.WorkingDir,

VolumesFrom: nil,
WorkingDirectory: service.WorkingDir,
},
},
Cpu: cpu,
Expand All @@ -91,7 +107,7 @@ func Convert(project *types.Project, service types.ServiceConfig) (*ecs.TaskDefi
PlacementConstraints: toPlacementConstraints(service.Deploy),
ProxyConfiguration: nil,
RequiresCompatibilities: []string{ecsapi.LaunchTypeFargate},
Tags: toTags(service.Labels),
Tags: tags,
}, nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@
"Properties": {
"ContainerDefinitions": [
{
"DockerLabels": {
"com.docker.compose.project": "TestSimpleConvert",
"com.docker.compose.service": "simple"
},
"Environment": [
{
"Name": "LOCALDOMAIN",
Expand Down Expand Up @@ -270,6 +274,16 @@
"NetworkMode": "awsvpc",
"RequiresCompatibilities": [
"FARGATE"
],
"Tags": [
{
"Key": "com.docker.compose.project",
"Value": "TestSimpleConvert"
},
{
"Key": "com.docker.compose.service",
"Value": "simple"
}
]
},
"Type": "AWS::ECS::TaskDefinition"
Expand Down

0 comments on commit 1a949c6

Please sign in to comment.