New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add X-TFE-Version header #563
Conversation
CHANGELOG.md
Outdated
@@ -3,6 +3,7 @@ | |||
## Enhancements | |||
|
|||
* Add `NotificationTriggerAssessmentCheckFailed` notification trigger type by @rexredinger [#549](https://github.com/hashicorp/go-tfe/pull/549) | |||
* Add `RemoteTFEVersion()` to the `Client` interface, which exposes the `X-TFE-Version` header set by a remote TFE instance by @sebasslash [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Add `RemoteTFEVersion()` to the `Client` interface, which exposes the `X-TFE-Version` header set by a remote TFE instance by @sebasslash [] | |
* Add `RemoteTFEVersion()` to the `Client` interface, which exposes the `X-TFE-Version` header set by a remote TFE instance by @sebasslash [#563](https://github.com/hashicorp/go-tfe/pull/563) |
@@ -27,6 +27,7 @@ func TestClient_newClient(t *testing.T) { | |||
w.Header().Set("Content-Type", "application/vnd.api+json") | |||
w.Header().Set("X-RateLimit-Limit", "30") | |||
w.Header().Set("TFP-API-Version", "34.21.9") | |||
w.Header().Set("X-TFE-Version", "202205-1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about testing for the case where we have TFC?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue with this is that I'd have restructure most of the test simply to test that a field is an empty string (the test isn't really operating under a TFC vs TFE context).
One nice guarantee we have is that the function that's used to fetch the header http.Response.Header.Get()
returns a string and the docs mention that if a key does not exist the function will return an empty string. So by testing that we can fetch the value of that header we are also inadvertently testing that it can potentially be empty as well since we know that header can be omitted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK - that makes sense - thank you for that explanation.
@annawinkler and I got together today, and we partially tested your PR. We were able to verify the proper behavior for TFC (an empty string returned by the method) by using your code sample. However, we were not able to test the behavior for a TFE instance because we do have access to one. We requested one in the # proj-tfe-releases channel, but the request is pending. |
Oh! Well you can configure your local dev instance as TFE by setting |
5263994
to
dc5fe4f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ Tested with latest tfe test instance and test script and got v202211-1
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. |
Description
Since TFE Version 202208-3, we've included the TFE version string as a header for each response. This PR adds support for the client to retrieve that header during the initial metadata request and cache it locally. That version string can be fetched using the new
Client
method:RemoteTFEVersion()
Testing plan
You can run the integration test:
go test -run TestClient_newClient -v ./... -tags=integration
Optionally, you can test against an actual TFE instance if you have one at your disposal: