Revert "Bump github.com/hashicorp/go-getter from 1.5.3 to 1.5.4 (#192)"

go-getter 1.5.4 actually requires Go 1.15+, which sadly wasn't mentioned
in the changelog, but it is mentioned in this commit:
https://github.com/hashicorp/go-getter/commit/af95113283f8288987ef82ac9cb141f919c5a484

The PR also didn't trigger relevant check for some reason,
so this was missed prior to merging.

This reverts commit eb250dc1165790a6c5ad89495b084ed2d11e6a3b.
2 files changed
tree: 7edad84ade676854d952e34a62e0640f08b71a4e
  1. .circleci/
  2. .github/
  3. cmd/
  4. internal/
  5. scripts/
  6. tfexec/
  7. tfinstall/
  8. .gitignore
  9. .goreleaser.yml
  10. CHANGELOG.md
  11. CONTRIBUTING.md
  12. go.mod
  13. go.sum
  14. LICENSE
  15. README.md
README.md

PkgGoDev

terraform-exec

A Go module for constructing and running Terraform CLI commands. Structured return values use the data types defined in terraform-json.

The Terraform Plugin SDK is the canonical Go interface for Terraform plugins using the gRPC protocol. This library is intended for use in Go programs that make use of Terraform's other interface, the CLI. Importing this library is preferable to importing github.com/hashicorp/terraform/command, because the latter is not intended for use outside Terraform Core.

While terraform-exec is already widely used, please note that this module is not yet at v1.0.0, and that therefore breaking changes may occur in minor releases.

We strictly follow semantic versioning.

Usage

The Terraform struct must be initialised with NewTerraform(workingDir, execPath).

Top-level Terraform commands each have their own function, which will return either error or (T, error), where T is a terraform-json type.

Example

package main

import (
	"context"
	"fmt"
	"io/ioutil"
	"os"
	"log"

	"github.com/hashicorp/terraform-exec/tfexec"
	"github.com/hashicorp/terraform-exec/tfinstall"
)

func main() {
	tmpDir, err := ioutil.TempDir("", "tfinstall")
	if err != nil {
		log.Fatalf("error creating temp dir: %s", err)
	}
	defer os.RemoveAll(tmpDir)

	execPath, err := tfinstall.Find(context.Background(), tfinstall.LatestVersion(tmpDir, false))
	if err != nil {
		log.Fatalf("error locating Terraform binary: %s", err)
	}

	workingDir := "/path/to/working/dir"
	tf, err := tfexec.NewTerraform(workingDir, execPath)
	if err != nil {
		log.Fatalf("error running NewTerraform: %s", err)
	}

	err = tf.Init(context.Background(), tfexec.Upgrade(true))
	if err != nil {
		log.Fatalf("error running Init: %s", err)
	}

	state, err := tf.Show(context.Background())
	if err != nil {
		log.Fatalf("error running Show: %s", err)
	}

	fmt.Println(state.FormatVersion) // "0.1"
}

Contributing

Please see CONTRIBUTING.md.