Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Enhancements

* Adds `Logs` method to `QueryRuns`, which is EXPERIMENTAL, SUBJECT TO CHANGE, and may not be available to all users by @brandonc [#1186](https://github.com/hashicorp/go-tfe/pull/1186)
* Adds `Source` field to `Workspace` by @jpadrianoGo [#1124](https://github.com/hashicorp/go-tfe/pull/1124)
* Adds `IconUrl`, `InstallationType`, and `InstallationURL` to githubAppInstallation, by @jpadrianoGo [#1191](https://github.com/hashicorp/go-tfe/pull/1143)
* Adds `CanceledAt`, `RunEvents`, `TriggerReason` field to `Run` by @jpadrianoGo [#1161](https://github.com/hashicorp/go-tfe/pull/1161)
* Adds `CreatedAt` field to `AgentPool` by @jpadrianoGo [#1150](https://github.com/hashicorp/go-tfe/pull/1150)
Expand Down
11 changes: 11 additions & 0 deletions workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,16 @@ type workspaces struct {
client *Client
}

// WorkspaceSource represents a source type of a workspace.
type WorkspaceSource string

const (
WorkspaceSourceAPI WorkspaceSource = "tfe-api"
WorkspaceSourceModule WorkspaceSource = "tfe-module"
WorkspaceSourceUI WorkspaceSource = "tfe-ui"
WorkspaceSourceTerraform WorkspaceSource = "terraform"
)

// WorkspaceList represents a list of workspaces.
type WorkspaceList struct {
*Pagination
Expand Down Expand Up @@ -198,6 +208,7 @@ type Workspace struct {
Permissions *WorkspacePermissions `jsonapi:"attr,permissions"`
QueueAllRuns bool `jsonapi:"attr,queue-all-runs"`
SpeculativeEnabled bool `jsonapi:"attr,speculative-enabled"`
Source WorkspaceSource `jsonapi:"attr,source"`
SourceName string `jsonapi:"attr,source-name"`
SourceURL string `jsonapi:"attr,source-url"`
StructuredRunOutputEnabled bool `jsonapi:"attr,structured-run-output-enabled"`
Expand Down
16 changes: 16 additions & 0 deletions workspace_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,22 @@ func TestWorkspacesRead(t *testing.T) {
})
}

func TestWorkspacesReadSource(t *testing.T) {
client := testClient(t)
ctx := context.Background()

orgTest, orgTestCleanup := createOrganization(t, client)
t.Cleanup(orgTestCleanup)

wTest, wTestCleanup := createWorkspace(t, client, orgTest)
t.Cleanup(wTestCleanup)

w, err := client.Workspaces.Read(ctx, orgTest.Name, wTest.Name)
require.NoError(t, err)

assert.Equal(t, WorkspaceSourceAPI, w.Source)
}

func TestWorkspacesReadWithOptions(t *testing.T) {
client := testClient(t)
ctx := context.Background()
Expand Down
Loading