Skip to content
Merged
83 changes: 83 additions & 0 deletions docs/data-sources/gpg_key.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "forgejo_gpg_key Data Source - forgejo"
subcategory: ""
description: |-
Forgejo user GPG key data source.
---

# forgejo_gpg_key (Data Source)

Forgejo user GPG key data source.

## Example Usage

```terraform
terraform {
required_providers {
forgejo = {
source = "svalabs/forgejo"
}
}
}

provider "forgejo" {
host = "http://localhost:3000"
}

# Existing GPG key
data "forgejo_gpg_key" "this" {
user = "test_user" # Optional, uses authenticated user if not provided
key_id = "test_key"
}
```

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

### Required

- `key_id` (String) ID of the GPG key.

### Optional

- `user` (String) Name of the user.

### Read-Only

- `can_certify` (Boolean) Can this key certify.
- `can_encrypt_comms` (Boolean) Can this key encrypt communications.
- `can_encrypt_storage` (Boolean) Can this key encrypt storage.
- `can_sign` (Boolean) Can this key sign.
- `created_at` (String) Time at which the GPG key was created.
- `emails` (List of Object) Emails associated with the GPG key. (see [below for nested schema](#nestedatt--emails))
- `expires_at` (String) Time at which the GPG key expires.
- `id` (Number) Numeric identifier of the GPG key.
- `primary_key_id` (String) Primary ID of the GPG key.
- `public_key` (String) The public key.
- `subkeys` (List of Object) Subkeys of the GPG key. (see [below for nested schema](#nestedatt--subkeys))

<a id="nestedatt--emails"></a>
### Nested Schema for `emails`

Read-Only:

- `email` (String)
- `verified` (Boolean)


<a id="nestedatt--subkeys"></a>
### Nested Schema for `subkeys`

Read-Only:

- `can_certify` (Boolean)
- `can_encrypt_comms` (Boolean)
- `can_encrypt_storage` (Boolean)
- `can_sign` (Boolean)
- `created_at` (String)
- `expires_at` (String)
- `id` (Number)
- `key_id` (String)
- `primary_key_id` (String)
- `public_key` (String)
94 changes: 94 additions & 0 deletions docs/resources/gpg_key.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "forgejo_gpg_key Resource - forgejo"
subcategory: ""
description: |-
Forgejo user GPG key resource.
---

# forgejo_gpg_key (Resource)

Forgejo user GPG key resource.

## Example Usage

```terraform
terraform {
required_providers {
forgejo = {
source = "svalabs/forgejo"
}
gpg = {
source = "terraform-provider-gpg/gpg"
}
}
}

variable "gpg_key_password" { sensitive = true }

provider "forgejo" {
host = "http://localhost:3000"
}

# GPG key
resource "gpg_key_pair" "test" {
identities = [{
name = "Test User"
email = "test_user@localhost.localdomain"
}]
passphrase = var.gpg_key_password
}

# Forgejo GPG key
resource "forgejo_gpg_key" "this" {
# There is no user for this resource, GPG keys can only be managed for the authenticated user.
armored_public_key = gpg_key_pair.test.public_key
}
```

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

### Required

- `armored_public_key` (String) Armored GPG Public key.

### Read-Only

- `can_certify` (Boolean) Can this key certify.
- `can_encrypt_comms` (Boolean) Can this key encrypt communications.
- `can_encrypt_storage` (Boolean) Can this key encrypt storage.
- `can_sign` (Boolean) Can this key sign.
- `created_at` (String) Time at which the GPG key was created.
- `emails` (List of Object) Emails associated with the GPG key. (see [below for nested schema](#nestedatt--emails))
- `expires_at` (String) Time at which the GPG key expires.
- `id` (Number) Numeric identifier of the GPG key.
- `key_id` (String) ID of the GPG key.
- `primary_key_id` (String) Primary ID of the GPG key.
- `public_key` (String) The public key.
- `subkeys` (List of Object) Subkeys of the GPG key. (see [below for nested schema](#nestedatt--subkeys))

<a id="nestedatt--emails"></a>
### Nested Schema for `emails`

Read-Only:

- `email` (String)
- `verified` (Boolean)


<a id="nestedatt--subkeys"></a>
### Nested Schema for `subkeys`

Read-Only:

- `can_certify` (Boolean)
- `can_encrypt_comms` (Boolean)
- `can_encrypt_storage` (Boolean)
- `can_sign` (Boolean)
- `created_at` (String)
- `expires_at` (String)
- `id` (Number)
- `key_id` (String)
- `primary_key_id` (String)
- `public_key` (String)
17 changes: 17 additions & 0 deletions examples/data-sources/forgejo_gpg_key/data-source.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
terraform {
required_providers {
forgejo = {
source = "svalabs/forgejo"
}
}
}

provider "forgejo" {
host = "http://localhost:3000"
}

# Existing GPG key
data "forgejo_gpg_key" "this" {
user = "test_user" # Optional, uses authenticated user if not provided
key_id = "test_key"
}
31 changes: 31 additions & 0 deletions examples/resources/forgejo_gpg_key/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
terraform {
required_providers {
forgejo = {
source = "svalabs/forgejo"
}
gpg = {
source = "terraform-provider-gpg/gpg"
}
}
}

variable "gpg_key_password" { sensitive = true }

provider "forgejo" {
host = "http://localhost:3000"
}

# GPG key
resource "gpg_key_pair" "test" {
identities = [{
name = "Test User"
email = "test_user@localhost.localdomain"
}]
passphrase = var.gpg_key_password
}

# Forgejo GPG key
resource "forgejo_gpg_key" "this" {
# There is no user for this resource, GPG keys can only be managed for the authenticated user.
armored_public_key = gpg_key_pair.test.public_key

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a comment that there's no user argument here. GPG keys can only be managed for the authenticated user...

}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (

require (
github.com/42wim/httpsig v1.2.3 // indirect
github.com/ProtonMail/go-crypto v1.1.6 // indirect
github.com/ProtonMail/go-crypto v1.3.0 // indirect
github.com/agext/levenshtein v1.2.2 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/cloudflare/circl v1.6.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ github.com/42wim/httpsig v1.2.3 h1:xb0YyWhkYj57SPtfSttIobJUPJZB9as1nsfo7KWVcEs=
github.com/42wim/httpsig v1.2.3/go.mod h1:nZq9OlYKDrUBhptd77IHx4/sZZD+IxTBADvAPI9G/EM=
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
github.com/ProtonMail/go-crypto v1.1.6 h1:ZcV+Ropw6Qn0AX9brlQLAUXfqLBc7Bl+f/DmNxpLfdw=
github.com/ProtonMail/go-crypto v1.1.6/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE=
github.com/ProtonMail/go-crypto v1.3.0 h1:ILq8+Sf5If5DCpHQp4PbZdS1J7HDFRXz/+xKBiRGFrw=
github.com/ProtonMail/go-crypto v1.3.0/go.mod h1:9whxjD8Rbs29b4XWbB8irEcE8KHMqaR2e7GWU1R+/PE=
github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE=
github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec=
Expand Down
Loading