Skip to content

Commit

Permalink
Add check for missing plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
brikis98 committed Aug 14, 2018
1 parent 1942596 commit e0069c0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 6 additions & 3 deletions cli/cli_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,16 +351,19 @@ func runTerraformCommandIfNoErrors(possibleErrors error, terragruntOptions *opti
return nil
}

// Workaround for https://github.com/hashicorp/terraform/issues/18460. Calling 'terraform init -get=false'
// Workaround for https://github.com/hashicorp/terraform/issues/18460. Calling 'terraform init -get=false '
// sometimes results in Terraform trying to download/validate modules anyway, so we need to ignore that error.
if util.ListContainsElement(terragruntOptions.TerraformCliArgs, "init") && util.ListContainsElement(terragruntOptions.TerraformCliArgs, "-get=false") {
if util.ListContainsElement(terragruntOptions.TerraformCliArgs, "init") &&
util.ListContainsElement(terragruntOptions.TerraformCliArgs, "-get=false") &&
util.ListContainsElement(terragruntOptions.TerraformCliArgs, "-get-plugins=false") &&
util.ListContainsElement(terragruntOptions.TerraformCliArgs, "-backend=false") {
out, err := shell.RunTerraformCommandAndCaptureOutput(terragruntOptions, terragruntOptions.TerraformCliArgs...)

// Write the log output to stderr to make sure we don't pollute stdout
terragruntOptions.ErrWriter.Write([]byte(out))

// If we got an error and the error output included this error message, ignore the error and keep going
if err != nil && len(moduleNotFoundErr.FindStringSubmatch(out)) > 0 {
if err != nil && (len(moduleNotFoundErr.FindStringSubmatch(out)) > 0 || strings.Contains(out, "Missing required providers.")) {
terragruntOptions.Logger.Println("Ignoring error from call to init, as this is a known Terraform bug: https://github.com/hashicorp/terraform/issues/18460")
return nil
}
Expand Down
4 changes: 3 additions & 1 deletion test/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,9 @@ func copyEnvironment(t *testing.T, environmentPath string) string {
return err
}

if info.IsDir() {
// The info.Mode() check is to catch symlinks to directories:
// https://stackoverflow.com/questions/32908277/fileinfo-isdir-isnt-detecting-directory
if info.IsDir() || (info.Mode()&os.ModeSymlink) == os.ModeSymlink {
return nil
}

Expand Down

0 comments on commit e0069c0

Please sign in to comment.