Skip to content

Commit

Permalink
Merge branch 'develop' into feature/feature/SCALRCORE-18947
Browse files Browse the repository at this point in the history
  • Loading branch information
petroprotsakh committed Jul 19, 2022
2 parents 5505f39 + 3b7f460 commit 5adf457
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 19 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- `scalr_workspace`: added new attribute `vcs_repo.ingress_submodules` ([#146](https://github.com/Scalr/terraform-provider-scalr/pull/146))
- `data.scalr_workspace`: added new attribute `vcs_repo.ingress_submodules` ([#146](https://github.com/Scalr/terraform-provider-scalr/pull/146))
- `scalr_workspace`: added new attribute `execution-mode` ([#157](https://github.com/Scalr/terraform-provider-scalr/pull/157))
- `data.scalr_workspace`: added new attribute `execution-mode` ([#157](https://github.com/Scalr/terraform-provider-scalr/pull/157))

### Deprecated

Expand Down
5 changes: 3 additions & 2 deletions docs/data-sources/scalr_workspace.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ All arguments plus:

The `hooks` block supports:

* `pre_init` - Script or action configured to call before init phase
* `pre_init` - Script or action configured to call before init phase
* `pre_plan` - Script or action configured to call before plan phase
* `post_plan` - Script or action configured to call after plan phase
* `pre_apply` - Script or action configured to call before apply phase
Expand All @@ -57,9 +57,10 @@ The `vcs_repo` block contains:
* `identifier` - * The reference to the VCS repository in the format `:org/:repo`, this refers to the organization and repository in your VCS provider.
* `path` - Path within the repo, if any.
* `dry_runs_enabled` - Boolean indicates the VCS driven dry runs should run when pull request to configuration versions branch created.
* `ingress_submodules` - Designates whether to clone git submodules of the VCS repository.

The `created_by` block contains:

* `username` - Username of creator.
* `email` - Email address of creator.
* `full_name` - Full name of creator.
* `full_name` - Full name of creator.
1 change: 1 addition & 0 deletions docs/resources/scalr_workspace.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ resource "scalr_workspace" "cli-driven" {
* `path` - (Optional) `Deprecated`: The repository subdirectory that Terraform will execute from. If omitted or submitted as an empty string, this defaults to the repository's root.
* `trigger_prefixes` - (Optional) List of paths (relative to `path`), whose changes will trigger a run for the workspace using this binding when the CV is created. If omitted or submitted as an empty list, any change in `path` will trigger a new run.
* `dry_runs_enabled` - (Optional) Set (true/false) to configure the VCS driven dry runs should run when pull request to configuration versions branch created. Default `true`
* `ingress_submodules` - (Optional) Designates whether to clone git submodules of the VCS repository.

* `hooks` - (Optional) Settings for the workspaces custom hooks.

Expand Down
11 changes: 8 additions & 3 deletions scalr/data_source_workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ func dataSourceScalrWorkspace() *schema.Resource {
Type: schema.TypeBool,
Computed: true,
},
"ingress_submodules": {
Type: schema.TypeBool,
Computed: true,
},
},
},
},
Expand Down Expand Up @@ -189,9 +193,10 @@ func dataSourceScalrWorkspaceRead(d *schema.ResourceData, meta interface{}) erro
var vcsRepo []interface{}
if workspace.VCSRepo != nil {
vcsConfig := map[string]interface{}{
"identifier": workspace.VCSRepo.Identifier,
"path": workspace.VCSRepo.Path,
"dry_runs_enabled": workspace.VCSRepo.DryRunsEnabled,
"identifier": workspace.VCSRepo.Identifier,
"path": workspace.VCSRepo.Path,
"dry_runs_enabled": workspace.VCSRepo.DryRunsEnabled,
"ingress_submodules": workspace.VCSRepo.IngressSubmodules,
}
vcsRepo = append(vcsRepo, vcsConfig)
}
Expand Down
36 changes: 22 additions & 14 deletions scalr/resource_scalr_workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ func resourceScalrWorkspace() *schema.Resource {
Optional: true,
Default: true,
},
"ingress_submodules": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
},
},
},
Expand Down Expand Up @@ -324,10 +329,11 @@ func resourceScalrWorkspaceCreate(d *schema.ResourceData, meta interface{}) erro
}

options.VCSRepo = &scalr.WorkspaceVCSRepoOptions{
Identifier: scalr.String(vcsRepo["identifier"].(string)),
Path: scalr.String(vcsRepo["path"].(string)),
TriggerPrefixes: &triggerPrefixes,
DryRunsEnabled: scalr.Bool(vcsRepo["dry_runs_enabled"].(bool)),
Identifier: scalr.String(vcsRepo["identifier"].(string)),
Path: scalr.String(vcsRepo["path"].(string)),
TriggerPrefixes: &triggerPrefixes,
DryRunsEnabled: scalr.Bool(vcsRepo["dry_runs_enabled"].(bool)),
IngressSubmodules: scalr.Bool(vcsRepo["ingress_submodules"].(bool)),
}

// Only set the branch if one is configured.
Expand Down Expand Up @@ -445,11 +451,12 @@ func resourceScalrWorkspaceRead(d *schema.ResourceData, meta interface{}) error
var vcsRepo []interface{}
if workspace.VCSRepo != nil {
vcsRepo = append(vcsRepo, map[string]interface{}{
"branch": workspace.VCSRepo.Branch,
"identifier": workspace.VCSRepo.Identifier,
"path": workspace.VCSRepo.Path,
"trigger_prefixes": workspace.VCSRepo.TriggerPrefixes,
"dry_runs_enabled": workspace.VCSRepo.DryRunsEnabled,
"branch": workspace.VCSRepo.Branch,
"identifier": workspace.VCSRepo.Identifier,
"path": workspace.VCSRepo.Path,
"trigger_prefixes": workspace.VCSRepo.TriggerPrefixes,
"dry_runs_enabled": workspace.VCSRepo.DryRunsEnabled,
"ingress_submodules": workspace.VCSRepo.IngressSubmodules,
})
}
d.Set("vcs_repo", vcsRepo)
Expand Down Expand Up @@ -556,11 +563,12 @@ func resourceScalrWorkspaceUpdate(d *schema.ResourceData, meta interface{}) erro
}

options.VCSRepo = &scalr.WorkspaceVCSRepoOptions{
Identifier: scalr.String(vcsRepo["identifier"].(string)),
Branch: scalr.String(vcsRepo["branch"].(string)),
Path: scalr.String(vcsRepo["path"].(string)),
TriggerPrefixes: &triggerPrefixes,
DryRunsEnabled: scalr.Bool(vcsRepo["dry_runs_enabled"].(bool)),
Identifier: scalr.String(vcsRepo["identifier"].(string)),
Branch: scalr.String(vcsRepo["branch"].(string)),
Path: scalr.String(vcsRepo["path"].(string)),
TriggerPrefixes: &triggerPrefixes,
DryRunsEnabled: scalr.Bool(vcsRepo["dry_runs_enabled"].(bool)),
IngressSubmodules: scalr.Bool(vcsRepo["ingress_submodules"].(bool)),
}
}

Expand Down

0 comments on commit 5adf457

Please sign in to comment.