summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxuzhang3 <57888764+xuzhang3@users.noreply.github.com>2022-06-01 17:42:06 +0800
committerGitHub <noreply@github.com>2022-06-01 17:42:06 +0800
commitcbabe63c02098883ea2be6613e56ac9c5cbebc00 (patch)
tree96d0a4ed9f7405b5855b28c106a1cd61d22885b9
parentc052d528a4051ba5a2a31866f8630946f7a96be7 (diff)
parent7692d2d5bb62bb1a2330bd43e18bdcbdaf4c77db (diff)
Merge pull request #591 from wetwicky/feature/Add_DefaultBranch_MatchType
adding 'DefaultBranch' into match_type setting
-rw-r--r--azuredevops/internal/acceptancetests/resource_branchpolicy_test.go116
-rw-r--r--azuredevops/internal/service/policy/branch/common.go40
-rw-r--r--website/docs/r/branch_policy_auto_reviewers.html.markdown6
-rw-r--r--website/docs/r/branch_policy_build_validation.html.markdown10
-rw-r--r--website/docs/r/branch_policy_comment_resolution.html.markdown10
-rw-r--r--website/docs/r/branch_policy_merge_types.html.markdown10
-rw-r--r--website/docs/r/branch_policy_min_reviewers.html.markdown10
-rw-r--r--website/docs/r/branch_policy_status_check.html.markdown14
-rw-r--r--website/docs/r/branch_policy_work_item_linking.html.markdown10
9 files changed, 166 insertions, 60 deletions
diff --git a/azuredevops/internal/acceptancetests/resource_branchpolicy_test.go b/azuredevops/internal/acceptancetests/resource_branchpolicy_test.go
index 4895704d..3d18b8b3 100644
--- a/azuredevops/internal/acceptancetests/resource_branchpolicy_test.go
+++ b/azuredevops/internal/acceptancetests/resource_branchpolicy_test.go
@@ -23,7 +23,7 @@ func TestAccBranchPolicyMinReviewers_CreateAndUpdate(t *testing.T) {
Providers: testutils.GetProviders(),
Steps: []resource.TestStep{
{
- Config: getMinReviewersHcl(true, true, 1, false),
+ Config: getMinReviewersHcl(true, true, 1, false, "\"refs/heads/release\"", "Exact"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet(minReviewerTfNode, "id"),
resource.TestCheckResourceAttr(minReviewerTfNode, "blocking", "true"),
@@ -36,7 +36,7 @@ func TestAccBranchPolicyMinReviewers_CreateAndUpdate(t *testing.T) {
resource.TestCheckResourceAttr(minReviewerTfNode, "settings.0.on_push_reset_approved_votes", "true"),
),
}, {
- Config: getMinReviewersHcl(false, false, 2, true),
+ Config: getMinReviewersHcl(false, false, 2, true, "\"refs/heads/release\"", "Exact"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet(minReviewerTfNode, "id"),
resource.TestCheckResourceAttr(minReviewerTfNode, "blocking", "false"),
@@ -58,7 +58,7 @@ func TestAccBranchPolicyMinReviewers_CreateAndUpdate(t *testing.T) {
})
}
-func getMinReviewersHcl(enabled bool, blocking bool, reviewers int, flag bool) string {
+func getMinReviewersHcl(enabled bool, blocking bool, reviewers int, flag bool, repositoryRef string, matchType string) string {
votes := "all"
if !flag {
votes = "approved"
@@ -73,7 +73,7 @@ func getMinReviewersHcl(enabled bool, blocking bool, reviewers int, flag bool) s
on_push_reset_%[3]s_votes = true
`, reviewers, flag, votes)
- return getBranchPolicyHcl("azuredevops_branch_policy_min_reviewers", enabled, blocking, settings)
+ return getBranchPolicyHcl("azuredevops_branch_policy_min_reviewers", enabled, blocking, settings, "azuredevops_git_repository.repository.id", repositoryRef, matchType)
}
func TestAccBranchPolicyAutoReviewers_CreateAndUpdate(t *testing.T) {
@@ -84,13 +84,13 @@ func TestAccBranchPolicyAutoReviewers_CreateAndUpdate(t *testing.T) {
Providers: testutils.GetProviders(),
Steps: []resource.TestStep{
{
- Config: getAutoReviewersHcl(true, true, false, "auto reviewer", fmt.Sprintf("\"%s\",\"%s\"", "*/API*.cs", "README.md")),
+ Config: getAutoReviewersHcl(true, true, false, "auto reviewer", fmt.Sprintf("\"%s\",\"%s\"", "*/API*.cs", "README.md"), "\"refs/heads/release\"", "Exact"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(autoReviewerTfNode, "enabled", "true"),
resource.TestCheckResourceAttr(autoReviewerTfNode, "blocking", "true"),
),
}, {
- Config: getAutoReviewersHcl(false, false, true, "new auto reviewer", fmt.Sprintf("\"%s\",\"%s\"", "*/API*.cs", "README.md")),
+ Config: getAutoReviewersHcl(false, false, true, "new auto reviewer", fmt.Sprintf("\"%s\",\"%s\"", "*/API*.cs", "README.md"), "\"refs/heads/release\"", "Exact"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(autoReviewerTfNode, "enabled", "false"),
resource.TestCheckResourceAttr(autoReviewerTfNode, "blocking", "false"),
@@ -105,7 +105,7 @@ func TestAccBranchPolicyAutoReviewers_CreateAndUpdate(t *testing.T) {
})
}
-func getAutoReviewersHcl(enabled bool, blocking bool, submitterCanVote bool, message string, pathFilters string) string {
+func getAutoReviewersHcl(enabled bool, blocking bool, submitterCanVote bool, message string, pathFilters string, repositoryRef string, matchType string) string {
settings := fmt.Sprintf(
`
auto_reviewer_ids = [azuredevops_user_entitlement.user.id]
@@ -120,7 +120,7 @@ func getAutoReviewersHcl(enabled bool, blocking bool, submitterCanVote bool, mes
return strings.Join(
[]string{
userEntitlement,
- getBranchPolicyHcl("azuredevops_branch_policy_auto_reviewers", enabled, blocking, settings),
+ getBranchPolicyHcl("azuredevops_branch_policy_auto_reviewers", enabled, blocking, settings, "azuredevops_git_repository.repository.id", repositoryRef, matchType),
},
"\n",
)
@@ -133,13 +133,13 @@ func TestAccBranchPolicyBuildValidation_CreateAndUpdate(t *testing.T) {
Providers: testutils.GetProviders(),
Steps: []resource.TestStep{
{
- Config: getBuildValidationHcl(true, true, "build validation", 0),
+ Config: getBuildValidationHcl(true, true, "build validation", 0, "\"refs/heads/release\"", "Exact"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(buildValidationTfNode, "enabled", "true"),
resource.TestCheckResourceAttr(buildValidationTfNode, "settings.0.filename_patterns.#", "3"),
),
}, {
- Config: getBuildValidationHcl(false, false, "build validation rename", 720),
+ Config: getBuildValidationHcl(false, false, "build validation rename", 720, "\"refs/heads/release\"", "Exact"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(buildValidationTfNode, "enabled", "false"),
resource.TestCheckResourceAttr(buildValidationTfNode, "settings.0.filename_patterns.#", "3"),
@@ -154,7 +154,7 @@ func TestAccBranchPolicyBuildValidation_CreateAndUpdate(t *testing.T) {
})
}
-func getBuildValidationHcl(enabled bool, blocking bool, displayName string, validDuration int) string {
+func getBuildValidationHcl(enabled bool, blocking bool, displayName string, validDuration int, repositoryRef string, matchType string) string {
settings := fmt.Sprintf(
`
display_name = "%s"
@@ -168,7 +168,7 @@ func getBuildValidationHcl(enabled bool, blocking bool, displayName string, vali
`, displayName, validDuration,
)
- return getBranchPolicyHcl("azuredevops_branch_policy_build_validation", enabled, blocking, settings)
+ return getBranchPolicyHcl("azuredevops_branch_policy_build_validation", enabled, blocking, settings, "azuredevops_git_repository.repository.id", repositoryRef, matchType)
}
func TestAccBranchPolicyWorkItemLinking_CreateAndUpdate(t *testing.T) {
@@ -180,12 +180,12 @@ func TestAccBranchPolicyWorkItemLinking_CreateAndUpdate(t *testing.T) {
Providers: testutils.GetProviders(),
Steps: []resource.TestStep{
{
- Config: getBranchPolicyHcl(resourceName, true, true, ""),
+ Config: getBranchPolicyHcl(resourceName, true, true, "", "azuredevops_git_repository.repository.id", "\"refs/heads/release\"", "Exact"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(workItemLinkingTfNode, "enabled", "true"),
),
}, {
- Config: getBranchPolicyHcl(resourceName, false, false, ""),
+ Config: getBranchPolicyHcl(resourceName, false, false, "", "azuredevops_git_repository.repository.id", "\"refs/heads/release\"", "Exact"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(workItemLinkingTfNode, "enabled", "false"),
),
@@ -208,12 +208,12 @@ func TestAccBranchPolicyCommentResolution_CreateAndUpdate(t *testing.T) {
Providers: testutils.GetProviders(),
Steps: []resource.TestStep{
{
- Config: getBranchPolicyHcl(resourceName, true, true, ""),
+ Config: getBranchPolicyHcl(resourceName, true, true, "", "azuredevops_git_repository.repository.id", "\"refs/heads/release\"", "Exact"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(workItemLinkingTfNode, "enabled", "true"),
),
}, {
- Config: getBranchPolicyHcl(resourceName, false, false, ""),
+ Config: getBranchPolicyHcl(resourceName, false, false, "", "azuredevops_git_repository.repository.id", "\"refs/heads/release\"", "Exact"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(workItemLinkingTfNode, "enabled", "false"),
),
@@ -234,7 +234,7 @@ func TestAccBranchPolicyMergeTypes_CreateAndUpdate(t *testing.T) {
Providers: testutils.GetProviders(),
Steps: []resource.TestStep{
{
- Config: getMergeTypesHcl(true, true, true, true, true, true),
+ Config: getMergeTypesHcl(true, true, true, true, true, true, "\"refs/heads/release\"", "Exact"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(buildValidationTfNode, "enabled", "true"),
resource.TestCheckResourceAttr(buildValidationTfNode, "settings.0.allow_squash", "true"),
@@ -243,7 +243,7 @@ func TestAccBranchPolicyMergeTypes_CreateAndUpdate(t *testing.T) {
resource.TestCheckResourceAttr(buildValidationTfNode, "settings.0.allow_rebase_with_merge", "true"),
),
}, {
- Config: getMergeTypesHcl(false, false, false, false, false, false),
+ Config: getMergeTypesHcl(false, false, false, false, false, false, "\"refs/heads/release\"", "Exact"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(buildValidationTfNode, "enabled", "false"),
resource.TestCheckResourceAttr(buildValidationTfNode, "settings.0.allow_squash", "false"),
@@ -261,7 +261,7 @@ func TestAccBranchPolicyMergeTypes_CreateAndUpdate(t *testing.T) {
})
}
-func getMergeTypesHcl(enabled bool, blocking bool, allowSquash bool, allowRebase bool, allowNoFastForward bool, allowRebaseMerge bool) string {
+func getMergeTypesHcl(enabled bool, blocking bool, allowSquash bool, allowRebase bool, allowNoFastForward bool, allowRebaseMerge bool, repositoryRef string, matchType string) string {
settings := fmt.Sprintf(
`
allow_squash = %t
@@ -271,10 +271,10 @@ func getMergeTypesHcl(enabled bool, blocking bool, allowSquash bool, allowRebase
`, allowSquash, allowRebase, allowNoFastForward, allowRebaseMerge,
)
- return getBranchPolicyHcl("azuredevops_branch_policy_merge_types", enabled, blocking, settings)
+ return getBranchPolicyHcl("azuredevops_branch_policy_merge_types", enabled, blocking, settings, "azuredevops_git_repository.repository.id", repositoryRef, matchType)
}
-func getBranchPolicyHcl(resourceName string, enabled bool, blocking bool, settings string) string {
+func getBranchPolicyHcl(resourceName string, enabled bool, blocking bool, settings string, repositoryId string, repositoryRef string, matchType string) string {
branchPolicy := fmt.Sprintf(`
resource "%s" "p" {
project_id = azuredevops_project.project.id
@@ -283,13 +283,13 @@ func getBranchPolicyHcl(resourceName string, enabled bool, blocking bool, settin
settings {
%s
scope {
- repository_id = azuredevops_git_repository.repository.id
- repository_ref = azuredevops_git_repository.repository.default_branch
- match_type = "exact"
+ repository_id = %s
+ repository_ref = %s
+ match_type = "%s"
}
}
}
- `, resourceName, enabled, blocking, settings)
+ `, resourceName, enabled, blocking, settings, repositoryId, repositoryRef, matchType)
projectAndRepo := testutils.HclGitRepoResource(testutils.GenerateResourceName(), testutils.GenerateResourceName(), "Clean")
buildDef := testutils.HclBuildDefinitionResource(
"Sample Build Definition",
@@ -309,3 +309,69 @@ func getBranchPolicyHcl(resourceName string, enabled bool, blocking bool, settin
"\n",
)
}
+
+func getStatusCheckHcl(enabled bool, blocking bool, name string, invalidateOnUpdate bool, applicability string, repositoryId string, repositoryRef string, matchType string) string {
+ settings := fmt.Sprintf(
+ `
+ name = "%s"
+ invalidate_on_update = %t
+ applicability = "%s"
+ filename_patterns = [
+ "/WebApp/*",
+ "!/WebApp/Tests/*",
+ "*.cs"
+ ]
+ `, name, invalidateOnUpdate, applicability,
+ )
+
+ return getBranchPolicyHcl("azuredevops_branch_policy_status_check", enabled, blocking, settings, repositoryId, repositoryRef, matchType)
+}
+
+func TestAccBranchPolicyStatusCheck_CreateAndUpdate(t *testing.T) {
+ statusCheckTfNode := "azuredevops_branch_policy_status_check.p"
+ resource.ParallelTest(t, resource.TestCase{
+ PreCheck: func() { testutils.PreCheck(t, nil) },
+ Providers: testutils.GetProviders(),
+ Steps: []resource.TestStep{
+ {
+ Config: getStatusCheckHcl(true, true, "abc-1", true, "default", "null", "null", "defaultBranch"),
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr(statusCheckTfNode, "enabled", "true"),
+ resource.TestCheckResourceAttr(statusCheckTfNode, "blocking", "true"),
+ resource.TestCheckResourceAttr(statusCheckTfNode, "settings.0.name", "abc-1"),
+ resource.TestCheckResourceAttr(statusCheckTfNode, "settings.0.invalidate_on_update", "true"),
+ resource.TestCheckResourceAttr(statusCheckTfNode, "settings.0.applicability", "default"),
+ resource.TestCheckResourceAttr(statusCheckTfNode, "settings.0.filename_patterns.#", "3"),
+ resource.TestCheckResourceAttr(statusCheckTfNode, "settings.0.scope.0.repository_id", ""),
+ resource.TestCheckResourceAttr(statusCheckTfNode, "settings.0.scope.0.repository_ref", ""),
+ resource.TestCheckResourceAttr(statusCheckTfNode, "settings.0.scope.0.match_type", "DefaultBranch"),
+ ),
+ }, {
+ Config: getStatusCheckHcl(false, false, "abc-2", false, "conditional", "null", "\"refs/heads/release\"", "Prefix"),
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr(statusCheckTfNode, "enabled", "false"),
+ resource.TestCheckResourceAttr(statusCheckTfNode, "blocking", "false"),
+ resource.TestCheckResourceAttr(statusCheckTfNode, "settings.0.name", "abc-2"),
+ resource.TestCheckResourceAttr(statusCheckTfNode, "settings.0.invalidate_on_update", "false"),
+ resource.TestCheckResourceAttr(statusCheckTfNode, "settings.0.applicability", "conditional"),
+ resource.TestCheckResourceAttr(statusCheckTfNode, "settings.0.scope.0.repository_id", ""),
+ resource.TestCheckResourceAttr(statusCheckTfNode, "settings.0.scope.0.repository_ref", "refs/heads/release"),
+ resource.TestCheckResourceAttr(statusCheckTfNode, "settings.0.scope.0.match_type", "Prefix"),
+ ),
+ }, {
+ Config: getStatusCheckHcl(false, false, "abc-3", false, "conditional", "null", "\"refs/heads/release\"", "Exact"),
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr(statusCheckTfNode, "settings.0.name", "abc-3"),
+ resource.TestCheckResourceAttr(statusCheckTfNode, "settings.0.scope.0.match_type", "Exact"),
+ resource.TestCheckResourceAttr(statusCheckTfNode, "settings.0.scope.0.repository_id", ""),
+ resource.TestCheckResourceAttr(statusCheckTfNode, "settings.0.scope.0.repository_ref", "refs/heads/release"),
+ ),
+ }, {
+ ResourceName: statusCheckTfNode,
+ ImportStateIdFunc: testutils.ComputeProjectQualifiedResourceImportID(statusCheckTfNode),
+ ImportState: true,
+ ImportStateVerify: true,
+ },
+ },
+ })
+}
diff --git a/azuredevops/internal/service/policy/branch/common.go b/azuredevops/internal/service/policy/branch/common.go
index cb0210f0..fef582e1 100644
--- a/azuredevops/internal/service/policy/branch/common.go
+++ b/azuredevops/internal/service/policy/branch/common.go
@@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"strconv"
+ "strings"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
@@ -48,8 +49,9 @@ const (
// The type of repository branch name matching strategy used by the policy
const (
- matchTypeExact string = "Exact"
- matchTypePrefix string = "Prefix"
+ matchTypeExact string = "Exact"
+ matchTypePrefix string = "Prefix"
+ matchTypeDefaultBranch string = "DefaultBranch"
)
// policyCrudArgs arguments for genBasePolicyResource
@@ -113,7 +115,7 @@ func genBasePolicyResource(crudArgs *policyCrudArgs) *schema.Resource {
Default: matchTypeExact,
DiffSuppressFunc: suppress.CaseDifference,
ValidateFunc: validation.StringInSlice([]string{
- matchTypeExact, matchTypePrefix,
+ matchTypeExact, matchTypePrefix, matchTypeDefaultBranch,
}, true),
},
},
@@ -188,14 +190,17 @@ func flattenSettings(d *schema.ResourceData, policyConfig *policy.PolicyConfigur
// baseExpandFunc expands each of the base elements of the schema
func baseExpandFunc(d *schema.ResourceData, typeID uuid.UUID) (*policy.PolicyConfiguration, *string, error) {
projectID := d.Get(SchemaProjectID).(string)
-
+ policySettings, err := expandSettings(d)
+ if err != nil {
+ return nil, nil, fmt.Errorf("Error parsing policy configuration settings: (%+v)", err)
+ }
policyConfig := policy.PolicyConfiguration{
IsEnabled: converter.Bool(d.Get(SchemaEnabled).(bool)),
IsBlocking: converter.Bool(d.Get(SchemaBlocking).(bool)),
Type: &policy.PolicyTypeRef{
Id: &typeID,
},
- Settings: expandSettings(d),
+ Settings: policySettings,
}
if d.Id() != "" {
@@ -209,7 +214,7 @@ func baseExpandFunc(d *schema.ResourceData, typeID uuid.UUID) (*policy.PolicyCon
return &policyConfig, &projectID, nil
}
-func expandSettings(d *schema.ResourceData) map[string]interface{} {
+func expandSettings(d *schema.ResourceData) (map[string]interface{}, error) {
settingsList := d.Get(SchemaSettings).([]interface{})
settings := settingsList[0].(map[string]interface{})
settingsScopes := settings[SchemaScope].([]interface{})
@@ -220,19 +225,34 @@ func expandSettings(d *schema.ResourceData) map[string]interface{} {
scopeSetting := map[string]interface{}{}
if repoID, ok := scopeMap[SchemaRepositoryID]; ok {
- scopeSetting["repositoryId"] = repoID
+ if repoID == "" {
+ scopeSetting["repositoryId"] = nil
+ } else {
+ scopeSetting["repositoryId"] = repoID
+ }
}
if repoRef, ok := scopeMap[SchemaRepositoryRef]; ok {
- scopeSetting["refName"] = repoRef
+ if repoRef == "" {
+ scopeSetting["refName"] = nil
+ } else {
+ scopeSetting["refName"] = repoRef
+ }
}
if matchType, ok := scopeMap[SchemaMatchType]; ok {
- scopeSetting["matchKind"] = matchType
+ if matchType == "" {
+ scopeSetting["matchKind"] = nil
+ } else {
+ scopeSetting["matchKind"] = matchType
+ }
+ }
+ if strings.EqualFold(scopeSetting["matchKind"].(string), matchTypeDefaultBranch) && (scopeSetting["repositoryId"] != nil || scopeSetting["refName"] != nil) {
+ return nil, fmt.Errorf(" neither 'repository_id' nor 'repository_ref' can be set when 'match_type=DefaultBranch'")
}
scopes[index] = scopeSetting
}
return map[string]interface{}{
SchemaScope: scopes,
- }
+ }, nil
}
//lint:ignore SA1019 SDKv2 migration - staticcheck's own linter directives are currently being ignored under golanci-lint
diff --git a/website/docs/r/branch_policy_auto_reviewers.html.markdown b/website/docs/r/branch_policy_auto_reviewers.html.markdown
index cd6b7c57..eb86f263 100644
--- a/website/docs/r/branch_policy_auto_reviewers.html.markdown
+++ b/website/docs/r/branch_policy_auto_reviewers.html.markdown
@@ -69,9 +69,9 @@ The following arguments are supported:
`scope` block supports the following:
- - `repository_id` - (Optional) The repository ID. Needed only if the scope of the policy will be limited to a single repository.
- - `repository_ref` - (Optional) The ref pattern to use for the match. If `match_type` is `Exact`, this should be a qualified ref such as `refs/heads/master`. If `match_type` is `Prefix`, this should be a ref path such as `refs/heads/releases`.
- - `match_type` (Optional) The match type to use when applying the policy. Supported values are `Exact` (default) or `Prefix`.
+- `repository_id` - (Optional) The repository ID. Needed only if the scope of the policy will be limited to a single repository. If `match_type` is `DefaultBranch`, this should not be defined.
+- `repository_ref` - (Optional) The ref pattern to use for the match when `match_type` other than `DefaultBranch`. If `match_type` is `Exact`, this should be a qualified ref such as `refs/heads/master`. If `match_type` is `Prefix`, this should be a ref path such as `refs/heads/releases`.
+- `match_type` (Optional) The match type to use when applying the policy. Supported values are `Exact` (default), `Prefix` or `DefaultBranch`.
## Attributes Reference
diff --git a/website/docs/r/branch_policy_build_validation.html.markdown b/website/docs/r/branch_policy_build_validation.html.markdown
index 734eb30f..7baa9723 100644
--- a/website/docs/r/branch_policy_build_validation.html.markdown
+++ b/website/docs/r/branch_policy_build_validation.html.markdown
@@ -62,6 +62,10 @@ resource "azuredevops_branch_policy_build_validation" "example" {
repository_ref = "refs/heads/releases"
match_type = "Prefix"
}
+
+ scope {
+ match_type = "DefaultBranch"
+ }
}
}
```
@@ -87,9 +91,9 @@ A `settings` block supports the following:
A `settings` `scope` block supports the following:
-- `repository_id` - (Optional) The repository ID. Needed only if the scope of the policy will be limited to a single repository.
-- `repository_ref` - (Optional) The ref pattern to use for the match. If `match_type` is `Exact`, this should be a qualified ref such as `refs/heads/master`. If `match_type` is `Prefix`, this should be a ref path such as `refs/heads/releases`.
-- `match_type` (Optional) The match type to use when applying the policy. Supported values are `Exact` (default) or `Prefix`.
+- `repository_id` - (Optional) The repository ID. Needed only if the scope of the policy will be limited to a single repository. If `match_type` is `DefaultBranch`, this should not be defined.
+- `repository_ref` - (Optional) The ref pattern to use for the match when `match_type` other than `DefaultBranch`. If `match_type` is `Exact`, this should be a qualified ref such as `refs/heads/master`. If `match_type` is `Prefix`, this should be a ref path such as `refs/heads/releases`.
+- `match_type` (Optional) The match type to use when applying the policy. Supported values are `Exact` (default), `Prefix` or `DefaultBranch`.
## Attributes Reference
diff --git a/website/docs/r/branch_policy_comment_resolution.html.markdown b/website/docs/r/branch_policy_comment_resolution.html.markdown
index c2638c7c..184c1037 100644
--- a/website/docs/r/branch_policy_comment_resolution.html.markdown
+++ b/website/docs/r/branch_policy_comment_resolution.html.markdown
@@ -43,6 +43,10 @@ resource "azuredevops_branch_policy_comment_resolution" "example" {
repository_ref = "refs/heads/releases"
match_type = "Prefix"
}
+
+ scope {
+ match_type = "DefaultBranch"
+ }
}
}
```
@@ -62,9 +66,9 @@ A `settings` block supports the following:
A `settings` `scope` block supports the following:
-- `repository_id` - (Optional) The repository ID. Needed only if the scope of the policy will be limited to a single repository.
-- `repository_ref` - (Optional) The ref pattern to use for the match. If `match_type` is `Exact`, this should be a qualified ref such as `refs/heads/master`. If `match_type` is `Prefix`, this should be a ref path such as `refs/heads/releases`.
-- `match_type` (Optional) The match type to use when applying the policy. Supported values are `Exact` (default) or `Prefix`.
+- `repository_id` - (Optional) The repository ID. Needed only if the scope of the policy will be limited to a single repository. If `match_type` is `DefaultBranch`, this should not be defined.
+- `repository_ref` - (Optional) The ref pattern to use for the match when `match_type` other than `DefaultBranch`. If `match_type` is `Exact`, this should be a qualified ref such as `refs/heads/master`. If `match_type` is `Prefix`, this should be a ref path such as `refs/heads/releases`.
+- `match_type` (Optional) The match type to use when applying the policy. Supported values are `Exact` (default), `Prefix` or `DefaultBranch`.
## Attributes Reference
diff --git a/website/docs/r/branch_policy_merge_types.html.markdown b/website/docs/r/branch_policy_merge_types.html.markdown
index f262ac08..7d3e9563 100644
--- a/website/docs/r/branch_policy_merge_types.html.markdown
+++ b/website/docs/r/branch_policy_merge_types.html.markdown
@@ -47,6 +47,10 @@ resource "azuredevops_branch_policy_merge_types" "example" {
repository_ref = "refs/heads/releases"
match_type = "Prefix"
}
+
+ scope {
+ match_type = "DefaultBranch"
+ }
}
}
```
@@ -71,9 +75,9 @@ A `settings` block supports the following:
A `settings` `scope` block supports the following:
-- `repository_id` - (Optional) The repository ID. Needed only if the scope of the policy will be limited to a single repository.
-- `repository_ref` - (Optional) The ref pattern to use for the match. If `match_type` is `Exact`, this should be a qualified ref such as `refs/heads/master`. If `match_type` is `Prefix`, this should be a ref path such as `refs/heads/releases`.
-- `match_type` (Optional) The match type to use when applying the policy. Supported values are `Exact` (default) or `Prefix`.
+- `repository_id` - (Optional) The repository ID. Needed only if the scope of the policy will be limited to a single repository. If `match_type` is `DefaultBranch`, this should not be defined.
+- `repository_ref` - (Optional) The ref pattern to use for the match when `match_type` other than `DefaultBranch`. If `match_type` is `Exact`, this should be a qualified ref such as `refs/heads/master`. If `match_type` is `Prefix`, this should be a ref path such as `refs/heads/releases`.
+- `match_type` (Optional) The match type to use when applying the policy. Supported values are `Exact` (default), `Prefix` or `DefaultBranch`.
## Attributes Reference
diff --git a/website/docs/r/branch_policy_min_reviewers.html.markdown b/website/docs/r/branch_policy_min_reviewers.html.markdown
index 5ae20968..8cdca14b 100644
--- a/website/docs/r/branch_policy_min_reviewers.html.markdown
+++ b/website/docs/r/branch_policy_min_reviewers.html.markdown
@@ -49,6 +49,10 @@ resource "azuredevops_branch_policy_min_reviewers" "example" {
repository_ref = "refs/heads/releases"
match_type = "Prefix"
}
+
+ scope {
+ match_type = "DefaultBranch"
+ }
}
}
```
@@ -78,9 +82,9 @@ Only one of `on_push_reset_all_votes` or `on_push_reset_approved_votes` may be s
A `settings` `scope` block supports the following:
-- `repository_id` - (Optional) The repository ID. Needed only if the scope of the policy will be limited to a single repository.
-- `repository_ref` - (Optional) The ref pattern to use for the match. If `match_type` is `Exact`, this should be a qualified ref such as `refs/heads/master`. If `match_type` is `Prefix`, this should be a ref path such as `refs/heads/releases`.
-- `match_type` (Optional) The match type to use when applying the policy. Supported values are `Exact` (default) or `Prefix`.
+- `repository_id` - (Optional) The repository ID. Needed only if the scope of the policy will be limited to a single repository. If `match_type` is `DefaultBranch`, this should not be defined.
+- `repository_ref` - (Optional) The ref pattern to use for the match when `match_type` other than `DefaultBranch`. If `match_type` is `Exact`, this should be a qualified ref such as `refs/heads/master`. If `match_type` is `Prefix`, this should be a ref path such as `refs/heads/releases`.
+- `match_type` (Optional) The match type to use when applying the policy. Supported values are `Exact` (default), `Prefix` or `DefaultBranch`.
## Attributes Reference
diff --git a/website/docs/r/branch_policy_status_check.html.markdown b/website/docs/r/branch_policy_status_check.html.markdown
index 5cad0a7f..5e0d4bbf 100644
--- a/website/docs/r/branch_policy_status_check.html.markdown
+++ b/website/docs/r/branch_policy_status_check.html.markdown
@@ -54,6 +54,10 @@ resource "azuredevops_branch_policy_status_check" "example" {
repository_ref = azuredevops_git_repository.example.default_branch
match_type = "Exact"
}
+
+ scope {
+ match_type = "DefaultBranch"
+ }
}
}
```
@@ -83,13 +87,9 @@ The following arguments are supported:
`scope` block supports the following:
- - `repository_id` - (Optional) The repository ID. Needed only if the scope of the policy will be limited to a single
- repository.
- - `repository_ref` - (Optional) The ref pattern to use for the match. If `match_type` is `Exact`, this should be a
- qualified ref such as `refs/heads/master`. If `match_type` is `Prefix`, this should be a ref path such
- as `refs/heads/releases`.
- - `match_type` (Optional) The match type to use when applying the policy. Supported values are `Exact` (default)
- or `Prefix`.
+ - `repository_id` - (Optional) The repository ID. Needed only if the scope of the policy will be limited to a single repository. If `match_type` is `DefaultBranch`, this should not be defined.
+ - `repository_ref` - (Optional) The ref pattern to use for the match when `match_type` other than `DefaultBranch`. If `match_type` is `Exact`, this should be a qualified ref such as `refs/heads/master`. If `match_type` is `Prefix`, this should be a ref path such as `refs/heads/releases`.
+ - `match_type` (Optional) The match type to use when applying the policy. Supported values are `Exact` (default), `Prefix` or `DefaultBranch`.
## Attributes Reference
diff --git a/website/docs/r/branch_policy_work_item_linking.html.markdown b/website/docs/r/branch_policy_work_item_linking.html.markdown
index ea21af4d..9c8d6f74 100644
--- a/website/docs/r/branch_policy_work_item_linking.html.markdown
+++ b/website/docs/r/branch_policy_work_item_linking.html.markdown
@@ -43,6 +43,10 @@ resource "azuredevops_branch_policy_work_item_linking" "example" {
repository_ref = "refs/heads/releases"
match_type = "Prefix"
}
+
+ scope {
+ match_type = "DefaultBranch"
+ }
}
}
```
@@ -62,9 +66,9 @@ A `settings` block supports the following:
A `settings` `scope` block supports the following:
-- `repository_id` - (Optional) The repository ID. Needed only if the scope of the policy will be limited to a single repository.
-- `repository_ref` - (Optional) The ref pattern to use for the match. If `match_type` is `Exact`, this should be a qualified ref such as `refs/heads/master`. If `match_type` is `Prefix`, this should be a ref path such as `refs/heads/releases`.
-- `match_type` (Optional) The match type to use when applying the policy. Supported values are `Exact` (default) or `Prefix`.
+- `repository_id` - (Optional) The repository ID. Needed only if the scope of the policy will be limited to a single repository. If `match_type` is `DefaultBranch`, this should not be defined.
+- `repository_ref` - (Optional) The ref pattern to use for the match when `match_type` other than `DefaultBranch`. If `match_type` is `Exact`, this should be a qualified ref such as `refs/heads/master`. If `match_type` is `Prefix`, this should be a ref path such as `refs/heads/releases`.
+- `match_type` (Optional) The match type to use when applying the policy. Supported values are `Exact` (default), `Prefix` or `DefaultBranch`.
## Attributes Reference