Skip to content

Conversation

ctrombley
Copy link
Collaborator

@ctrombley ctrombley commented Aug 20, 2025

Description

This PR adds Source field to Workspace struct, originally by @jpadrianoGo (#1124).

Testing plan

  1. Generate the required environment variables for go test, TFE_ADDRESS and TFE_TOKEN
  2. Run TFE_ADDRESS="https://example" TFE_TOKEN="example" go test ./... -v -run TestWorkspacesReadSource. The new tests should pass.
  3. Source is read for Workspaces.
{
  "data": {
    "id": "ws-***",
    "type": "workspaces",
    "attributes": {
      "allow-destroy-plan": true,
      "auto-apply": false,
      "auto-apply-run-trigger": false,
      "auto-destroy-activity-duration": null,
      "auto-destroy-at": null,
      "auto-destroy-status": null,
      "inherits-project-auto-destroy": true,
      "created-at": "2025-06-03T08:42:47.572Z",
      "environment": "default",
      "locked": false,
      "name": "wsTest",
      "queue-all-runs": false,
      "speculative-enabled": true,
      "structured-run-output-enabled": true,
      "terraform-version": "1.12.1",
      "working-directory": null,
      "global-remote-state": false,
      "updated-at": "2025-06-03T08:42:47.572Z",
      "resource-count": 0,
      "apply-duration-average": null,
      "plan-duration-average": null,
      "policy-check-failures": null,
      "run-failures": null,
      "workspace-kpis-runs-count": null,
      "unarchived-workspace-change-requests-count": 0,
      "latest-change-at": "2025-06-03T08:42:47.572Z",
      "operations": true,
      "execution-mode": "remote",
      "vcs-repo": null,
      "vcs-repo-identifier": null,
      "permissions": {
        "can-update": true,
        "can-destroy": true,
        "can-queue-run": true,
        "can-read-run": true,
        "can-read-variable": true,
        "can-update-variable": true,
        "can-read-state-versions": true,
        "can-read-state-outputs": true,
        "can-create-state-versions": true,
        "can-queue-apply": true,
        "can-lock": true,
        "can-unlock": true,
        "can-force-unlock": true,
        "can-read-settings": true,
        "can-manage-tags": true,
        "can-manage-run-tasks": true,
        "can-force-delete": true,
        "can-manage-assessments": true,
        "can-manage-ephemeral-workspaces": false,
        "can-read-assessment-results": true,
        "can-read-change-requests": false,
        "can-update-change-requests": false,
        "can-queue-destroy": true
      },
      "actions": {
        "is-destroyable": true
      },
      "description": null,
      "file-triggers-enabled": true,
      "trigger-prefixes": [],
      "trigger-patterns": [],
      "assessments-enabled": false,
      "last-assessment-result-at": null,
      "locked-reason": "",
      "source": "tfe-api",
      "source-name": null,
      "tag-names": [],
      "setting-overwrites": {
        "execution-mode": false,
        "agent-pool": false
      }
    },
    "relationships": {
      "organization": {
        "data": {
          "id": "orgTest",
          "type": "organizations"
        }
      },
      "current-run": {
        "data": null
      },
      "latest-run": {
        "data": null
      },
      "outputs": {
        "data": []
      },
      "remote-state-consumers": {
        "links": {
          "related": "/api/v2/workspaces/ws-***/relationships/remote-state-consumers"
        }
      },
      "current-state-version": {
        "data": null
      },
      "current-configuration-version": {
        "data": null
      },
      "agent-pool": {
        "data": null
      },
      "readme": {
        "data": null
      },
      "project": {
        "data": {
          "id": "prj-***",
          "type": "projects"
        }
      },
      "current-assessment-result": {
        "data": null
      },
      "vars": {
        "data": []
      }
    },
    "links": {
      "self": "/api/v2/organizations/orgTest/workspaces/wsTest",
      "self-html": "/app/orgTest/workspaces/wsTest"
    }
  }
}

External links

Output from tests

Including output from tests may require access to a TFE instance. Ignore this section if you have no environment to test against.

$ TFE_ADDRESS="https://example" TFE_TOKEN="example"go test ./... -v -run TestWorkspacesReadSource

=== RUN   TestWorkspacesReadSource
--- PASS: TestWorkspacesReadSource (3.86s)
PASS
ok      github.com/hashicorp/go-tfe     3.910s

@ctrombley ctrombley self-assigned this Aug 20, 2025
@ctrombley ctrombley requested a review from a team as a code owner August 20, 2025 15:33
Maed223
Maed223 previously approved these changes Aug 22, 2025
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! Didn't know about the no code module source, but it checks out 💯

@ctrombley ctrombley merged commit 7b6d762 into main Aug 22, 2025
8 checks passed
@ctrombley ctrombley deleted the workspace/source branch August 22, 2025 19:38
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.

mutahhir pushed a commit that referenced this pull request Sep 2, 2025
* Added source to workspace

* Updated changelog

* Updated changelog

* Updated changelog

* Updated changelog

* Updated changelog

* Updated changelog

* Updated changelog

---------

Co-authored-by: jpadrianoGo <[email protected]>
Co-authored-by: JP Adriano <[email protected]>
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.

3 participants