Skip to content

Commit

Permalink
Fail if terraform doesnot exist
Browse files Browse the repository at this point in the history
  • Loading branch information
sparshadotel committed Oct 4, 2019
1 parent a5b16a2 commit 0cad35c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
13 changes: 12 additions & 1 deletion infrastructure/shift-infrastructure.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
package infrastructure

import "github.com/leapfrogtechnology/shift/infrastructure/internals"
import (
"errors"
"github.com/leapfrogtechnology/shift/core/utils/logger"
"github.com/leapfrogtechnology/shift/infrastructure/internals"
"github.com/leapfrogtechnology/shift/infrastructure/utils"
)

func Initialize(details string) (string, error) {
if !utils.CommandExists("terraform") {
logger.FailOnError(errors.New("terraform does not exist"), "Please install terraform on your device")
}
infrastructureInfo, err := internals.Initialize(details)
if err != nil {
logger.FailOnError(err, "Failed to Init Infrastructure")
}
return infrastructureInfo, err
}
8 changes: 8 additions & 0 deletions infrastructure/utils/command-exists.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package utils

import "os/exec"

func CommandExists(command string) bool {
_, err := exec.LookPath(command)
return err == nil
}

0 comments on commit 0cad35c

Please sign in to comment.