8000 Add Source to Workspace by jpadrianoGo · Pull Request #1124 · hashicorp/go-tfe · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add Source to Workspace #1124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
8000
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* Adds BETA support for approving all plans for a stack deployment run, which is EXPERIMENTAL, SUBJECT TO CHANGE, and may not be available to all users by @ctrombley [#1136](https://github.com/hashicorp/go-tfe/pull/1136)
* Adds BETA support for listing and reading `StackDeploymentSteps`, which is EXPERIMENTAL, SUBJECT TO CHANGE, and may not be available to all users by @ctrombley [#1133](https://github.com/hashicorp/go-tfe/pull/1133)
* Adds BETA support for approving all plans in `StackDeploymentGroups`, which is EXPERIMENTAL, SUBJECT TO CHANGE, and may not be available to all users by @hwatkins05-hashicorp [#1137](https://github.com/hashicorp/go-tfe/pull/1137)
* Adds `Source` field to `Workspace` by @jpadrianoGo [#1124](https://github.com/hashicorp/go-tfe/pull/1124)

## Bug Fixes

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
0