Skip to content

Commit

Permalink
Fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Artem Vang committed Mar 31, 2022
2 parents c52252b + 0810da8 commit 6cdb9ae
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 13 deletions.
8 changes: 5 additions & 3 deletions CHANGELOG.md
Expand Up @@ -10,14 +10,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- **New resource:** `scalr_account_allowed_ips` ([#111](https://github.com/Scalr/terraform-provider-scalr/pull/111))
- `scalr_workspace`: added new attribute `run_operation_timeout`

### Changed

- `resource.scalr_role`: added new state migration (include `accounts:set-quotas` permission if needed) ([#116](https://github.com/Scalr/terraform-provider-scalr/pull/108))

### Fixed

- Correctly handle not found resources ([#117](https://github.com/Scalr/terraform-provider-scalr/pull/117))

### Changed
- `resource.scalr_role`: added new state migration (include `accounts:set-quotas` permission if needed) ([#116](https://github.com/Scalr/terraform-provider-scalr/pull/108))

### Required

- scalr-server >= `8.15.0`
Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/scalr_workspace.md
Expand Up @@ -35,6 +35,7 @@ All arguments plus:
* `operations` - Boolean indicates if the workspace is being used for remote execution.
* `terraform_version` - The version of Terraform used for this workspace.
* `working_directory` - A relative path that Terraform will execute within.
* `run_operation_timeout` - The number of minutes run operation can be executed before termination.
* `module_version_id` - The identifier of a module version in the format `modver-<RANDOM STRING>`.
* `vcs_provider_id` - The identifier of a VCS provider in the format `vcs-<RANDOM STRING>`.
* `vcs_repo` - If workspace is linked to VCS repository this block shows the details, otherwise `{}`
Expand Down
1 change: 1 addition & 0 deletions docs/resources/scalr_workspace.md
Expand Up @@ -96,6 +96,7 @@ resource "scalr_workspace" "cli-driven" {
Defaults to `true`.
* `terraform_version` - (Optional) The version of Terraform to use for this workspace. Defaults to the latest available version.
* `working_directory` - (Optional) A relative path that Terraform will be run in. Defaults to the root of the repository `""`.
* `run_operation_timeout` - (Optional) The number of minutes run operation can be executed before termination. Defaults to `0` (not set, backend default is used).
* `module_version_id` - (Optional) The identifier of a module version in the format `modver-<RANDOM STRING>`. This attribute conflicts with `vcs_provider_id` and `vcs_repo` attributes.
* `agent_pool_id` - (Optional) The identifier of an agent pool in the format `apool-<RANDOM STRING>`.
* `vcs_provider_id` - (Optional) ID of vcs provider - required if vcs-repo present and vice versa, in the format `vcs-<RANDOM STRING>`
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -5,7 +5,7 @@ require (
github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce
github.com/hashicorp/terraform-plugin-sdk v1.17.2
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734
github.com/scalr/go-scalr v0.0.0-20220328095152-4e6e6133123d
github.com/scalr/go-scalr v0.0.0-20220331085920-4ec72236c661
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Expand Up @@ -299,8 +299,8 @@ github.com/posener/complete v1.2.1 h1:LrvDIY//XNo65Lq84G/akBuMGlawHvGBABv8f/ZN6D
github.com/posener/complete v1.2.1/go.mod h1:6gapUrK/U1TAN7ciCoNRIdVC5sbdBTUh1DKN0g6uH7E=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/scalr/go-scalr v0.0.0-20220328095152-4e6e6133123d h1:Cz9pzV5kcXw/rxai/gK7nIjyNOv7vA8+CH4kQqZuaL8=
github.com/scalr/go-scalr v0.0.0-20220328095152-4e6e6133123d/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE=
github.com/scalr/go-scalr v0.0.0-20220331085920-4ec72236c661 h1:DnvLMEoIGdre8txCto7ml8mvI/LcIA+uqtdhXRDUY3o=
github.com/scalr/go-scalr v0.0.0-20220331085920-4ec72236c661/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
Expand Down
18 changes: 17 additions & 1 deletion scalr/resource_scalr_workspace.go
Expand Up @@ -187,6 +187,10 @@ func resourceScalrWorkspace() *schema.Resource {
},
},
},
"run_operation_timeout": {
Type: schema.TypeInt,
Optional: true,
},
},
}
}
Expand Down Expand Up @@ -232,6 +236,10 @@ func resourceScalrWorkspaceCreate(d *schema.ResourceData, meta interface{}) erro
options.WorkingDirectory = scalr.String(workingDir.(string))
}

if runOperationTimeout, ok := d.GetOk("run_operation_timeout"); ok {
options.RunOperationTimeout = scalr.Int(runOperationTimeout.(int))
}

if v, ok := d.GetOk("module_version_id"); ok {
options.ModuleVersion = &scalr.ModuleVersion{ID: v.(string)}
}
Expand Down Expand Up @@ -316,6 +324,10 @@ func resourceScalrWorkspaceRead(d *schema.ResourceData, meta interface{}) error
d.Set("environment_id", workspace.Environment.ID)
d.Set("has_resources", workspace.HasResources)

if workspace.RunOperationTimeout != nil {
d.Set("run_operation_timeout", &workspace.RunOperationTimeout)
}

if workspace.VcsProvider != nil {
d.Set("vcs_provider_id", workspace.VcsProvider.ID)
}
Expand Down Expand Up @@ -375,7 +387,7 @@ func resourceScalrWorkspaceUpdate(d *schema.ResourceData, meta interface{}) erro
d.HasChange("terraform_version") || d.HasChange("working_directory") ||
d.HasChange("vcs_repo") || d.HasChange("operations") ||
d.HasChange("vcs_provider_id") || d.HasChange("agent_pool_id") ||
d.HasChange("hooks") || d.HasChange("module_version_id") {
d.HasChange("hooks") || d.HasChange("module_version_id") || d.HasChange("run_operation_timeout") {
// Create a new options struct.
options := scalr.WorkspaceUpdateOptions{
Name: scalr.String(d.Get("name").(string)),
Expand All @@ -396,6 +408,10 @@ func resourceScalrWorkspaceUpdate(d *schema.ResourceData, meta interface{}) erro

options.WorkingDirectory = scalr.String(d.Get("working_directory").(string))

if runOperationTimeout, ok := d.GetOk("run_operation_timeout"); ok {
options.RunOperationTimeout = scalr.Int(runOperationTimeout.(int))
}

if vcsProviderId, ok := d.GetOk("vcs_provider_id"); ok {
options.VcsProvider = &scalr.VcsProvider{
ID: vcsProviderId.(string),
Expand Down
24 changes: 18 additions & 6 deletions scalr/resource_scalr_workspace_test.go
Expand Up @@ -34,6 +34,8 @@ func TestAccScalrWorkspace_basic(t *testing.T) {
"scalr_workspace.test", "operations", "true"),
resource.TestCheckResourceAttr(
"scalr_workspace.test", "working_directory", ""),
resource.TestCheckResourceAttr(
"scalr_workspace.test", "run_operation_timeout", "18"),
resource.TestCheckResourceAttr(
"scalr_workspace.test", "hooks.0.pre_plan", "./scripts/pre-plan.sh"),
resource.TestCheckResourceAttr(
Expand Down Expand Up @@ -72,6 +74,7 @@ func TestAccScalrWorkspace_monorepo(t *testing.T) {
"scalr_workspace.test", "operations", "true"),
resource.TestCheckResourceAttr(
"scalr_workspace.test", "working_directory", "/db"),
resource.TestCheckNoResourceAttr("scalr_workspace.test", "run_operation_timeout"),
),
},
},
Expand Down Expand Up @@ -159,6 +162,8 @@ func TestAccScalrWorkspace_update(t *testing.T) {
resource.TestCheckResourceAttr("scalr_workspace.test", "auto_apply", "true"),
resource.TestCheckResourceAttr("scalr_workspace.test", "operations", "true"),
resource.TestCheckResourceAttr("scalr_workspace.test", "working_directory", ""),
resource.TestCheckResourceAttr(
"scalr_workspace.test", "run_operation_timeout", "18"),
resource.TestCheckResourceAttr(
"scalr_workspace.test", "hooks.0.pre_plan", "./scripts/pre-plan.sh"),
resource.TestCheckResourceAttr(
Expand Down Expand Up @@ -186,6 +191,8 @@ func TestAccScalrWorkspace_update(t *testing.T) {
"scalr_workspace.test", "terraform_version", "0.12.19"),
resource.TestCheckResourceAttr(
"scalr_workspace.test", "working_directory", "terraform/test"),
resource.TestCheckResourceAttr(
"scalr_workspace.test", "run_operation_timeout", "200"),
resource.TestCheckResourceAttr(
"scalr_workspace.test", "hooks.0.pre_plan", "./scripts/pre-plan_updated.sh"),
resource.TestCheckResourceAttr(
Expand Down Expand Up @@ -213,6 +220,8 @@ func TestAccScalrWorkspace_update(t *testing.T) {
"scalr_workspace.test", "terraform_version", "0.12.19"),
resource.TestCheckResourceAttr(
"scalr_workspace.test", "working_directory", "terraform/test"),
resource.TestCheckResourceAttr(
"scalr_workspace.test", "run_operation_timeout", "0"),
resource.TestCheckNoResourceAttr("scalr_workspace.test", "hooks"),
),
},
Expand Down Expand Up @@ -417,9 +426,10 @@ resource scalr_environment test {
func testAccScalrWorkspaceBasic(rInt int) string {
return fmt.Sprintf(testAccScalrWorkspaceCommonConfig, rInt, defaultAccount, `
resource scalr_workspace test {
name = "workspace-test"
environment_id = scalr_environment.test.id
auto_apply = true
name = "workspace-test"
environment_id = scalr_environment.test.id
auto_apply = true
run_operation_timeout = 18
hooks {
pre_plan = "./scripts/pre-plan.sh"
post_plan = "./scripts/post-plan.sh"
Expand All @@ -441,9 +451,10 @@ resource "scalr_workspace" "test" {
func testAccScalrWorkspaceRenamed(rInt int) string {
return fmt.Sprintf(testAccScalrWorkspaceCommonConfig, rInt, defaultAccount, `
resource "scalr_workspace" "test" {
name = "renamed-out-of-band"
environment_id = scalr_environment.test.id
auto_apply = true
name = "renamed-out-of-band"
environment_id = scalr_environment.test.id
auto_apply = true
run_operation_timeout = 18
hooks {
pre_plan = "./scripts/pre-plan.sh"
post_plan = "./scripts/post-plan.sh"
Expand All @@ -462,6 +473,7 @@ resource "scalr_workspace" "test" {
operations = false
terraform_version = "0.12.19"
working_directory = "terraform/test"
run_operation_timeout = 200
hooks {
pre_plan = "./scripts/pre-plan_updated.sh"
post_plan = "./scripts/post-plan_updated.sh"
Expand Down

0 comments on commit 6cdb9ae

Please sign in to comment.