pre release version bump
Some checks reported errors
continuous-integration/drone/push Build encountered an error

make fmt
clarified some limitations for fork resource
This commit is contained in:
Tobias Trabelsi 2022-10-05 21:22:30 +02:00
parent f3c0793a88
commit 6d0bd5906a
Signed by: lerentis
GPG Key ID: FF0C2839718CAF2E
5 changed files with 47 additions and 14 deletions

View File

@ -17,7 +17,7 @@ terraform {
required_providers { required_providers {
gitea = { gitea = {
source = "Lerentis/gitea" source = "Lerentis/gitea"
version = "0.8.0" version = "0.9.0"
} }
} }
} }

View File

@ -3,14 +3,44 @@
page_title: "gitea_fork Resource - terraform-provider-gitea" page_title: "gitea_fork Resource - terraform-provider-gitea"
subcategory: "" subcategory: ""
description: |- description: |-
gitea_fork manages repository fork gitea_fork manages repository fork to the current user or an organisation
Forking a repository to a dedicated user is currently unsupported
Creating a fork using this resource without an organisation will create the fork in the executors name
--- ---
# gitea_fork (Resource) # gitea_fork (Resource)
`gitea_fork` manages repository fork `gitea_fork` manages repository fork to the current user or an organisation
Forking a repository to a dedicated user is currently unsupported
Creating a fork using this resource without an organisation will create the fork in the executors name
## Example Usage
```terraform
resource "gitea_org" "org1" {
name = "org1"
}
resource "gitea_org" "org2" {
name = "org2"
}
resource "gitea_repository" "repo1_in_org1" {
username = gitea_org.org1.name
name = "repo1-in-org1"
}
resource "gitea_fork" "user_fork_of_repo1_in_org1" {
owner = gitea_org.org1.name
repo = gitea_repository.repo1_in_org1.name
}
resource "gitea_fork" "org2_fork_of_repo1_in_org1" {
owner = gitea_org.org1.name
repo = gitea_repository.repo1_in_org1.name
organization = gitea_org.org2.name
}
```
<!-- schema generated by tfplugindocs --> <!-- schema generated by tfplugindocs -->
## Schema ## Schema

View File

@ -2,7 +2,7 @@ terraform {
required_providers { required_providers {
gitea = { gitea = {
source = "Lerentis/gitea" source = "Lerentis/gitea"
version = "0.8.0" version = "0.9.0"
} }
} }
} }

View File

@ -8,16 +8,16 @@ resource "gitea_org" "org2" {
resource "gitea_repository" "repo1_in_org1" { resource "gitea_repository" "repo1_in_org1" {
username = gitea_org.org1.name username = gitea_org.org1.name
name = "repo1-in-org1" name = "repo1-in-org1"
} }
resource "gitea_fork" "user_fork_of_repo1_in_org1" { resource "gitea_fork" "user_fork_of_repo1_in_org1" {
owner = gitea_org.org1.name owner = gitea_org.org1.name
repo = gitea_repository.repo1_in_org1.name repo = gitea_repository.repo1_in_org1.name
} }
resource "gitea_fork" "org2_fork_of_repo1_in_org1" { resource "gitea_fork" "org2_fork_of_repo1_in_org1" {
owner = gitea_org.org1.name owner = gitea_org.org1.name
repo = gitea_repository.repo1_in_org1.name repo = gitea_repository.repo1_in_org1.name
organization = gitea_org.org2.name organization = gitea_org.org2.name
} }

View File

@ -3,14 +3,15 @@ package gitea
import ( import (
"fmt" "fmt"
"strconv" "strconv"
"code.gitea.io/sdk/gitea" "code.gitea.io/sdk/gitea"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
const ( const (
forkOwner string = "owner" forkOwner string = "owner"
forkRepo string = "repo" forkRepo string = "repo"
forkOrganization string = "organization" forkOrganization string = "organization"
) )
func resourceForkCreate(d *schema.ResourceData, meta interface{}) (err error) { func resourceForkCreate(d *schema.ResourceData, meta interface{}) (err error) {
@ -24,8 +25,8 @@ func resourceForkCreate(d *schema.ResourceData, meta interface{}) (err error) {
} }
repo, _, err := client.CreateFork(d.Get(forkOwner).(string), repo, _, err := client.CreateFork(d.Get(forkOwner).(string),
d.Get(forkRepo).(string), d.Get(forkRepo).(string),
opts) opts)
if err == nil { if err == nil {
err = setForkResourceData(repo, d) err = setForkResourceData(repo, d)
} }
@ -102,6 +103,8 @@ func resourceGiteaFork() *schema.Resource {
Description: "The organization that owns the forked repo", Description: "The organization that owns the forked repo",
}, },
}, },
Description: "`gitea_fork` manages repository fork", Description: "`gitea_fork` manages repository fork to the current user or an organisation\n" +
"Forking a repository to a dedicated user is currently unsupported\n" +
"Creating a fork using this resource without an organisation will create the fork in the executors name",
} }
} }