mirror of https://github.com/docker/compose.git
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
|
||||
|
||||
// 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 {
|
||||
s := arn.(string)
|
||||
return &s, nil
|
||||
|
|
|
@ -10,6 +10,22 @@ import (
|
|||
)
|
||||
|
||||
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()
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -29,8 +45,8 @@ func (c *client) ComposeUp(project *compose.Project) error {
|
|||
return err
|
||||
}
|
||||
|
||||
for _, service := range project.Services {
|
||||
_, err = c.CreateService(project, service, securityGroup, subnets, logGroup)
|
||||
for _, mapping := range mappings {
|
||||
_, err = c.CreateService(project, mapping.service, mapping.task, securityGroup, subnets, logGroup)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -38,12 +54,7 @@ func (c *client) ComposeUp(project *compose.Project) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (c *client) CreateService(project *compose.Project, service types.ServiceConfig, securityGroup *string, subnets []*string, logGroup *string) (*string, error) {
|
||||
task, err := convert.Convert(project, service)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (c *client) CreateService(project *compose.Project, service *types.ServiceConfig, task *ecs.RegisterTaskDefinitionInput, securityGroup *string, subnets []*string, logGroup *string) (*string, error) {
|
||||
role, err := c.GetEcsTaskExecutionRole(service)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
Loading…
Reference in New Issue