Skip to content

Commit 9b9580d

Browse files
authored
Merge branch 'main' into main
2 parents 2a9e052 + f88988b commit 9b9580d

File tree

9 files changed

+101
-5
lines changed

9 files changed

+101
-5
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jobs:
7676
run: jrm ./ci-summary-provider.xml "junit-test-summary-0/*.xml" "junit-test-summary-1/*.xml" "junit-test-summary-2/*.xml" "junit-test-summary-3/*.xml" "junit-test-summary-4/*.xml"
7777

7878
- name: Upload test artifacts
79-
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
79+
uses: actions/upload-artifact@89ef406dd8d7e03cfd12d9e0a4a378f454709029 # v4.3.5
8080
with:
8181
name: junit-test-summary
8282
path: ./ci-summary-provider.xml

.github/workflows/create-release-pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
go build -o terraform-provider-tfe
5252
5353
- name: Upload test artifacts
54-
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
54+
uses: actions/upload-artifact@89ef406dd8d7e03cfd12d9e0a4a378f454709029 # v4.3.5
5555
with:
5656
name: terraform-provider-tfe
5757
path: terraform-provider-tfe

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
fetch-depth: 0
1818
- name: Generate Release Notes
1919
run: sed -n -e "1{/# /d;}" -e "2{/^$/d;}" -e "/# $(git describe --abbrev=0 --exclude="$(git describe --abbrev=0 --match='v*.*.*' --tags)" --match='v*.*.*' --tags | tr -d v)/q;p" CHANGELOG.md > release-notes.txt
20-
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
20+
- uses: actions/upload-artifact@89ef406dd8d7e03cfd12d9e0a4a378f454709029 # v4.3.5
2121
with:
2222
name: release-notes
2323
path: release-notes.txt

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
## Unreleased
2+
23
ENHANCEMENTS:
34
* `d/tfe_project`: Add `workspace_names` attribute, by @1natedawg [#1429](https://github.com/hashicorp/terraform-provider-tfe/pull/1429)
45

6+
BUG FIXES:
7+
* `r/tfe_workspace` html_url is now planned to be recomputed when `name` changes. Previously, changed values would show up on the next plan, by @brandonc [1422](https://github.com/hashicorp/terraform-provider-tfe/issues/1422)
8+
59
## v0.57.1
610

711
* `r/tfe_stack` initial support for this BETA feature was released in v0.57.0 but the documentation link was broken and it was not mentioned in the release notes. NOTE: This resource is subject to change and has limited support in HCP Terraform.

internal/provider/provider_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ func TestConfigureEnvOrganization(t *testing.T) {
213213
// The TFE Provider tests use these environment variables, which are set in the
214214
// GitHub Action workflow file .github/workflows/ci.yml.
215215
func testAccGithubPreCheck(t *testing.T) {
216-
skipUnlessAfterDate(t, time.Date(2024, 8, 1, 0, 0, 0, 0, time.UTC))
216+
skipUnlessAfterDate(t, time.Date(2024, 9, 1, 0, 0, 0, 0, time.UTC))
217217

218218
if envGithubToken == "" {
219219
t.Skip("Please set GITHUB_TOKEN to run this test")

internal/provider/resource_tfe_registry_module_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,7 @@ func testAccCheckTFERegistryModuleDestroy(s *terraform.State) error {
10721072
}
10731073

10741074
func testAccPreCheckTFERegistryModule(t *testing.T) {
1075-
skipUnlessAfterDate(t, time.Date(2024, 8, 1, 0, 0, 0, 0, time.UTC))
1075+
skipUnlessAfterDate(t, time.Date(2024, 9, 1, 0, 0, 0, 0, time.UTC))
10761076

10771077
if envGithubToken == "" {
10781078
t.Skip("Please set GITHUB_TOKEN to run this test")

internal/provider/resource_tfe_workspace.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ func resourceTFEWorkspace() *schema.Resource {
6767
return err
6868
}
6969

70+
if d.HasChange("name") {
71+
if err := d.SetNewComputed("html_url"); err != nil {
72+
return err
73+
}
74+
}
75+
7076
return nil
7177
},
7278

internal/provider/resource_tfe_workspace_test.go

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,35 @@ func TestAccTFEWorkspace_customProject(t *testing.T) {
203203
})
204204
}
205205

206+
func TestAccTFEWorkspace_HTMLURL(t *testing.T) {
207+
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
208+
209+
// When name is changed, the html_url should be updated as well
210+
resource.Test(t, resource.TestCase{
211+
PreCheck: func() { testAccPreCheck(t) },
212+
Providers: testAccProviders,
213+
CheckDestroy: testAccCheckTFEWorkspaceDestroy,
214+
Steps: []resource.TestStep{
215+
{
216+
Config: testAccTFEWorkspace_HTMLURL(rInt),
217+
Check: resource.ComposeTestCheckFunc(
218+
resource.TestCheckResourceAttr("tfe_workspace.foobar", "name", "workspace-test"),
219+
resource.TestCheckResourceAttrPair("tfe_workspace.foobar", "html_url", "tfe_project.foobar", "description"),
220+
testAccCheckTFEWorkspaceHTMLURLHasSuffix("tfe_workspace.foobar", "workspace-test"),
221+
),
222+
},
223+
{
224+
Config: testAccTFEWorkspace_HTMLURLRenamed(rInt),
225+
Check: resource.ComposeTestCheckFunc(
226+
resource.TestCheckResourceAttr("tfe_workspace.foobar", "name", "workspace-test-renamed"),
227+
resource.TestCheckResourceAttrPair("tfe_workspace.foobar", "html_url", "tfe_project.foobar", "description"),
228+
testAccCheckTFEWorkspaceHTMLURLHasSuffix("tfe_workspace.foobar", "workspace-test-renamed"),
229+
),
230+
},
231+
},
232+
})
233+
}
234+
206235
func TestTagValidation(t *testing.T) {
207236
testCases := []struct {
208237
tag string
@@ -2249,6 +2278,22 @@ func TestTFEWorkspace_delete_withoutCanForceDeletePermission(t *testing.T) {
22492278
}
22502279
}
22512280

2281+
func testAccCheckTFEWorkspaceHTMLURLHasSuffix(resourceName, suffix string) resource.TestCheckFunc {
2282+
return func(s *terraform.State) error {
2283+
rs, ok := s.RootModule().Resources[resourceName]
2284+
if !ok {
2285+
return fmt.Errorf("not found: %s", resourceName)
2286+
}
2287+
2288+
url := rs.Primary.Attributes["html_url"]
2289+
if !strings.HasSuffix(url, suffix) {
2290+
return fmt.Errorf("expected %q to have suffix %q", url, suffix)
2291+
}
2292+
2293+
return nil
2294+
}
2295+
}
2296+
22522297
func testAccCheckTFEWorkspaceExists(
22532298
n string, workspace *tfe.Workspace, p *schema.Provider) resource.TestCheckFunc {
22542299
return func(s *terraform.State) error {
@@ -2849,6 +2894,44 @@ resource "tfe_workspace" "foobar" {
28492894
}`, rInt, aart)
28502895
}
28512896

2897+
func testAccTFEWorkspace_HTMLURL(rInt int) string {
2898+
return fmt.Sprintf(`
2899+
resource "tfe_organization" "foobar" {
2900+
name = "tst-terraform-%d"
2901+
2902+
}
2903+
2904+
resource "tfe_project" "foobar" {
2905+
name = "testproject"
2906+
organization = tfe_organization.foobar.id
2907+
description = tfe_workspace.foobar.html_url
2908+
}
2909+
2910+
resource "tfe_workspace" "foobar" {
2911+
name = "workspace-test"
2912+
organization = tfe_organization.foobar.id
2913+
}`, rInt)
2914+
}
2915+
2916+
func testAccTFEWorkspace_HTMLURLRenamed(rInt int) string {
2917+
return fmt.Sprintf(`
2918+
resource "tfe_organization" "foobar" {
2919+
name = "tst-terraform-%d"
2920+
2921+
}
2922+
2923+
resource "tfe_project" "foobar" {
2924+
name = "testproject"
2925+
organization = tfe_organization.foobar.id
2926+
description = tfe_workspace.foobar.html_url
2927+
}
2928+
2929+
resource "tfe_workspace" "foobar" {
2930+
name = "workspace-test-renamed"
2931+
organization = tfe_organization.foobar.id
2932+
}`, rInt)
2933+
}
2934+
28522935
func testAccTFEWorkspace_defaultOrg() string {
28532936
return `
28542937
resource "tfe_workspace" "foobar" {

internal/provider/stack.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
14
package provider
25

36
import (

0 commit comments

Comments
 (0)