Skip to content

Commit

Permalink
Merge pull request #146 from Scalr/feature/SCALRCORE-17117
Browse files Browse the repository at this point in the history
SCALRCORE-17117 Support VCS clone with submodules
  • Loading branch information
penja committed Jul 19, 2022
2 parents 271d621 + bd27874 commit 3b7f460
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 22 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### 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))

## [1.0.0-rc32] - 2022-07-15

### Added
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 @@ -45,7 +45,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 @@ -56,9 +56,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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
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-20220705164951-30c98b966d48
github.com/scalr/go-scalr v0.0.0-20220711092821-b5bf24a47d01
)

require (
Expand Down
5 changes: 3 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,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-20220705164951-30c98b966d48 h1:U1MwJfCyYqA8USl8IzEWJWmzLElmxN8ygEkOoY2YeQM=
github.com/scalr/go-scalr v0.0.0-20220705164951-30c98b966d48/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE=
github.com/scalr/go-scalr v0.0.0-20220711092821-b5bf24a47d01 h1:6/XbSdPU+QKjC6q7X16DZQV6CV90ZpJ7vsF7hpsZ6c4=
github.com/scalr/go-scalr v0.0.0-20220711092821-b5bf24a47d01/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 Expand Up @@ -478,6 +478,7 @@ golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220517195934-5e4e11fc645e h1:w36l2Uw3dRan1K3TyXriXvY+6T56GNmlKGcqiQUJDfM=
golang.org/x/sys v0.0.0-20220517195934-5e4e11fc645e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
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 @@ -111,6 +111,10 @@ func dataSourceScalrWorkspace() *schema.Resource {
Type: schema.TypeBool,
Computed: true,
},
"ingress_submodules": {
Type: schema.TypeBool,
Computed: true,
},
},
},
},
Expand Down Expand Up @@ -183,9 +187,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 @@ -177,6 +177,11 @@ func resourceScalrWorkspace() *schema.Resource {
Optional: true,
Default: true,
},
"ingress_submodules": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
},
},
},
Expand Down Expand Up @@ -295,10 +300,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 @@ -415,11 +421,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 @@ -517,11 +524,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 3b7f460

Please sign in to comment.