Skip to content

Commit

Permalink
Allow repository mainbranch configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
michalschott committed Nov 20, 2024
1 parent 1ba1821 commit 571ef5d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions bitbucket/resource_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions docs/resources/repository.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 571ef5d

Please sign in to comment.