Compare commits
3 Commits
f3c0793a88
...
v0.9.0
Author | SHA1 | Date | |
---|---|---|---|
9c819ad4c2
|
|||
6d5439a00a
|
|||
6d0bd5906a
|
@ -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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
@ -71,3 +71,27 @@ resource "gitea_git_hook" "org_repo_pre_receive" {
|
|||||||
repo = gitea_repository.org_repo.name
|
repo = gitea_repository.org_repo.name
|
||||||
content = file("${path.module}/pre-receive.sh")
|
content = file("${path.module}/pre-receive.sh")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
@ -2,7 +2,7 @@ terraform {
|
|||||||
required_providers {
|
required_providers {
|
||||||
gitea = {
|
gitea = {
|
||||||
source = "terraform.local/lerentis/gitea"
|
source = "terraform.local/lerentis/gitea"
|
||||||
version = "0.8.0"
|
version = "0.9.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ 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"
|
||||||
)
|
)
|
||||||
@ -61,7 +62,24 @@ func resourceForkRead(d *schema.ResourceData, meta interface{}) (err error) {
|
|||||||
func resourceForkDelete(d *schema.ResourceData, meta interface{}) (err error) {
|
func resourceForkDelete(d *schema.ResourceData, meta interface{}) (err error) {
|
||||||
client := meta.(*gitea.Client)
|
client := meta.(*gitea.Client)
|
||||||
|
|
||||||
client.DeleteRepo(d.Get(forkOrganization).(string), d.Get(forkRepo).(string))
|
id, err := strconv.ParseInt(d.Id(), 10, 64)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
repo, _, err := client.GetRepoByID(id)
|
||||||
|
var resp *gitea.Response
|
||||||
|
|
||||||
|
resp, err = client.DeleteRepo(repo.Owner.UserName, repo.Name)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
if resp.StatusCode == 404 {
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -102,6 +120,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",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user