# dokploy_gitea_provider (Resource)

A Gitea connection (Git > Gitea): the OAuth2 application that lets Dokploy list and clone repositories. Applications and composes then use the `gitea` source block with this record's `id`.

~> **A person must authorize the application once in a browser.** Terraform stores the OAuth2 application credentials. Until someone opens Git > Gitea in the Dokploy UI and completes the authorization, Dokploy holds no access token, the `dokploy_gitea_provider` data source reports `is_configured = false`, and a deploy from this provider fails.

~> **Dokploy stores and returns `client_secret` in cleartext.** The attribute is sensitive, so Terraform does not print it, but anyone with API access to the server can read it. The `client_secret_wo` companion keeps it out of the Terraform state.

## Example Usage

```terraform
# Register the OAuth2 application that you created in Gitea
# (Settings > Applications). The default redirect_uri matches the provider's
# endpoint; register the same URI in Gitea.
resource "dokploy_gitea_provider" "main" {
  name      = "gitea"
  gitea_url = "https://gitea.example.com"
  client_id = var.gitea_client_id

  # Write-only: Terraform 1.11 or later. Change the version to send a new secret.
  client_secret_wo         = var.gitea_client_secret
  client_secret_wo_version = 1
}

# After the apply, open Git > Gitea in Dokploy and authorize the application
# once. Until then the provider holds no access token.
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `client_id` (String) Client ID of the OAuth2 application that you created in Gitea.
- `gitea_url` (String) URL of the Gitea instance, for example `https://gitea.example.com`.
- `name` (String) Display name. Dokploy does not enforce a unique name.

### Optional

> **NOTE**: [Write-only arguments](https://developer.hashicorp.com/terraform/language/resources/ephemeral#write-only-arguments) are supported in Terraform 1.11 and later.

- `client_secret` (String, Sensitive) Client secret of the OAuth2 application. Set this attribute or `client_secret_wo`.
- `client_secret_wo` (String, Sensitive, [Write-only](https://developer.hashicorp.com/terraform/language/resources/ephemeral#write-only-arguments)) Write-only form of `client_secret`. Terraform keeps it out of the plan and the state. It needs Terraform 1.11 or later. Set exactly one of `client_secret` and `client_secret_wo`. A new value reaches the server only when `client_secret_wo_version` changes.
- `client_secret_wo_version` (Number) Version of `client_secret_wo`. Change it to send the current `client_secret_wo` value to the server. It needs `client_secret_wo`.
- `gitea_internal_url` (String) URL that the Dokploy server uses to reach Gitea when it differs from `gitea_url`, for example an address on a private network. If you remove it from the configuration, the provider clears it.
- `redirect_uri` (String) Redirect URI of the OAuth2 application. Defaults to `<endpoint>/api/providers/gitea/callback`, built from the provider's `endpoint`. Register the same URI in Gitea.
- `scopes` (String) OAuth2 scopes that Dokploy requests, comma-separated. Defaults to `repo,repo:status,read:user,read:org`.

### Read-Only

- `created_at` (String) Creation timestamp from the server.
- `git_provider_id` (String) Id of the generic git-provider record that owns this Gitea record.
- `id` (String) The `giteaId`. The `gitea.gitea_id` of an application or a compose references it.

## Import

Import is supported using the following syntax:

The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example:

```shell
# Import by the giteaId, the id that gitea.one takes.
terraform import dokploy_gitea_provider.main X_9OsNZiMvNvaqGIJJzpf
```