Skip to content

Commit

Permalink
Merge pull request #84 from hashicorp/feature/workspace-operations
Browse files Browse the repository at this point in the history
Adding support for configuring operations
  • Loading branch information
sudomateo authored Sep 27, 2019
2 parents 416df13 + 844f52a commit 0289275
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ type WorkspaceCreateOptions struct {
// organization.
Name *string `jsonapi:"attr,name"`

// Whether the workspace will use remote or local execution mode.
Operations *bool `jsonapi:"attr,operations,omitempty"`

// Whether to queue all runs. Unless this is set to true, runs triggered by
// a webhook will not be queued until at least one run is manually queued.
QueueAllRuns *bool `jsonapi:"attr,queue-all-runs,omitempty"`
Expand Down Expand Up @@ -316,6 +319,9 @@ type WorkspaceUpdateOptions struct {
// disabled, any push will trigger a run.
FileTriggersEnabled *bool `jsonapi:"attr,file-triggers-enabled,omitempty"`

// Whether the workspace will use remote or local execution mode.
Operations *bool `jsonapi:"attr,operations,omitempty"`

// Whether to queue all runs. Unless this is set to true, runs triggered by
// a webhook will not be queued until at least one run is manually queued.
QueueAllRuns *bool `jsonapi:"attr,queue-all-runs,omitempty"`
Expand Down
8 changes: 8 additions & 0 deletions workspace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func TestWorkspacesCreate(t *testing.T) {
Name: String("foo"),
AutoApply: Bool(true),
FileTriggersEnabled: Bool(true),
Operations: Bool(true),
QueueAllRuns: Bool(true),
TerraformVersion: String("0.11.0"),
TriggerPrefixes: []string{"/modules", "/shared"},
Expand All @@ -110,6 +111,7 @@ func TestWorkspacesCreate(t *testing.T) {
assert.Equal(t, *options.Name, item.Name)
assert.Equal(t, *options.AutoApply, item.AutoApply)
assert.Equal(t, *options.FileTriggersEnabled, item.FileTriggersEnabled)
assert.Equal(t, *options.Operations, item.Operations)
assert.Equal(t, *options.QueueAllRuns, item.QueueAllRuns)
assert.Equal(t, *options.TerraformVersion, item.TerraformVersion)
assert.Equal(t, options.TriggerPrefixes, item.TriggerPrefixes)
Expand Down Expand Up @@ -256,6 +258,7 @@ func TestWorkspacesUpdate(t *testing.T) {
options := WorkspaceUpdateOptions{
Name: String(wTest.Name),
AutoApply: Bool(true),
Operations: Bool(true),
QueueAllRuns: Bool(true),
TerraformVersion: String("0.10.0"),
}
Expand All @@ -275,6 +278,7 @@ func TestWorkspacesUpdate(t *testing.T) {
Name: String(randomString(t)),
AutoApply: Bool(false),
FileTriggersEnabled: Bool(true),
Operations: Bool(false),
QueueAllRuns: Bool(false),
TerraformVersion: String("0.11.1"),
TriggerPrefixes: []string{"/modules", "/shared"},
Expand All @@ -295,6 +299,7 @@ func TestWorkspacesUpdate(t *testing.T) {
assert.Equal(t, *options.Name, item.Name)
assert.Equal(t, *options.AutoApply, item.AutoApply)
assert.Equal(t, *options.FileTriggersEnabled, item.FileTriggersEnabled)
assert.Equal(t, *options.Operations, item.Operations)
assert.Equal(t, *options.QueueAllRuns, item.QueueAllRuns)
assert.Equal(t, *options.TerraformVersion, item.TerraformVersion)
assert.Equal(t, options.TriggerPrefixes, item.TriggerPrefixes)
Expand Down Expand Up @@ -336,6 +341,7 @@ func TestWorkspacesUpdateByID(t *testing.T) {
options := WorkspaceUpdateOptions{
Name: String(wTest.Name),
AutoApply: Bool(true),
Operations: Bool(true),
QueueAllRuns: Bool(true),
TerraformVersion: String("0.10.0"),
}
Expand All @@ -355,6 +361,7 @@ func TestWorkspacesUpdateByID(t *testing.T) {
Name: String(randomString(t)),
AutoApply: Bool(false),
FileTriggersEnabled: Bool(true),
Operations: Bool(false),
QueueAllRuns: Bool(false),
TerraformVersion: String("0.11.1"),
TriggerPrefixes: []string{"/modules", "/shared"},
Expand All @@ -375,6 +382,7 @@ func TestWorkspacesUpdateByID(t *testing.T) {
assert.Equal(t, *options.Name, item.Name)
assert.Equal(t, *options.AutoApply, item.AutoApply)
assert.Equal(t, *options.FileTriggersEnabled, item.FileTriggersEnabled)
assert.Equal(t, *options.Operations, item.Operations)
assert.Equal(t, *options.QueueAllRuns, item.QueueAllRuns)
assert.Equal(t, *options.TerraformVersion, item.TerraformVersion)
assert.Equal(t, options.TriggerPrefixes, item.TriggerPrefixes)
Expand Down

0 comments on commit 0289275

Please sign in to comment.