From 40b6dca69b1252e75ccbe22c65265ed72ee3b40b Mon Sep 17 00:00:00 2001 From: penghaoh Date: Tue, 18 Jun 2019 18:05:09 -0700 Subject: [PATCH] fixed #796 --- ecs-cli/modules/cli/local/project/project.go | 8 +++++--- ecs-cli/modules/cli/local/project/project_test.go | 5 ++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ecs-cli/modules/cli/local/project/project.go b/ecs-cli/modules/cli/local/project/project.go index 81184fc6e..d11840f63 100644 --- a/ecs-cli/modules/cli/local/project/project.go +++ b/ecs-cli/modules/cli/local/project/project.go @@ -21,6 +21,7 @@ import ( "fmt" "io/ioutil" "os" + "path/filepath" "strings" "github.com/aws/amazon-ecs-cli/ecs-cli/modules/cli/local/converter" @@ -32,10 +33,11 @@ import ( "github.com/urfave/cli" ) -const ( - LocalOutDefaultFileName = "docker-compose.local.yml" +var ( + wd, _ = os.Getwd() + LocalOutDefaultFileName = filepath.Join(wd, "docker-compose.local.yml") LocalOutFileMode = os.FileMode(0600) // Owner=read/write, Other=none - LocalInFileName = "task-definition.json" + LocalInFileName = filepath.Join(wd, "task-definition.json") ) // Interface for a local project, holding data needed to convert an ECS Task Definition to a Docker Compose file diff --git a/ecs-cli/modules/cli/local/project/project_test.go b/ecs-cli/modules/cli/local/project/project_test.go index 8aa59585a..172a95758 100644 --- a/ecs-cli/modules/cli/local/project/project_test.go +++ b/ecs-cli/modules/cli/local/project/project_test.go @@ -19,6 +19,7 @@ import ( "flag" "io/ioutil" "os" + "strings" "testing" "github.com/aws/amazon-ecs-cli/ecs-cli/modules/commands/flags" @@ -34,7 +35,9 @@ func TestWrite(t *testing.T) { oldOpenFile := openFile openFile = func(filename string) (*os.File, error) { - tmpfile, err := ioutil.TempFile("", filename) + tmpFileNameList := strings.Split(filename, string(os.PathSeparator)) + tmpFileName := tmpFileNameList[len(tmpFileNameList)-1] + tmpfile, err := ioutil.TempFile("", tmpFileName) assert.NoError(t, err, "Unexpected error in creating temp compose file") defer os.Remove(tmpfile.Name())