From 571ef5dc04f7af14e79fcb06fcd36031668a996e Mon Sep 17 00:00:00 2001 From: Michal Schott Date: Wed, 20 Nov 2024 11:50:13 +0100 Subject: [PATCH] Allow repository mainbranch configuration --- bitbucket/resource_repository.go | 13 +++++++++++++ docs/resources/repository.md | 1 + 2 files changed, 14 insertions(+) diff --git a/bitbucket/resource_repository.go b/bitbucket/resource_repository.go index 901409f6..70e5ceac 100644 --- a/bitbucket/resource_repository.go +++ b/bitbucket/resource_repository.go @@ -77,6 +77,11 @@ func resourceRepository() *schema.Resource { Default: "allow_forks", ValidateFunc: validation.StringInSlice([]string{"allow_forks", "no_public_forks", "no_forks"}, false), }, + "mainbranch": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, "language": { Type: schema.TypeString, Optional: true, @@ -173,6 +178,13 @@ func newRepositoryFromResource(d *schema.ResourceData) *bitbucket.Repository { repo.Project = project } + if v, ok := d.GetOk("mainbranch"); ok && v.(string) != "" { + mainbranch := &bitbucket.Branch{ + Name: v.(string), + } + repo.Mainbranch = mainbranch + } + return repo } @@ -364,6 +376,7 @@ func resourceRepositoryRead(ctx context.Context, d *schema.ResourceData, m inter d.Set("slug", repoRes.Slug) d.Set("language", repoRes.Language) d.Set("fork_policy", repoRes.ForkPolicy) + d.Set("mainbranch", repoRes.Mainbranch.Name) // d.Set("website", repoRes.Website) d.Set("description", repoRes.Description) d.Set("project_key", repoRes.Project.Key) diff --git a/docs/resources/repository.md b/docs/resources/repository.md index a9254907..044519c8 100644 --- a/docs/resources/repository.md +++ b/docs/resources/repository.md @@ -59,6 +59,7 @@ The following arguments are supported: * `link` - (Optional) A set of links to a resource related to this object. See [Link](#link) Below. * `inherit_default_merge_strategy` - (Optional) Whether to inherit default merge strategy from project. * `inherit_branching_model` - (Optional) Whether to inherit branching model from project. +* `mainbranch` - (Optional) Name of main branch. ### Link