Skip to content

Commit

Permalink
(#25) Make ExecError public
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelapenya committed Sep 11, 2019
1 parent 0f66b80 commit 38810f1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions compose.go
Expand Up @@ -18,8 +18,8 @@ const (

// DockerCompose defines the contract for running Docker Compose
type DockerCompose interface {
Down() execError
Invoke() execError
Down() ExecError
Invoke() ExecError
WithCommand([]string) DockerCompose
WithEnv(map[string]string) DockerCompose
}
Expand Down Expand Up @@ -50,7 +50,7 @@ func NewLocalDockerCompose(filePath string, identifier string) *LocalDockerCompo
}

// Down executes docker-compose down
func (dc *LocalDockerCompose) Down() execError {
func (dc *LocalDockerCompose) Down() ExecError {
if which(dc.Executable) != nil {
panic("Local Docker Compose not found. Is " + dc.Executable + " on the PATH?")
}
Expand All @@ -75,7 +75,7 @@ func (dc *LocalDockerCompose) Down() execError {
}

// Invoke invokes the docker compose
func (dc *LocalDockerCompose) Invoke() execError {
func (dc *LocalDockerCompose) Invoke() ExecError {
if which(dc.Executable) != nil {
panic("Local Docker Compose not found. Is " + dc.Executable + " on the PATH?")
}
Expand Down Expand Up @@ -119,17 +119,17 @@ func (dc *LocalDockerCompose) WithEnv(env map[string]string) DockerCompose {
return dc
}

// execError is super struct that holds any information about an execution error, so the client code
// ExecError is super struct that holds any information about an execution error, so the client code
// can handle the result
type execError struct {
type ExecError struct {
Error error
Stdout error
Stderr error
}

// execute executes a program with arguments and environment variables inside a specific directory
func execute(
dirContext string, environment map[string]string, binary string, args []string) execError {
dirContext string, environment map[string]string, binary string, args []string) ExecError {

var errStdout, errStderr error

Expand All @@ -153,7 +153,7 @@ func execute(

err := cmd.Start()
if err != nil {
return execError{
return ExecError{
Error: err,
Stderr: errStderr,
Stdout: errStdout,
Expand All @@ -170,7 +170,7 @@ func execute(

err = cmd.Wait()

return execError{
return ExecError{
Error: err,
Stderr: errStderr,
Stdout: errStdout,
Expand Down
2 changes: 1 addition & 1 deletion compose_test.go
Expand Up @@ -21,7 +21,7 @@ func TestLocalDockerCompose(t *testing.T) {
defer destroyFn()
}

func checkIfError(t *testing.T, err execError) {
func checkIfError(t *testing.T, err ExecError) {
if err.Error != nil || err.Stdout != nil || err.Stderr != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit 38810f1

Please sign in to comment.