Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
fix: handle errors for mkdirall when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelapenya committed Feb 17, 2020
1 parent 244540e commit 5dc4cb0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
7 changes: 5 additions & 2 deletions cli/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ func GetComposeFile(isStack bool, composeName string) (string, error) {
}

// create parent directory for the compose file
io.MkdirAll(filepath.Dir(composeFilePath))
err = io.MkdirAll(filepath.Dir(composeFilePath))
if err != nil {
return composeFilePath, err
}

err = io.WriteFile(composeBytes, composeFilePath)
if err != nil {
Expand Down Expand Up @@ -217,7 +220,7 @@ func checkConfigDirectory(dir string) {
if found && err == nil {
return
}
io.MkdirAll(dir)
_ = io.MkdirAll(dir)
}

func checkConfigDirs(workspace string) {
Expand Down
5 changes: 4 additions & 1 deletion cli/internal/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ func CopyFile(src string, dst string, BUFFERSIZE int64) error {
return errors.New("File " + dst + " already exists")
}

MkdirAll(dst)
err = MkdirAll(dst)
if err != nil {
return err
}

destination, err := os.Create(dst)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions cli/internal/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ func TestRecover(t *testing.T) {
"foo": "bar",
}

MkdirAll(workspace)
_ = MkdirAll(workspace)

Update(ID, workspace, composeFiles, initialEnv)

runFile := filepath.Join(workspace, ID+".run")
Expand Down Expand Up @@ -56,7 +56,7 @@ func TestUpdateCreatesStateFile(t *testing.T) {
filepath.Join(workspace, "compose/services/d/4.yml"),
}
runFile := filepath.Join(workspace, ID+".run")
MkdirAll(runFile)
_ = MkdirAll(runFile)

Update(ID, workspace, composeFiles, map[string]string{})

Expand Down

0 comments on commit 5dc4cb0

Please sign in to comment.