Skip to content

Commit

Permalink
Merge pull request #6 from in4it/feature/volumes
Browse files Browse the repository at this point in the history
ecs volumes support
  • Loading branch information
wardviaene authored Mar 1, 2018
2 parents a1521cd + 8411ed4 commit ce3fa77
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
27 changes: 27 additions & 0 deletions provider/ecs/ecs.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,20 @@ func (e *ECS) CreateTaskDefinition(d service.Deploy) (*string, error) {
e.TaskDefinition.SetPlacementConstraints(pcs)
}

// volumes
if len(d.Volumes) > 0 {
var volumes []*ecs.Volume
for _, vol := range d.Volumes {
volumes = append(volumes, &ecs.Volume{
Name: aws.String(vol.Name),
Host: &ecs.HostVolumeProperties{
SourcePath: aws.String(vol.Host.SourcePath),
},
})
}
e.TaskDefinition.SetVolumes(volumes)
}

// loop over containers
for _, container := range d.Containers {

Expand Down Expand Up @@ -343,6 +357,19 @@ func (e *ECS) CreateTaskDefinition(d service.Deploy) (*string, error) {
containerDefinition.SetEnvironment(environment)
}

// MountPoints
if len(container.MountPoints) > 0 {
var mps []*ecs.MountPoint
for _, mp := range container.MountPoints {
mps = append(mps, &ecs.MountPoint{
ContainerPath: aws.String(mp.ContainerPath),
SourceVolume: aws.String(mp.SourceVolume),
ReadOnly: aws.Bool(mp.ReadOnly),
})
}
containerDefinition.SetMountPoints(mps)
}

e.TaskDefinition.ContainerDefinitions = append(e.TaskDefinition.ContainerDefinitions, containerDefinition)
}

Expand Down
14 changes: 14 additions & 0 deletions service/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type Deploy struct {
LaunchType string `json:"launchType"`
DeregistrationDelay int64 `json:"deregistrationDelay"`
Stickiness DeployStickiness `json:"stickiness"`
Volumes []DeployVolume `json:"volumes"`
}
type DeployContainer struct {
ContainerName string `json:"containerName" binding:"required"`
Expand All @@ -39,11 +40,17 @@ type DeployContainer struct {
CPU int64 `json:"cpu"`
CPUReservation int64 `json:"cpuReservation"`
Environment []*DeployContainerEnvironment `json:"environment"`
MountPoints []*DeployContainerMountPoint `json:"mountPoints"`
}
type DeployContainerEnvironment struct {
Name string `json:"name"`
Value string `json:"value"`
}
type DeployContainerMountPoint struct {
ContainerPath string `json:"containerPath"`
SourceVolume string `json:"sourceVolume"`
ReadOnly bool `json:"readonly"`
}
type DeployNetworkConfiguration struct {
AssignPublicIp string `json:"assignPublicIp"`
SecurityGroups []string `json:"securityGroups"`
Expand Down Expand Up @@ -73,6 +80,13 @@ type DeployStickiness struct {
Enabled bool `json:"enabled"`
Duration int64 `json:"duration"`
}
type DeployVolume struct {
Host DeployVolumeHost `json:"host"`
Name string `json:"name"`
}
type DeployVolumeHost struct {
SourcePath string `json:"sourcePath"`
}

type DeployResult struct {
ServiceName string `json:"serviceName"`
Expand Down

0 comments on commit ce3fa77

Please sign in to comment.