Skip to content

Commit

Permalink
Merge branch 'main' into jfreda/add-team-notification-cfg-resource
Browse files Browse the repository at this point in the history
  • Loading branch information
barrettclark authored Jan 22, 2025
2 parents ce8630a + 9990b80 commit 81c93cb
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: ./.github/actions/lint-provider-tfe

tests:
Expand All @@ -35,7 +35,7 @@ jobs:
organization: hashicorp-v2
workspace: tflocal-terraform-provider-tfe

- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- uses: ./.github/actions/test-provider-tfe
with:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/create-release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
outputs:
version: ${{ steps.remove-leading-v.outputs.version }}
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- uses: actions-ecosystem/action-get-latest-tag@b7c32daec3395a9616f88548363a42652b22d435 # v1.6.0
id: get-latest-tag
Expand All @@ -33,7 +33,7 @@ jobs:
buildBinary:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
Expand Down Expand Up @@ -68,7 +68,7 @@ jobs:
CHECKPOINT_DISABLE: "1"
timeout-minutes: 120
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- run: git config --global user.email "[email protected]"
- run: git config --global user.name "Brandon Croft"
- name: Get yarn cache directory path
Expand Down Expand Up @@ -102,7 +102,7 @@ jobs:
TF_PLUGIN_CACHE_DIR: ${{ steps.global-cache-dir-path.outputs.dir }}/terraform-plugins

- name: Create Pull Request
uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v6.1.0
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7.0.5
with:
commit-message: "cdktf: update documentation"
title: "release: ${{ github.event.inputs.version }}"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout main
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Deploy docs
uses: mhausenblas/mkdocs-deploy-gh-pages@d77dd03172e96abbcdb081d8c948224762033653 # 1.26
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/nightly-tfe-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
organization: hashicorp-v2
workspace: tflocal-terraform-provider-tfe-nightly

- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- uses: ./.github/actions/test-provider-tfe
with:
Expand Down Expand Up @@ -96,7 +96,7 @@ jobs:
needs: [tests-summarize]
if: "${{ always() }}"
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Set up Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
release-notes:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Generate Release Notes
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/resource_tfe_workspace_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func (m validateSelfReference) PlanModifySet(_ context.Context, req planmodifier
}

// Check if the workspace ID is in the set
if slices.Contains(remoteStateConsumerIDs, workspaceID.ValueString()) {
if !workspaceID.IsUnknown() && slices.Contains(remoteStateConsumerIDs, workspaceID.ValueString()) {
resp.Diagnostics.AddError("Invalid remote_state_consumer_ids", "workspace_id cannot be in the set of remote_state_consumer_ids")
}
}
Expand Down
50 changes: 49 additions & 1 deletion internal/provider/resource_tfe_workspace_settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,34 @@ func TestAccTFEWorkspaceSettings(t *testing.T) {
})
}

func TestAccTFEWorkspaceWithSettings(t *testing.T) {
tfeClient, err := getClientUsingEnv()
if err != nil {
t.Fatal(err)
}

org, cleanupOrg := createBusinessOrganization(t, tfeClient)
t.Cleanup(cleanupOrg)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccMuxedProviders,
Steps: []resource.TestStep{
// Start with local execution
{
Config: testAccTFEWorkspaceSettingsUnknownIDRemoteState(org.Name),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet(
"tfe_workspace_settings.foobar", "id"),
resource.TestCheckResourceAttrSet(
"tfe_workspace_settings.foobar", "workspace_id",
),
),
},
},
})
}

func TestAccTFEWorkspaceSettingsRemoteState(t *testing.T) {
tfeClient, err := getClientUsingEnv()
if err != nil {
Expand Down Expand Up @@ -222,7 +250,7 @@ func testAccCheckTFEWorkspaceSettingsDestroy(s *terraform.State) error {
return testAccCheckTFEWorkspaceSettingsDestroyProvider(testAccProvider)(s)
}

func testAccCheckTFEWorkspaceSettingsDestroyProvider(p *schema.Provider) func(s *terraform.State) error {
func testAccCheckTFEWorkspaceSettingsDestroyProvider(_ *schema.Provider) func(s *terraform.State) error {
return func(s *terraform.State) error {
tfeClient, err := getClientUsingEnv()
if err != nil {
Expand Down Expand Up @@ -256,6 +284,26 @@ func testAccCheckTFEWorkspaceSettingsDestroyProvider(p *schema.Provider) func(s
}
}

func testAccTFEWorkspaceSettingsUnknownIDRemoteState(orgName string) string {
return fmt.Sprintf(`
resource "tfe_workspace" "foobar1" {
name = "foobar1"
organization = "%s"
}
resource "tfe_workspace" "foobar2" {
name = "foobar2"
organization = "%s"
}
resource "tfe_workspace_settings" "foobar" {
workspace_id = tfe_workspace.foobar1.id
global_remote_state = false
remote_state_consumer_ids = [tfe_workspace.foobar2.id]
}
`, orgName, orgName)
}

func testAccTFEWorkspaceSettingsRemoteState(workspaceID, workspaceID2 string) string {
return fmt.Sprintf(`
resource "tfe_workspace_settings" "foobar" {
Expand Down

0 comments on commit 81c93cb

Please sign in to comment.