The Wayback Machine - https://web.archive.org./web/20220306014455/https://github.com/hashicorp/terraform/commit/83e6703bf77f60660db4465ef50d30c633f800f1
Skip to content
Permalink
Browse files
Remove revision from version command
The revision field is only populated on dev builds so this means
most releases of Terraform have an empty "terraform_revision" field
in the JSON output. Since we recommend developers use go tooling
to `go build` this tool when developing, the revision is not useful
data and so it is removed.
  • Loading branch information
pselle committed Jan 12, 2021
1 parent ae52190 commit 83e6703bf77f60660db4465ef50d30c633f800f1
Showing with 3 additions and 24 deletions.
  1. +0 −1 .tfdev
  2. +0 −7 command/version.go
  3. +1 −3 command/version_test.go
  4. +0 −1 commands.go
  5. +2 −2 main.go
  6. +0 −7 scripts/build.sh
  7. +0 −3 version.go
1 .tfdev
@@ -1,5 +1,4 @@
version_info {
commit_var = "main.GitCommit"
version_var = "github.com/hashicorp/terraform/version.Version"
prerelease_var = "github.com/hashicorp/terraform/version.Prerelease"
}
@@ -16,7 +16,6 @@ import (
type VersionCommand struct {
Meta

Revision string
Version string
VersionPrerelease string
CheckFunc VersionCheckFunc
@@ -25,7 +24,6 @@ type VersionCommand struct {

type VersionOutput struct {
Version string `json:"terraform_version"`
Revision string `json:"terraform_revision"`
Platform string `json:"platform"`
ProviderSelections map[string]string `json:"provider_selections"`
Outdated bool `json:"terraform_outdated"`
@@ -80,10 +78,6 @@ func (c *VersionCommand) Run(args []string) int {
fmt.Fprintf(&versionString, "Terraform v%s", c.Version)
if c.VersionPrerelease != "" {
fmt.Fprintf(&versionString, "-%s", c.VersionPrerelease)

if c.Revision != "" {
fmt.Fprintf(&versionString, " (%s)", c.Revision)
}
}

// We'll also attempt to print out the selected plugin versions. We do
@@ -139,7 +133,6 @@ func (c *VersionCommand) Run(args []string) int {

output := VersionOutput{
Version: versionOutput,
Revision: c.Revision,
Platform: c.Platform.String(),
ProviderSelections: selectionsOutput,
Outdated: outdated,
@@ -142,7 +142,6 @@ func TestVersion_json(t *testing.T) {
expected := strings.TrimSpace(`
{
"terraform_version": "4.5.6",
"terraform_revision": "",
"platform": "aros_riscv64",
"provider_selections": {},
"terraform_outdated": false
@@ -190,7 +189,6 @@ func TestVersion_json(t *testing.T) {
expected = strings.TrimSpace(`
{
"terraform_version": "4.5.6-foo",
"terraform_revision": "",
"platform": "aros_riscv64",
"provider_selections": {
"registry.terraform.io/hashicorp/test1": "7.8.9-beta.2",
@@ -223,7 +221,7 @@ func TestVersion_jsonoutdated(t *testing.T) {
}

actual := strings.TrimSpace(ui.OutputWriter.String())
expected := "{\n \"terraform_version\": \"4.5.6\",\n \"terraform_revision\": \"\",\n \"platform\": \"aros_riscv64\",\n \"provider_selections\": {},\n \"terraform_outdated\": true\n}"
expected := "{\n \"terraform_version\": \"4.5.6\",\n \"platform\": \"aros_riscv64\",\n \"provider_selections\": {},\n \"terraform_outdated\": true\n}"
if actual != expected {
t.Fatalf("wrong output\ngot: %#v\nwant: %#v", actual, expected)
}
@@ -270,7 +270,6 @@ func initCommands(
"version": func() (cli.Command, error) {
return &command.VersionCommand{
Meta: meta,
Revision: GitCommit,
Version: Version,
VersionPrerelease: VersionPrerelease,
Platform: getproviders.CurrentPlatform,
@@ -117,8 +117,8 @@ func wrappedMain() int {
}

log.Printf(
"[INFO] Terraform version: %s %s %s",
Version, VersionPrerelease, GitCommit)
"[INFO] Terraform version: %s %s",
Version, VersionPrerelease)
log.Printf("[INFO] Go runtime version: %s", runtime.Version())
log.Printf("[INFO] CLI args: %#v", os.Args)

@@ -10,10 +10,6 @@ DIR="$( cd -P "$( dirname "$SOURCE" )/.." && pwd )"
# Change into that directory
cd "$DIR"

# Get the git commit
GIT_COMMIT=$(git rev-parse HEAD)
GIT_DIRTY=$(test -n "`git status --porcelain`" && echo "+CHANGES" || true)

# Determine the arch/os combos we're building for
XC_ARCH=${XC_ARCH:-"386 amd64 arm"}
XC_OS=${XC_OS:-linux darwin windows freebsd openbsd solaris}
@@ -29,9 +25,6 @@ mkdir -p bin/
if [[ -n "${TF_DEV}" ]]; then
XC_OS=$(go env GOOS)
XC_ARCH=$(go env GOARCH)

# Allow LD_FLAGS to be appended during development compilations
LD_FLAGS="-X main.GitCommit=${GIT_COMMIT}${GIT_DIRTY} $LD_FLAGS"
fi

if ! which gox > /dev/null; then
@@ -4,9 +4,6 @@ import (
"github.com/hashicorp/terraform/version"
)

// The git commit that was compiled. This will be filled in by the compiler.
var GitCommit string

var Version = version.Version

var VersionPrerelease = version.Prerelease

0 comments on commit 83e6703

Please sign in to comment.