Skip to content

Commit 5bdce6b

Browse files
committed
Add dependency on docker/libcompose and move libcompose.InfoSet
1 parent 0b72624 commit 5bdce6b

13 files changed

Lines changed: 2084 additions & 204 deletions

File tree

ecs-cli/Godeps/Godeps.json

Lines changed: 78 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ecs-cli/license/license.go

Lines changed: 1954 additions & 170 deletions
Large diffs are not rendered by default.

ecs-cli/license/license_test.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,20 @@ import (
2020

2121
func TestVendorDirectoryStructure(t *testing.T) {
2222
directories, _ := ioutil.ReadDir("./../vendor")
23-
if len(directories) != 1 {
24-
t.Errorf("Should have exactly 1 directory under vendor/. Found [%s] directories", len(directories))
23+
if len(directories) != 2 {
24+
t.Errorf("Should have exactly 2 directories under vendor/. Found [%s] directories", len(directories))
2525
}
26-
dir := directories[0]
27-
if !dir.IsDir() {
28-
t.Error("Expected only contents of vendor/ to be a directory")
26+
var found bool
27+
for _, dir := range directories {
28+
if !dir.IsDir() {
29+
t.Errorf("Expected contents of vendor/ to be directories, but %s is not", dir)
30+
}
31+
if "github.com" == dir.Name() {
32+
found = true
33+
}
2934
}
30-
if "github.com" != dir.Name() {
31-
t.Errorf("directory name : Expected=github.com, Found=[%s]", dir.Name())
35+
36+
if !found {
37+
t.Errorf("Expected one directory to be name=github.com, Found=[%v]", directories)
3238
}
3339
}

ecs-cli/modules/command/cluster_app.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@ import (
2323
ec2client "github.com/aws/amazon-ecs-cli/ecs-cli/modules/aws/clients/ec2"
2424
ecsclient "github.com/aws/amazon-ecs-cli/ecs-cli/modules/aws/clients/ecs"
2525
ecscompose "github.com/aws/amazon-ecs-cli/ecs-cli/modules/compose/ecs"
26-
"github.com/aws/amazon-ecs-cli/ecs-cli/modules/compose/libcompose"
2726
"github.com/aws/amazon-ecs-cli/ecs-cli/modules/config"
2827
"github.com/aws/amazon-ecs-cli/ecs-cli/modules/config/ami"
2928
"github.com/aws/aws-sdk-go/aws"
3029
"github.com/codegangsta/cli"
30+
"github.com/docker/libcompose/project"
3131
)
3232

33+
// displayTitle flag is used to print the title for the fields
34+
const displayTitle = true
35+
3336
var flagNamesToStackParameterKeys map[string]string
3437

3538
func init() {
@@ -106,7 +109,7 @@ func ClusterPS(c *cli.Context) {
106109
logrus.Error("Error executing 'ps ", err)
107110
return
108111
}
109-
os.Stdout.WriteString(infoSet.String())
112+
os.Stdout.WriteString(infoSet.String(displayTitle))
110113
}
111114

112115
func createCluster(context *cli.Context, rdwr config.ReadWriter, ecsClient ecsclient.ECSClient, cfnClient cloudformation.CloudformationClient, amiIds ami.ECSAmiIds) error {
@@ -261,7 +264,7 @@ func scaleCluster(context *cli.Context, rdwr config.ReadWriter, ecsClient ecscli
261264
return cfnClient.WaitUntilUpdateComplete(stackName)
262265
}
263266

264-
func clusterPS(context *cli.Context, rdwr config.ReadWriter, ecsClient ecsclient.ECSClient) (libcompose.InfoSet, error) {
267+
func clusterPS(context *cli.Context, rdwr config.ReadWriter, ecsClient ecsclient.ECSClient) (project.InfoSet, error) {
265268
ecsParams, err := newCliParams(context, rdwr)
266269
if err != nil {
267270
return nil, err

ecs-cli/modules/compose/cli/ecs/app/app.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ import (
2323
"github.com/codegangsta/cli"
2424
)
2525

26+
// displayTitle flag is used to print the title for the fields
27+
const displayTitle = true
28+
2629
// ProjectAction is an adapter to allow the use of ordinary functions as libcompose actions.
2730
// Any function that has the appropriate signature can be register as an action on a codegansta/cli command.
2831
//
@@ -79,7 +82,7 @@ func ProjectPs(p ecscompose.Project, c *cli.Context) {
7982
if err != nil {
8083
log.Fatal(err)
8184
}
82-
os.Stdout.WriteString(allInfo.String())
85+
os.Stdout.WriteString(allInfo.String(displayTitle))
8386
}
8487

8588
// ProjectRun starts containers and executes one-time command against the container

ecs-cli/modules/compose/ecs/container.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ import (
1818
"strings"
1919

2020
"github.com/aws/amazon-ecs-cli/ecs-cli/modules/compose/ecs/utils"
21-
libcompose "github.com/aws/amazon-ecs-cli/ecs-cli/modules/compose/libcompose"
2221
"github.com/aws/aws-sdk-go/aws"
2322
"github.com/aws/aws-sdk-go/service/ecs"
23+
"github.com/docker/libcompose/project"
2424
)
2525

2626
// Container is a wrapper around ecsContainer
@@ -98,15 +98,15 @@ func (c *Container) PortString() string {
9898
}
9999

100100
// convertContainersToInfoSet transforms the list of containers into a formatted set of fields
101-
func convertContainersToInfoSet(containers []Container) libcompose.InfoSet {
102-
result := libcompose.InfoSet{}
101+
func convertContainersToInfoSet(containers []Container) project.InfoSet {
102+
result := project.InfoSet{}
103103
for _, cont := range containers {
104-
info := libcompose.Info{}
104+
info := project.Info{}
105105
// TODO: Add more fields
106-
info = append(info, libcompose.InfoPart{"Name", cont.Name()})
107-
info = append(info, libcompose.InfoPart{"State", cont.State()})
108-
info = append(info, libcompose.InfoPart{"Ports", cont.PortString()})
109-
info = append(info, libcompose.InfoPart{"TaskDefinition", cont.TaskDefinition()})
106+
info = append(info, project.InfoPart{"Name", cont.Name()})
107+
info = append(info, project.InfoPart{"State", cont.State()})
108+
info = append(info, project.InfoPart{"Ports", cont.PortString()})
109+
info = append(info, project.InfoPart{"TaskDefinition", cont.TaskDefinition()})
110110
result = append(result, info)
111111
}
112112
return result

ecs-cli/modules/compose/ecs/entity.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ import (
1818

1919
log "github.com/Sirupsen/logrus"
2020
composeutils "github.com/aws/amazon-ecs-cli/ecs-cli/modules/compose/ecs/utils"
21-
libcompose "github.com/aws/amazon-ecs-cli/ecs-cli/modules/compose/libcompose"
2221
"github.com/aws/amazon-ecs-cli/ecs-cli/utils"
2322
"github.com/aws/amazon-ecs-cli/ecs-cli/utils/cache"
2423
"github.com/aws/aws-sdk-go/aws"
2524
"github.com/aws/aws-sdk-go/service/ecs"
25+
"github.com/docker/libcompose/project"
2626
)
2727

2828
// ProjectEntity ties closely to how operations performed with the compose yaml are integrated with ECS
@@ -31,7 +31,7 @@ type ProjectEntity interface {
3131
Create() error
3232
Start() error
3333
Up() error
34-
Info(filterComposeTasks bool) (libcompose.InfoSet, error)
34+
Info(filterComposeTasks bool) (project.InfoSet, error)
3535
Run(commandOverrides map[string]string) error
3636
Scale(count int) error
3737
Stop() error
@@ -94,7 +94,7 @@ func getOrCreateTaskDefinition(entity ProjectEntity) (*ecs.TaskDefinition, error
9494

9595
// info returns a formatted list of containers (running and stopped) in the current cluster
9696
// filtered by this project if filterLocal is set to true
97-
func info(entity ProjectEntity, filterLocal bool) (libcompose.InfoSet, error) {
97+
func info(entity ProjectEntity, filterLocal bool) (project.InfoSet, error) {
9898
containers, err := collectContainers(entity, filterLocal)
9999
if err != nil {
100100
return nil, err

ecs-cli/modules/compose/ecs/mocks/project.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package mock_ecs
1919
import (
2020
ecs "github.com/aws/amazon-ecs-cli/ecs-cli/modules/compose/ecs"
2121
libcompose "github.com/aws/amazon-ecs-cli/ecs-cli/modules/compose/libcompose"
22+
project "github.com/docker/libcompose/project"
2223
gomock "github.com/golang/mock/gomock"
2324
)
2425

@@ -83,9 +84,9 @@ func (_mr *_MockProjectRecorder) Entity() *gomock.Call {
8384
return _mr.mock.ctrl.RecordCall(_mr.mock, "Entity")
8485
}
8586

86-
func (_m *MockProject) Info() (libcompose.InfoSet, error) {
87+
func (_m *MockProject) Info() (project.InfoSet, error) {
8788
ret := _m.ctrl.Call(_m, "Info")
88-
ret0, _ := ret[0].(libcompose.InfoSet)
89+
ret0, _ := ret[0].(project.InfoSet)
8990
ret1, _ := ret[1].(error)
9091
return ret0, ret1
9192
}

ecs-cli/modules/compose/ecs/mocks/project_entity.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ package mock_ecs
1818

1919
import (
2020
ecs "github.com/aws/amazon-ecs-cli/ecs-cli/modules/compose/ecs"
21-
libcompose "github.com/aws/amazon-ecs-cli/ecs-cli/modules/compose/libcompose"
2221
utils "github.com/aws/amazon-ecs-cli/ecs-cli/utils"
2322
cache "github.com/aws/amazon-ecs-cli/ecs-cli/utils/cache"
2423
ecs0 "github.com/aws/aws-sdk-go/service/ecs"
24+
project "github.com/docker/libcompose/project"
2525
gomock "github.com/golang/mock/gomock"
2626
)
2727

@@ -76,9 +76,9 @@ func (_mr *_MockProjectEntityRecorder) Down() *gomock.Call {
7676
return _mr.mock.ctrl.RecordCall(_mr.mock, "Down")
7777
}
7878

79-
func (_m *MockProjectEntity) Info(_param0 bool) (libcompose.InfoSet, error) {
79+
func (_m *MockProjectEntity) Info(_param0 bool) (project.InfoSet, error) {
8080
ret := _m.ctrl.Call(_m, "Info", _param0)
81-
ret0, _ := ret[0].(libcompose.InfoSet)
81+
ret0, _ := ret[0].(project.InfoSet)
8282
ret1, _ := ret[1].(error)
8383
return ret0, ret1
8484
}

ecs-cli/modules/compose/ecs/project.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"github.com/Sirupsen/logrus"
1818
"github.com/aws/amazon-ecs-cli/ecs-cli/modules/compose/ecs/utils"
1919
libcompose "github.com/aws/amazon-ecs-cli/ecs-cli/modules/compose/libcompose"
20+
"github.com/docker/libcompose/project"
2021
)
2122

2223
// Project is the starting point for the compose app to interact with and issue commands
@@ -33,7 +34,7 @@ type Project interface {
3334
Create() error
3435
Start() error
3536
Up() error
36-
Info() (libcompose.InfoSet, error)
37+
Info() (project.InfoSet, error)
3738
Run(commandOverrides map[string]string) error
3839
Scale(count int) error
3940
Stop() error
@@ -141,7 +142,7 @@ func (p *ecsProject) Up() error {
141142
return p.entity.Up()
142143
}
143144

144-
func (p *ecsProject) Info() (libcompose.InfoSet, error) {
145+
func (p *ecsProject) Info() (project.InfoSet, error) {
145146
return p.entity.Info(true)
146147
}
147148

0 commit comments

Comments
 (0)