Skip to content

Commit

Permalink
Exclude terraform providers and .git repository when hashing workspace (
Browse files Browse the repository at this point in the history
#197)

* Exclude terraform providers when hashing workspace

* Also exclude .git directories
  • Loading branch information
toastwaffle authored Nov 7, 2023
1 parent a7880a0 commit 39d3807
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/terraform/terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,9 @@ func (h Harness) DeleteCurrentWorkspace(ctx context.Context) error {
return Classify(err)
}

// GenerateChecksum calculates the md5sum of the workspace to see if terraform init needs to run
// GenerateChecksum calculates the md5sum of the workspace (excluding installed providers) to see if terraform init needs to run
func (h Harness) GenerateChecksum(ctx context.Context) (string, error) {
command := "/usr/bin/find . -type f -exec /usr/bin/md5sum {} + | LC_ALL=C /usr/bin/sort | /usr/bin/md5sum | /usr/bin/awk '{print $1}'"
command := "/usr/bin/find . -path ./.git -prune -o -path ./.terraform/providers -prune -o -type f -exec /usr/bin/md5sum {} + | LC_ALL=C /usr/bin/sort | /usr/bin/md5sum | /usr/bin/awk '{print $1}'"
cmd := exec.CommandContext(ctx, "/bin/sh", "-c", command) //nolint:gosec
cmd.Dir = h.Dir

Expand Down

0 comments on commit 39d3807

Please sign in to comment.