Skip to content

Commit

Permalink
Incorporate review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
bwhaley committed Jul 28, 2021
1 parent a166b40 commit 950fddf
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions modules/packer/packer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"errors"
"fmt"
"io/ioutil"
"log"
"os"
"regexp"
"sync"
"time"

"github.com/gruntwork-io/terratest/modules/retry"
"github.com/hashicorp/go-multierror"
"github.com/stretchr/testify/require"

"github.com/gruntwork-io/terratest/modules/logger"
"github.com/gruntwork-io/terratest/modules/shell"
Expand Down Expand Up @@ -106,9 +106,7 @@ func BuildArtifactE(t testing.TestingT, options *Options) (string, error) {
const packerPluginPathEnvVar = "PACKER_PLUGIN_PATH"
options.Logger.Logf(t, "Creating a temporary directory for Packer plugins")
pluginDir, err := ioutil.TempDir("", "terratest-packer-")
if err != nil {
log.Fatal(err)
}
require.NoError(t, err)
if len(options.Env) == 0 {
options.Env = make(map[string]string)
}
Expand Down Expand Up @@ -189,14 +187,10 @@ func hasPackerInit(t testing.TestingT, options *Options) (bool, error) {
Env: options.Env,
WorkingDir: options.WorkingDir,
}
description := fmt.Sprintf("%s %v", cmd.Command, cmd.Args)
localVersion, err := retry.DoWithRetryableErrorsE(t, description, options.RetryableErrors, options.MaxRetries, options.TimeBetweenRetries, func() (string, error) {
return shell.RunCommandAndGetOutputE(t, cmd)
})
localVersion, err := shell.RunCommandAndGetOutputE(t, cmd)
if err != nil {
return false, err
}

thisVersion, err := version.NewVersion(localVersion)
if err != nil {
return false, err
Expand All @@ -220,16 +214,14 @@ func packerInit(t testing.TestingT, options *Options) error {
return nil
}

options.Logger.Logf(t, "Running Packer init")

cmd := shell.Command{
Command: "packer",
Args: []string{"init", options.Template},
Env: options.Env,
WorkingDir: options.WorkingDir,
}

description := fmt.Sprintf("%s %v", cmd.Command, cmd.Args)
description := "Running Packer init"
_, err = retry.DoWithRetryableErrorsE(t, description, options.RetryableErrors, options.MaxRetries, options.TimeBetweenRetries, func() (string, error) {
return shell.RunCommandAndGetOutputE(t, cmd)
})
Expand Down

0 comments on commit 950fddf

Please sign in to comment.