Skip to content

Commit 6e830cc

Browse files
authored
Merge branch 'main' into hs26gill/TF-31708-Add-the-ProjectRemoteState
2 parents ba51bee + 0998908 commit 6e830cc

File tree

6 files changed

+64
-28
lines changed

6 files changed

+64
-28
lines changed

.github/actions/test-go-tfe/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ runs:
107107
TFE_ADMIN_SUPPORT_TOKEN: ${{ inputs.admin_support_token }}
108108
TFE_ADMIN_VERSION_MAINTENANCE_TOKEN: ${{ inputs.admin_version_maintenance_token }}
109109
TFC_RUN_TASK_URL: "http://testing-mocks.tfe:22180/runtasks/pass"
110-
GITHUB_POLICY_SET_IDENTIFIER: "hashicorp/test-policy-set"
111-
GITHUB_REGISTRY_MODULE_IDENTIFIER: "hashicorp/terraform-random-module"
110+
GITHUB_POLICY_SET_IDENTIFIER: "Maed223/test-policy-set"
111+
GITHUB_REGISTRY_MODULE_IDENTIFIER: "Maed223/terraform-random-module"
112112
GITHUB_REGISTRY_NO_CODE_MODULE_IDENTIFIER: "hashicorp/terraform-random-no-code-module"
113113
OAUTH_CLIENT_GITHUB_TOKEN: "${{ inputs.oauth-client-github-token }}"
114114
SKIP_HYOK_INTEGRATION_TESTS: "${{ inputs.skip-hyok-integration-tests }}"

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ jobs:
118118
TFE_ADMIN_SUPPORT_TOKEN: ${{ fromJSON(steps.tflocal.outputs.workspace-outputs-json).tfe_admin_token_by_role.support }}
119119
TFE_ADMIN_VERSION_MAINTENANCE_TOKEN: ${{ fromJSON(steps.tflocal.outputs.workspace-outputs-json).tfe_admin_token_by_role.version-maintenance }}
120120
TFC_RUN_TASK_URL: "http://testing-mocks.tfe:22180/runtasks/pass"
121-
GITHUB_POLICY_SET_IDENTIFIER: "hashicorp/test-policy-set"
122-
GITHUB_REGISTRY_MODULE_IDENTIFIER: "hashicorp/terraform-random-module"
121+
GITHUB_POLICY_SET_IDENTIFIER: "Maed223/test-policy-set"
122+
GITHUB_REGISTRY_MODULE_IDENTIFIER: "Maed223/terraform-random-module"
123123
GITHUB_REGISTRY_NO_CODE_MODULE_IDENTIFIER: "hashicorp/terraform-random-no-code-module"
124124
OAUTH_CLIENT_GITHUB_TOKEN: "${{ secrets.OAUTH_CLIENT_GITHUB_TOKEN }}"
125125
GO111MODULE: "on"

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
# Unreleased
22

3-
* Remove org settings validation in RegistryModulesCreateMonorepo tests, by @jillirami ([#1236](https://github.com/hashicorp/go-tfe/pull/1236))
3+
## Enhancements
4+
45
* Add BETA `ProjectRemoteState` attribute to `Workspace` by @hs26gill [#1248](https://github.com/hashicorp/go-tfe/pull/1248)
56

7+
# v1.96.0
8+
9+
## Enhancements
10+
11+
* QueryRun API is now generally available in HCP Terraform (not available in Terraform Enterprise), by @sowju-hashicorp [#1245](https://github.com/hashicorp/go-tfe/pull/1245)
12+
13+
* Remove org settings validation in RegistryModulesCreateMonorepo tests, by @jillirami ([#1236](https://github.com/hashicorp/go-tfe/pull/1236))
14+
* Add `RemoteTFENumericVersion()` to the `Client` interface, which exposes the `X-TFE-Current-Version` header set by a remote TFE instance by @skj-skj [#1246](https://github.com/hashicorp/go-tfe/pull/1246)
15+
616
# v1.95.0
717

818
## Enhancements

query_runs.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ var _ QueryRuns = (*queryRuns)(nil)
1717
// QueryRuns describes all the run related methods that the Terraform Enterprise
1818
// API supports.
1919
//
20-
// NOTE WELL: This is a beta feature and is subject to change until noted otherwise in the
21-
// release notes.
20+
// TFE API docs:
21+
// https://developer.hashicorp.com/terraform/cloud-docs/api-docs/query-runs
2222
type QueryRuns interface {
2323
// List all the query runs of the given workspace.
2424
List(ctx context.Context, workspaceID string, options *QueryRunListOptions) (*QueryRunList, error)

tfe.go

Lines changed: 42 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ import (
3232
)
3333

3434
const (
35-
_userAgent = "go-tfe"
36-
_headerRateLimit = "X-RateLimit-Limit"
37-
_headerRateReset = "X-RateLimit-Reset"
38-
_headerAppName = "TFP-AppName"
39-
_headerAPIVersion = "TFP-API-Version"
40-
_headerTFEVersion = "X-TFE-Version"
41-
_includeQueryParam = "include"
35+
_userAgent = "go-tfe"
36+
_headerRateLimit = "X-RateLimit-Limit"
37+
_headerRateReset = "X-RateLimit-Reset"
38+
_headerAppName = "TFP-AppName"
39+
_headerAPIVersion = "TFP-API-Version"
40+
_headerTFEVersion = "X-TFE-Version"
41+
_headerTFENumericVersion = "X-TFE-Current-Version"
42+
_includeQueryParam = "include"
4243

4344
DefaultAddress = "https://app.terraform.io"
4445
DefaultBasePath = "/api/v2/"
@@ -111,17 +112,18 @@ func DefaultConfig() *Config {
111112
// Client is the Terraform Enterprise API client. It provides the basic
112113
// connectivity and configuration for accessing the TFE API
113114
type Client struct {
114-
baseURL *url.URL
115-
registryBaseURL *url.URL
116-
token string
117-
headers http.Header
118-
http *retryablehttp.Client
119-
limiter *rate.Limiter
120-
retryLogHook RetryLogHook
121-
retryServerErrors bool
122-
remoteAPIVersion string
123-
remoteTFEVersion string
124-
appName string
115+
baseURL *url.URL
116+
registryBaseURL *url.URL
117+
token string
118+
headers http.Header
119+
http *retryablehttp.Client
120+
limiter *rate.Limiter
121+
retryLogHook RetryLogHook
122+
retryServerErrors bool
123+
remoteAPIVersion string
124+
remoteTFEVersion string
125+
remoteTFENumericVersion string
126+
appName string
125127

126128
Admin Admin
127129
Agents Agents
@@ -449,6 +451,9 @@ func NewClient(cfg *Config) (*Client, error) {
449451
// Save the TFE version
450452
client.remoteTFEVersion = meta.TFEVersion
451453

454+
// Save the TFE Numeric version
455+
client.remoteTFENumericVersion = meta.TFENumericVersion
456+
452457
// Save the app name
453458
client.appName = meta.AppName
454459

@@ -613,7 +618,7 @@ func (c *Client) SetFakeRemoteAPIVersion(fakeAPIVersion string) {
613618
c.remoteAPIVersion = fakeAPIVersion
614619
}
615620

616-
// RemoteTFEVersion returns the server's declared TFE version string.
621+
// RemoteTFEVersion returns the server's declared TFE monthly version string.
617622
//
618623
// A Terraform Enterprise API server includes its current version in an
619624
// HTTP header field in all responses. This value is saved by the client
@@ -624,6 +629,17 @@ func (c Client) RemoteTFEVersion() string {
624629
return c.remoteTFEVersion
625630
}
626631

632+
// RemoteTFENumericVersion returns the server's declared TFE version string.
633+
//
634+
// A Terraform Enterprise API server includes its current numeric version in an
635+
// HTTP header field in all responses. This value is saved by the client
636+
// during the initial setup request and RemoteTFENumericVersion returns that cached
637+
// value. This function returns an empty string for any Terraform Enterprise version
638+
// earlier than 1.0.3 and for HCP Terraform.
639+
func (c Client) RemoteTFENumericVersion() string {
640+
return c.remoteTFENumericVersion
641+
}
642+
627643
// RetryServerErrors configures the retry HTTP check to also retry
628644
// unexpected errors or requests that failed with a server error.
629645
func (c *Client) RetryServerErrors(retry bool) {
@@ -699,11 +715,16 @@ type rawAPIMetadata struct {
699715
// field was not included in the response.
700716
APIVersion string
701717

702-
// TFEVersion is the raw TFE version string reported by the server in the
718+
// TFEVersion is the raw TFE monthly version string reported by the server in the
703719
// X-TFE-Version response header, or an empty string if that header
704720
// field was not included in the response.
705721
TFEVersion string
706722

723+
// TFENumericVersion is the raw TFE Numeric version string reported by the server in the
724+
// X-TFE-Current-Version response header, or an empty string if that header
725+
// field was not included in the response.
726+
TFENumericVersion string
727+
707728
// RateLimit is the raw API version string reported by the server in the
708729
// X-RateLimit-Limit response header, or an empty string if that header
709730
// field was not included in the response.
@@ -743,6 +764,7 @@ func (c *Client) getRawAPIMetadata() (rawAPIMetadata, error) {
743764
meta.APIVersion = resp.Header.Get(_headerAPIVersion)
744765
meta.RateLimit = resp.Header.Get(_headerRateLimit)
745766
meta.TFEVersion = resp.Header.Get(_headerTFEVersion)
767+
meta.TFENumericVersion = resp.Header.Get(_headerTFENumericVersion)
746768
meta.AppName = resp.Header.Get(_headerAppName)
747769

748770
return meta, nil

tfe_integration_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ func TestClient_newClient(t *testing.T) {
2525
w.Header().Set("X-RateLimit-Limit", "30")
2626
w.Header().Set("TFP-API-Version", "34.21.9")
2727
w.Header().Set("X-TFE-Version", "202205-1")
28+
w.Header().Set("X-TFE-Current-Version", "1.1.0")
2829
if enterpriseEnabled() {
2930
w.Header().Set("TFP-AppName", "Terraform Enterprise")
3031
} else {
@@ -87,7 +88,10 @@ func TestClient_newClient(t *testing.T) {
8788
t.Errorf("unexpected remote API version %q; want %q", client.RemoteAPIVersion(), want)
8889
}
8990
if want := "202205-1"; client.RemoteTFEVersion() != want {
90-
t.Errorf("unexpected remote TFE version %q; want %q", client.RemoteTFEVersion(), want)
91+
t.Errorf("unexpected remote TFE monthly version %q; want %q", client.RemoteTFEVersion(), want)
92+
}
93+
if want := "1.1.0"; client.RemoteTFENumericVersion() != want {
94+
t.Errorf("unexpected remote TFE numeric version %q; want %q", client.RemoteTFENumericVersion(), want)
9195
}
9296

9397
if enterpriseEnabled() {

0 commit comments

Comments
 (0)