mirror of
https://github.com/docker/compose.git
synced 2025-07-21 20:54:32 +02:00
Convert services into TaskDefinition before creating resources
close #6 Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
7763de47eb
commit
17f3ff9db1
@ -13,7 +13,7 @@ const ECSTaskExecutionPolicy = "arn:aws:iam::aws:policy/service-role/AmazonECSTa
|
|||||||
var defaultTaskExecutionRole *string
|
var defaultTaskExecutionRole *string
|
||||||
|
|
||||||
// GetEcsTaskExecutionRole retrieve the role ARN to apply for task execution
|
// GetEcsTaskExecutionRole retrieve the role ARN to apply for task execution
|
||||||
func (c client) GetEcsTaskExecutionRole(spec types.ServiceConfig) (*string, error) {
|
func (c client) GetEcsTaskExecutionRole(spec *types.ServiceConfig) (*string, error) {
|
||||||
if arn, ok := spec.Extras["x-ecs-TaskExecutionRole"]; ok {
|
if arn, ok := spec.Extras["x-ecs-TaskExecutionRole"]; ok {
|
||||||
s := arn.(string)
|
s := arn.(string)
|
||||||
return &s, nil
|
return &s, nil
|
||||||
|
@ -10,6 +10,22 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (c *client) ComposeUp(project *compose.Project) error {
|
func (c *client) ComposeUp(project *compose.Project) error {
|
||||||
|
type mapping struct {
|
||||||
|
service *types.ServiceConfig
|
||||||
|
task *ecs.RegisterTaskDefinitionInput
|
||||||
|
}
|
||||||
|
mappings := []mapping{}
|
||||||
|
for _, service := range project.Services {
|
||||||
|
task, err := convert.Convert(project, service)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
mappings = append(mappings, mapping{
|
||||||
|
service: &service,
|
||||||
|
task: task,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
vpc, err := c.GetDefaultVPC()
|
vpc, err := c.GetDefaultVPC()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -29,8 +45,8 @@ func (c *client) ComposeUp(project *compose.Project) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, service := range project.Services {
|
for _, mapping := range mappings {
|
||||||
_, err = c.CreateService(project, service, securityGroup, subnets, logGroup)
|
_, err = c.CreateService(project, mapping.service, mapping.task, securityGroup, subnets, logGroup)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -38,12 +54,7 @@ func (c *client) ComposeUp(project *compose.Project) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *client) CreateService(project *compose.Project, service types.ServiceConfig, securityGroup *string, subnets []*string, logGroup *string) (*string, error) {
|
func (c *client) CreateService(project *compose.Project, service *types.ServiceConfig, task *ecs.RegisterTaskDefinitionInput, securityGroup *string, subnets []*string, logGroup *string) (*string, error) {
|
||||||
task, err := convert.Convert(project, service)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
role, err := c.GetEcsTaskExecutionRole(service)
|
role, err := c.GetEcsTaskExecutionRole(service)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user