Skip to content
Merged
56 changes: 56 additions & 0 deletions docs/data-sources/gpg_key.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
# 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 api key's 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.
- `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.
66 changes: 66 additions & 0 deletions docs/resources/gpg_key.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
# 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" {
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.
- `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.
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 api key's user if not provided

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.

Instead of ... api key's user ..., let's call this ... authenticated user ... (for consistency).

Sorry for being picky - it's my inner monk ;-)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

All good, authenticated user is better!

key_id = "test_key"
}
30 changes: 30 additions & 0 deletions examples/resources/forgejo_gpg_key/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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" {
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