Skip to content

Conversation

@skj-skj
Copy link
Contributor

@skj-skj skj-skj commented Nov 7, 2025

Description

from TFE 1.1.0 & 1.0.3, we have added X-TFE-Current-Version header which returns TFE numeric version value. this pr adds new function/method RemoteTFENumericVersion to client interface which returns TFE numeric version string, and for earlier TFE versions the function will return empty string

Testing plan

  1. spin up TFE 1.1.0 or 1.0.3
  2. create token to create admin docker exec -t terraform-enterprise-tfe-1 tfectl admin token
  3. create admin user and grab the user tfe token
    curl -X POST 'https://tfe.example.com/admin/initial-admin-user?token=your-token' -H 'Content-Type: application/json' -d '{"username":"admin","email":"[email protected]","password":"somePASS123!@#"} | jq -r '.token''
  4. create new directory, run:
      go mod init main
      go get github.com/hashicorp/go-tfe@b682c9a94293397c76d083ce9e93f968ef967964
  5. run go mod tidy
  6. create main.go file with below content:
    // Example code to print the remote TFE numeric version.
    package main
    
    import (
        "fmt"
     	"log"
    
    	tfe "github.com/hashicorp/go-tfe"
    )
    
    func main() {
    
    	config := &tfe.Config{
    		Address: "https://tfe.example.com",
     		Token:   "your-tfe-token",
    	}
    
    	client, err := tfe.NewClient(config)
    	if err != nil {
    		log.Fatal(err)
    	}
    
    	fmt.Printf("Remote TFE Numeric Version: %s\n", client.RemoteTFENumericVersion())
    }
  7. run go run main.go

External links

Output from tests

output should be this:

Remote TFE Numeric Version: 1.1.0
// or 
Remote TFE Numeric Version: 1.0.3

screenshot of the above testing plan:
Untitled 5

Rollback Plan

Changes to Security Controls

no

@datadog-terraform-cloud-hashicorp
Copy link

datadog-terraform-cloud-hashicorp bot commented Nov 7, 2025

⚠️ Tests

⚠️ Warnings

❄️ 1 New flaky test detected

TestPlanExportsCreate_RunDependent from plan_export_integration_test.go (Datadog)
Run "run-pU5UkT5bLa4SpPzg" unexpectedly errored

ℹ️ Info

🧪 All tests passed

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: b682c9a | Docs | Was this helpful? Give us feedback!

@skj-skj skj-skj self-assigned this Nov 18, 2025
@skj-skj skj-skj marked this pull request as ready for review November 18, 2025 11:57
@skj-skj skj-skj requested a review from a team as a code owner November 18, 2025 11:57
Copy link
Contributor

@Maed223 Maed223 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good!

@Maed223 Maed223 merged commit 0beb480 into main Nov 19, 2025
28 of 30 checks passed
@Maed223 Maed223 deleted the skj/new-tfe-numeric-version branch November 19, 2025 18:48
@github-actions
Copy link

Reminder to the contributor that merged this PR: if your changes have added important functionality or fixed a relevant bug, open a follow-up PR to update CHANGELOG.md with a note on your changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants