started with documentation

This commit is contained in:
Tobias Trabelsi 2022-06-12 17:49:33 +02:00
parent f7d1914d45
commit cc6f0d460a
No known key found for this signature in database
GPG key ID: FF0C2839718CAF2E
10 changed files with 298 additions and 96 deletions

View file

@ -7,3 +7,67 @@ Terraform Gitea Provider
## History ## History
This is a fork of https://gitea.com/gitea/terraform-provider-gitea. Many thanks for the foundation of this provider This is a fork of https://gitea.com/gitea/terraform-provider-gitea. Many thanks for the foundation of this provider
## Usage
This is not a 1.0 release, so usage is subject to change!
```terraform
terraform {
required_providers {
gitea = {
source = "Lerentis/gitea"
version = "0.3.0"
}
}
}
provider "gitea" {
base_url = var.gitea_url # optionally use GITEA_BASE_URL env var
token = var.gitea_token # optionally use GITEA_TOKEN env var
# Username/Password authentication is mutally exclusive with token authentication
# username = var.username # optionally use GITEA_USERNAME env var
# password = var.password # optionally use GITEA_PASSWORD env var
# A file containing the ca certificate to use in case ssl certificate is not from a standard chain
cacert_file = var.cacert_file
# If you are running a gitea instance with self signed TLS certificates
# and you want to disable certificate validation you can deactivate it with this flag
insecure = false
}
resource "gitea_repository" "test" {
username = "lerentis"
name = "test"
private = true
issue_labels = "Default"
license = "MIT"
gitignores = "Go"
}
resource "gitea_repository" "mirror" {
username = "lerentis"
name = "terraform-provider-gitea-mirror"
description = "Mirror of Terraform Provider"
mirror = true
migration_clone_addresse = "https://git.uploadfilter24.eu/lerentis/terraform-provider-gitea.git"
migration_service = "gitea"
migration_service_auth_token = var.gitea_mirror_token
}
resource "gitea_org" "test_org" {
name = "test-org"
}
resource "gitea_repository" "org_repo" {
username = gitea_org.test_org.name
name = "org-test-repo"
}
```
## Contributing
This repo is a mirror of [uploadfilter24.eu](https://git.uploadfilter24.eu/lerentis/terraform-provider-gitea), where i mostly develop. PRs will be manually merged on the gitea instance as keeping these two repositories in sync can be very error prune.

View file

@ -10,7 +10,34 @@ description: |-
## Example Usage
```terraform
terraform {
required_providers {
gitea = {
source = "Lerentis/gitea"
version = "0.3.0"
}
}
}
provider "gitea" {
base_url = var.gitea_url # optionally use GITEA_BASE_URL env var
token = var.gitea_token # optionally use GITEA_TOKEN env var
# Username/Password authentication is mutally exclusive with token authentication
# username = var.username # optionally use GITEA_USERNAME env var
# password = var.password # optionally use GITEA_PASSWORD env var
# A file containing the ca certificate to use in case ssl certificate is not from a standard chain
cacert_file = var.cacert_file
# If you are running a gitea instance with self signed TLS certificates
# and you want to disable certificate validation you can deactivate it with this flag
insecure = false
}
```
<!-- schema generated by tfplugindocs --> <!-- schema generated by tfplugindocs -->
## Schema ## Schema

View file

@ -3,30 +3,44 @@
page_title: "gitea_org Resource - terraform-provider-gitea" page_title: "gitea_org Resource - terraform-provider-gitea"
subcategory: "" subcategory: ""
description: |- description: |-
Handling Ogranisation resources gitea_org manages a gitea organisation.
Organisations are a way to group repositories and abstract permission management in a gitea instance.
--- ---
# gitea_org (Resource) # gitea_org (Resource)
Handling Ogranisation resources `gitea_org` manages a gitea organisation.
Organisations are a way to group repositories and abstract permission management in a gitea instance.
## Example Usage
```terraform
resource "gitea_org" "test_org" {
name = "test-org"
}
resource "gitea_repository" "org_repo" {
username = gitea_org.test_org.name
name = "org-test-repo"
}
```
<!-- schema generated by tfplugindocs --> <!-- schema generated by tfplugindocs -->
## Schema ## Schema
### Required ### Required
- `name` (String) - `name` (String) The name of the organisation without spaces.
### Optional ### Optional
- `description` (String) - `description` (String) A description of this organisation.
- `full_name` (String) - `full_name` (String) The display name of the organisation. Defaults to the value of `name`.
- `location` (String) - `location` (String)
- `repo_admin_change_team_access` (Boolean) - `repo_admin_change_team_access` (Boolean)
- `visibility` (String) - `visibility` (String) Flag is this organisation should be publicly visible or not.
- `website` (String) - `website` (String) A link to a website with more information about this organisation.
### Read-Only ### Read-Only

View file

@ -3,22 +3,51 @@
page_title: "gitea_repository Resource - terraform-provider-gitea" page_title: "gitea_repository Resource - terraform-provider-gitea"
subcategory: "" subcategory: ""
description: |- description: |-
Handling Repository resources gitea_repository manages a gitea repository.
Per default this repository will be initializiled with the provided configuration (gitignore, License etc.).
If the username property is set to a organisation name, the provider will try to look if this organisation exists and create the repository under the organisation scope.
Repository migrations have some properties that are not available to regular repositories. These are all prefixed with migration_.
--- ---
# gitea_repository (Resource) # gitea_repository (Resource)
Handling Repository resources `gitea_repository` manages a gitea repository.
Per default this repository will be initializiled with the provided configuration (gitignore, License etc.).
If the `username` property is set to a organisation name, the provider will try to look if this organisation exists and create the repository under the organisation scope.
Repository migrations have some properties that are not available to regular repositories. These are all prefixed with `migration_`.
## Example Usage
```terraform
resource "gitea_repository" "test" {
username = "lerentis"
name = "test"
private = true
issue_labels = "Default"
license = "MIT"
gitignores = "Go"
}
resource "gitea_repository" "mirror" {
username = "lerentis"
name = "terraform-provider-gitea-mirror"
description = "Mirror of Terraform Provider"
mirror = true
migration_clone_addresse = "https://git.uploadfilter24.eu/lerentis/terraform-provider-gitea.git"
migration_service = "gitea"
migration_service_auth_token = var.gitea_mirror_token
}
```
<!-- schema generated by tfplugindocs --> <!-- schema generated by tfplugindocs -->
## Schema ## Schema
### Required ### Required
- `name` (String) - `name` (String) The Name of the repository
- `username` (String) - `username` (String) The Owner of the repository
### Optional ### Optional
@ -28,18 +57,21 @@ Handling Repository resources
- `allow_rebase_explicit` (Boolean) - `allow_rebase_explicit` (Boolean)
- `allow_squash_merge` (Boolean) - `allow_squash_merge` (Boolean)
- `archived` (Boolean) - `archived` (Boolean)
- `auto_init` (Boolean) - `auto_init` (Boolean) Flag if the repository should be initiated with the configured values
- `autodetect_manual_merge` (Boolean) - `autodetect_manual_merge` (Boolean)
- `default_branch` (String) - `default_branch` (String) The default branch of the repository. Defaults to `main`
- `description` (String) - `description` (String) The description of the repository.
- `gitignores` (String) - `gitignores` (String) A specific gitignore that should be commited to the repositoryon creation if `auto_init` is set to `true`
- `has_issues` (Boolean) Need to exist in the gitea instance
- `has_projects` (Boolean) - `has_issues` (Boolean) A flag if the repository should have issue management enabled or not.
- `has_pull_requests` (Boolean) - `has_projects` (Boolean) A flag if the repository should have the native project management enabled or not.
- `has_wiki` (Boolean) - `has_pull_requests` (Boolean) A flag if the repository should acceppt pull requests or not.
- `has_wiki` (Boolean) A flag if the repository should have the native wiki enabled or not.
- `ignore_whitespace_conflicts` (Boolean) - `ignore_whitespace_conflicts` (Boolean)
- `issue_labels` (String) - `issue_labels` (String) The Issue Label configuration to be used in this repository.
- `license` (String) Need to exist in the gitea instance
- `license` (String) The license under which the source code of this repository should be.
Need to exist in the gitea instance
- `migration_clone_addresse` (String) - `migration_clone_addresse` (String)
- `migration_issue_labels` (Boolean) - `migration_issue_labels` (Boolean)
- `migration_lfs` (Boolean) - `migration_lfs` (Boolean)
@ -52,10 +84,10 @@ Handling Repository resources
- `migration_service_auth_token` (String, Sensitive) - `migration_service_auth_token` (String, Sensitive)
- `migration_service_auth_username` (String) - `migration_service_auth_username` (String)
- `mirror` (Boolean) - `mirror` (Boolean)
- `private` (Boolean) - `private` (Boolean) Flag if the repository should be private or not.
- `readme` (String) - `readme` (String)
- `repo_template` (Boolean) - `repo_template` (Boolean)
- `website` (String) - `website` (String) A link to a website with more information.
### Read-Only ### Read-Only

View file

@ -1,13 +0,0 @@
terraform {
required_providers {
gitea = {
source = "terraform.local/lerentis/gitea"
version = "0.3.0"
}
}
}
provider "gitea" {
base_url = var.gitea_url
token = var.gitea_token
}

View file

@ -0,0 +1,24 @@
terraform {
required_providers {
gitea = {
source = "Lerentis/gitea"
version = "0.3.0"
}
}
}
provider "gitea" {
base_url = var.gitea_url # optionally use GITEA_BASE_URL env var
token = var.gitea_token # optionally use GITEA_TOKEN env var
# Username/Password authentication is mutally exclusive with token authentication
# username = var.username # optionally use GITEA_USERNAME env var
# password = var.password # optionally use GITEA_PASSWORD env var
# A file containing the ca certificate to use in case ssl certificate is not from a standard chain
cacert_file = var.cacert_file
# If you are running a gitea instance with self signed TLS certificates
# and you want to disable certificate validation you can deactivate it with this flag
insecure = false
}

View file

@ -0,0 +1,8 @@
resource "gitea_org" "test_org" {
name = "test-org"
}
resource "gitea_repository" "org_repo" {
username = gitea_org.test_org.name
name = "org-test-repo"
}

View file

@ -0,0 +1,18 @@
resource "gitea_repository" "test" {
username = "lerentis"
name = "test"
private = true
issue_labels = "Default"
license = "MIT"
gitignores = "Go"
}
resource "gitea_repository" "mirror" {
username = "lerentis"
name = "terraform-provider-gitea-mirror"
description = "Mirror of Terraform Provider"
mirror = true
migration_clone_addresse = "https://git.uploadfilter24.eu/lerentis/terraform-provider-gitea.git"
migration_service = "gitea"
migration_service_auth_token = var.gitea_mirror_token
}

View file

@ -139,24 +139,28 @@ func resourceGiteaOrg() *schema.Resource {
}, },
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"name": { "name": {
Type: schema.TypeString, Type: schema.TypeString,
Required: true, Required: true,
ForceNew: true, ForceNew: true,
Description: "The name of the organisation without spaces.",
}, },
"full_name": { "full_name": {
Type: schema.TypeString, Type: schema.TypeString,
Required: false, Required: false,
Optional: true, Optional: true,
Description: "The display name of the organisation. Defaults to the value of `name`.",
}, },
"description": { "description": {
Type: schema.TypeString, Type: schema.TypeString,
Required: false, Required: false,
Optional: true, Optional: true,
Description: "A description of this organisation.",
}, },
"website": { "website": {
Type: schema.TypeString, Type: schema.TypeString,
Required: false, Required: false,
Optional: true, Optional: true,
Description: "A link to a website with more information about this organisation.",
}, },
"location": { "location": {
Type: schema.TypeString, Type: schema.TypeString,
@ -175,12 +179,14 @@ func resourceGiteaOrg() *schema.Resource {
Computed: true, Computed: true,
}, },
"visibility": { "visibility": {
Type: schema.TypeString, Type: schema.TypeString,
Required: false, Required: false,
Optional: true, Optional: true,
Default: "public", Default: "public",
Description: "Flag is this organisation should be publicly visible or not.",
}, },
}, },
Description: "Handling Ogranisation resources", Description: "`gitea_org` manages a gitea organisation.\n\n" +
"Organisations are a way to group repositories and abstract permission management in a gitea instance.",
} }
} }

View file

@ -259,20 +259,23 @@ func resourceGiteaRepository() *schema.Resource {
}, },
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"username": { "username": {
Type: schema.TypeString, Type: schema.TypeString,
Required: true, Required: true,
ForceNew: true, ForceNew: true,
Description: "The Owner of the repository",
}, },
"name": { "name": {
Type: schema.TypeString, Type: schema.TypeString,
Required: true, Required: true,
ForceNew: true, ForceNew: true,
Description: "The Name of the repository",
}, },
"auto_init": { "auto_init": {
Type: schema.TypeBool, Type: schema.TypeBool,
Required: false, Required: false,
Optional: true, Optional: true,
Default: true, Default: true,
Description: "Flag if the repository should be initiated with the configured values",
}, },
"repo_template": { "repo_template": {
Type: schema.TypeBool, Type: schema.TypeBool,
@ -285,18 +288,25 @@ func resourceGiteaRepository() *schema.Resource {
Required: false, Required: false,
Optional: true, Optional: true,
Default: "Default", Default: "Default",
Description: "The Issue Label configuration to be used in this repository.\n" +
"Need to exist in the gitea instance",
}, },
"gitignores": { "gitignores": {
Type: schema.TypeString, Type: schema.TypeString,
Required: false, Required: false,
Optional: true, Optional: true,
Default: "", Default: "",
Description: "A specific gitignore that should be commited to the repository" +
"on creation if `auto_init` is set to `true`\n" +
"Need to exist in the gitea instance",
}, },
"license": { "license": {
Type: schema.TypeString, Type: schema.TypeString,
Required: false, Required: false,
Optional: true, Optional: true,
Default: "", Default: "",
Description: "The license under which the source code of this repository should be.\n" +
"Need to exist in the gitea instance",
}, },
"readme": { "readme": {
Type: schema.TypeString, Type: schema.TypeString,
@ -305,22 +315,25 @@ func resourceGiteaRepository() *schema.Resource {
Default: "", Default: "",
}, },
"description": { "description": {
Type: schema.TypeString, Type: schema.TypeString,
Required: false, Required: false,
Optional: true, Optional: true,
Default: "", Default: "",
Description: "The description of the repository.",
}, },
"private": { "private": {
Type: schema.TypeBool, Type: schema.TypeBool,
Required: false, Required: false,
Optional: true, Optional: true,
Default: true, Default: true,
Description: "Flag if the repository should be private or not.",
}, },
"default_branch": { "default_branch": {
Type: schema.TypeString, Type: schema.TypeString,
Required: false, Required: false,
Optional: true, Optional: true,
Default: "main", Default: "main",
Description: "The default branch of the repository. Defaults to `main`",
}, },
"created": { "created": {
Type: schema.TypeString, Type: schema.TypeString,
@ -343,34 +356,39 @@ func resourceGiteaRepository() *schema.Resource {
Computed: true, Computed: true,
}, },
"website": { "website": {
Type: schema.TypeString, Type: schema.TypeString,
Required: false, Required: false,
Optional: true, Optional: true,
Default: "", Default: "",
Description: "A link to a website with more information.",
}, },
"has_issues": { "has_issues": {
Type: schema.TypeBool, Type: schema.TypeBool,
Required: false, Required: false,
Optional: true, Optional: true,
Default: true, Default: true,
Description: "A flag if the repository should have issue management enabled or not.",
}, },
"has_wiki": { "has_wiki": {
Type: schema.TypeBool, Type: schema.TypeBool,
Required: false, Required: false,
Optional: true, Optional: true,
Default: true, Default: true,
Description: "A flag if the repository should have the native wiki enabled or not.",
}, },
"has_pull_requests": { "has_pull_requests": {
Type: schema.TypeBool, Type: schema.TypeBool,
Required: false, Required: false,
Optional: true, Optional: true,
Default: true, Default: true,
Description: "A flag if the repository should acceppt pull requests or not.",
}, },
"has_projects": { "has_projects": {
Type: schema.TypeBool, Type: schema.TypeBool,
Required: false, Required: false,
Optional: true, Optional: true,
Default: true, Default: true,
Description: "A flag if the repository should have the native project management enabled or not.",
}, },
"ignore_whitespace_conflicts": { "ignore_whitespace_conflicts": {
Type: schema.TypeBool, Type: schema.TypeBool,
@ -496,6 +514,10 @@ func resourceGiteaRepository() *schema.Resource {
Default: "", Default: "",
}, },
}, },
Description: "Handling Repository resources", Description: "`gitea_repository` manages a gitea repository.\n\n" +
"Per default this repository will be initializiled with the provided configuration (gitignore, License etc.).\n" +
"If the `username` property is set to a organisation name, the provider will try to look if this organisation exists " +
"and create the repository under the organisation scope.\n\n" +
"Repository migrations have some properties that are not available to regular repositories. These are all prefixed with `migration_`.",
} }
} }