Skip to content

Commit 7b6d762

Browse files
Add Source to Workspace (#1189)
* 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]>
1 parent 7fceec6 commit 7b6d762

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Enhancements
44

55
* 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)
6+
* Adds `Source` field to `Workspace` by @jpadrianoGo [#1124](https://github.com/hashicorp/go-tfe/pull/1124)
67
* Adds `IconUrl`, `InstallationType`, and `InstallationURL` to githubAppInstallation, by @jpadrianoGo [#1191](https://github.com/hashicorp/go-tfe/pull/1143)
78
* Adds `CanceledAt`, `RunEvents`, `TriggerReason` field to `Run` by @jpadrianoGo [#1161](https://github.com/hashicorp/go-tfe/pull/1161)
89
* Adds `CreatedAt` field to `AgentPool` by @jpadrianoGo [#1150](https://github.com/hashicorp/go-tfe/pull/1150)

workspace.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,16 @@ type workspaces struct {
151151
client *Client
152152
}
153153

154+
// WorkspaceSource represents a source type of a workspace.
155+
type WorkspaceSource string
156+
157+
const (
158+
WorkspaceSourceAPI WorkspaceSource = "tfe-api"
159+
WorkspaceSourceModule WorkspaceSource = "tfe-module"
160+
WorkspaceSourceUI WorkspaceSource = "tfe-ui"
161+
WorkspaceSourceTerraform WorkspaceSource = "terraform"
162+
)
163+
154164
// WorkspaceList represents a list of workspaces.
155165
type WorkspaceList struct {
156166
*Pagination
@@ -198,6 +208,7 @@ type Workspace struct {
198208
Permissions *WorkspacePermissions `jsonapi:"attr,permissions"`
199209
QueueAllRuns bool `jsonapi:"attr,queue-all-runs"`
200210
SpeculativeEnabled bool `jsonapi:"attr,speculative-enabled"`
211+
Source WorkspaceSource `jsonapi:"attr,source"`
201212
SourceName string `jsonapi:"attr,source-name"`
202213
SourceURL string `jsonapi:"attr,source-url"`
203214
StructuredRunOutputEnabled bool `jsonapi:"attr,structured-run-output-enabled"`

workspace_integration_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,22 @@ func TestWorkspacesRead(t *testing.T) {
10641064
})
10651065
}
10661066

1067+
func TestWorkspacesReadSource(t *testing.T) {
1068+
client := testClient(t)
1069+
ctx := context.Background()
1070+
1071+
orgTest, orgTestCleanup := createOrganization(t, client)
1072+
t.Cleanup(orgTestCleanup)
1073+
1074+
wTest, wTestCleanup := createWorkspace(t, client, orgTest)
1075+
t.Cleanup(wTestCleanup)
1076+
1077+
w, err := client.Workspaces.Read(ctx, orgTest.Name, wTest.Name)
1078+
require.NoError(t, err)
1079+
1080+
assert.Equal(t, WorkspaceSourceAPI, w.Source)
1081+
}
1082+
10671083
func TestWorkspacesReadWithOptions(t *testing.T) {
10681084
client := testClient(t)
10691085
ctx := context.Background()

0 commit comments

Comments
 (0)