Skip to content

Commit

Permalink
Merge branch 'develop' into feature/SCALRCORE-27107
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanMytsko committed Oct 3, 2023
2 parents 1345842 + bb8e5ec commit 06f5e0e
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `scalr_provider_configuration`: Fixed error message if aws credentials type is wrong. ([#275](https://github.com/Scalr/terraform-provider-scalr/pull/275))
- `data.scalr_enviroment`: Added new attribute `default_provider_configurations` ([#279](https://github.com/Scalr/terraform-provider-scalr/pull/279))

### Added

- `scalr_vcs_provider`: Added new `draft_pr_runs_enabled` attribute ([#278](https://github.com/Scalr/terraform-provider-scalr/pull/278))

## [1.4.0] - 2023-08-11

### Changed
Expand Down
1 change: 1 addition & 0 deletions docs/resources/vcs_provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ resource "scalr_vcs_provider" "example" {

- `account_id` (String) ID of the account.
- `agent_pool_id` (String) The id of the agent pool to connect Scalr to self-hosted VCS provider.
- `draft_pr_runs_enabled` (Boolean) Enable draft PR runs for the VCS provider.
- `environments` (Set of String) The list of environment identifiers that the VCS provider is shared to. Use `["*"]` to share with all environments.
- `url` (String) This field is required for self-hosted vcs providers.
- `username` (String) This field is required for `bitbucket_enterprise` provider type.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/hashicorp/terraform-plugin-docs v0.16.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734
github.com/scalr/go-scalr v0.0.0-20230724130629-32e739f11ab5
github.com/scalr/go-scalr v0.0.0-20230927092645-93eaae8b79df
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,8 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww=
github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY=
github.com/scalr/go-scalr v0.0.0-20230724130629-32e739f11ab5 h1:qG5f2IRp3zisp2TcnQlthkI4MKPXO53c8jsolHZtBNQ=
github.com/scalr/go-scalr v0.0.0-20230724130629-32e739f11ab5/go.mod h1:p34SHb25YRvbgft7SUjSDYESeoQhWzAlxGXId/BbaSE=
github.com/scalr/go-scalr v0.0.0-20230927092645-93eaae8b79df h1:K8+luuthRvtvKapPOuDMqGpAchsdFVhgI3MgxwBURcg=
github.com/scalr/go-scalr v0.0.0-20230927092645-93eaae8b79df/go.mod h1:p34SHb25YRvbgft7SUjSDYESeoQhWzAlxGXId/BbaSE=
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
Expand Down
14 changes: 14 additions & 0 deletions scalr/resource_scalr_vcs_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ func resourceScalrVcsProvider() *schema.Resource {
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"draft_pr_runs_enabled": {
Description: "Enable draft PR runs for the VCS provider.",
Type: schema.TypeBool,
Optional: true,
Default: false,
},
},
}
}
Expand Down Expand Up @@ -124,6 +130,10 @@ func resourceScalrVcsProviderCreate(ctx context.Context, d *schema.ResourceData,
}
}

if draftPRsRunEnabled, ok := d.GetOk("draft_pr_runs_enabled"); ok {
options.DraftPrRunsEnabled = scalr.Bool(draftPRsRunEnabled.(bool))
}

if environmentsI, ok := d.GetOk("environments"); ok {
environments := environmentsI.(*schema.Set).List()
if (len(environments) == 1) && (environments[0].(string) == "*") {
Expand Down Expand Up @@ -214,6 +224,10 @@ func resourceScalrVcsProviderUpdate(ctx context.Context, d *schema.ResourceData,
}
}

if d.HasChange("draft_pr_runs_enabled") {
options.DraftPrRunsEnabled = scalr.Bool(d.Get("draft_pr_runs_enabled").(bool))
}

if environmentsI, ok := d.GetOk("environments"); ok {
environments := environmentsI.(*schema.Set).List()
if (len(environments) == 1) && (environments[0].(string) == "*") {
Expand Down
3 changes: 3 additions & 0 deletions scalr/resource_scalr_vcs_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func TestAccVcsProvider_basic(t *testing.T) {
resource.TestCheckResourceAttr("scalr_vcs_provider.test", "vcs_type", string(scalr.Github)),
resource.TestCheckResourceAttr("scalr_vcs_provider.test", "url", "https://github.com"),
resource.TestCheckResourceAttr("scalr_vcs_provider.test", "environments.0", "*"),
resource.TestCheckResourceAttr("scalr_vcs_provider.test", "draft_pr_runs_enabled", "false"),
),
},
{
Expand All @@ -36,6 +37,7 @@ func TestAccVcsProvider_basic(t *testing.T) {
resource.TestCheckResourceAttr("scalr_vcs_provider.test", "account_id", defaultAccount),
resource.TestCheckResourceAttr("scalr_vcs_provider.test", "vcs_type", string(scalr.Github)),
resource.TestCheckResourceAttr("scalr_vcs_provider.test", "url", "https://github.com"),
resource.TestCheckResourceAttr("scalr_vcs_provider.test", "draft_pr_runs_enabled", "true"),
),
},
{
Expand Down Expand Up @@ -159,5 +161,6 @@ resource "scalr_vcs_provider" "test" {
account_id = "%s"
vcs_type="%s"
token = "%s"
draft_pr_runs_enabled = true
}`, defaultAccount, string(vcsType), token)
}

0 comments on commit 06f5e0e

Please sign in to comment.