Skip to content

Commit

Permalink
Add argocd_gpg_key resource (#315)
Browse files Browse the repository at this point in the history
  • Loading branch information
onematchfox authored Jul 7, 2023
1 parent cced478 commit 08682d2
Show file tree
Hide file tree
Showing 13 changed files with 859 additions and 3 deletions.
75 changes: 75 additions & 0 deletions docs/resources/gpg_key.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "argocd_gpg_key Resource - terraform-provider-argocd"
subcategory: ""
description: |-
Manages GPG keys https://argo-cd.readthedocs.io/en/stable/user-guide/gpg-verification/ within ArgoCD.
---

# argocd_gpg_key (Resource)

Manages [GPG keys](https://argo-cd.readthedocs.io/en/stable/user-guide/gpg-verification/) within ArgoCD.

## Example Usage

```terraform
resource "argocd_gpg_key" "this" {
public_key = <<EOF
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBGSJdlcBEACnza+KvWLyKWUHJPhgs//HRL0EEmA/EcFKioBlrgPNYf/O7hNg
KT3NDaNrD26pr+bOb4mfaqNNS9no8b9EP3C7Co3Wf2d4xpJ5/hlpIm3V652S5daZ
I7ylVT8QOrhaqEnHH2hEcOfDaqjrYfrx3qiI8v7DmV6jfGi1tDUUgfJwiOyZk4q1
jiPo5k4+XNp9mCtUAGyidLFcUqQ9XbHKgBwgAoxtIKNSbdPCGhsjgTHHhzswMH/Z
DhhtcraqrfOhoP9lI4/zyCS+B9OfUy7BS/1SqWKIgdsjFIR+zHIOI69lh77+ZAVE
MVYJBdFke5/g/tTPaQGuBqaIJ3d/Mi/ZlbTsoBcq5qam73uh7fcgBV5la6NeuNcR
tvKMVl4DlnkJS8LBtElLEeHEylTCdNltrUFwshDKDBtq6ilTKCK14R6g4lkn8VcE
9xx7Mhdh77tp66FRZ6ge1E8EUEFwEeFhp240KRyaA5U1/kAarn8083zZ7d4+QObp
L4KMqgrwLaxyPLgu0J/f946qLewV7XsbZRXE1jQa9Z7W5TEoJwjcC79DXe1wChc6
cBfCtluDsnklwvldpKTEZU0q/hKE6Zt7NjLUyExV+5guoHllxoVxx7sh+jtKm/J+
5gh+B3xOTDxRV2XYIx1TM6U1iLxAqchzFec8dfkuTbs/5f++PrddvZfiUQARAQAB
tD1BcmdvQ0QgVGVycmFmb3JtIFByb3ZpZGVyIDxmYWtldXNlckB1c2Vycy5ub3Jl
cGx5LmdpdGh1Yi5jb20+iQJOBBMBCgA4FiEEvK9bNlncXDhFAk6kmtkpVUAdOI0F
AmSJdlcCGwMFCwkIBwIGFQoJCAsCBBYCAwECHgECF4AACgkQmtkpVUAdOI2FdA//
YuFYsX6SUVgI4l68ZHE34jLTWU5R2ujB6luErcguAlLyDtrD3melva3V/ETc69/1
5o7Ayn3a7uz5lCEvUSLsCN+V2o3EjrA81pt8Zs+Z9WYeZE5F5DnKzq81PObdASB7
Po2X0qLqqKIhpQxc/E7m26xmePCf82H36gtvPiEVmVA5yduk1lLG3aZtNIRCa4VK
gmDjR8Se+OZeAw7JQCOeJB9/Y8oQ8nVkj1SWNIICaUwIXHtrj7r1z6XTDAEkGeBg
HXW8IEhZDE1Nq3vQtZvgwftEoPT/Ff+8DwvL1JUov2ObQDolallzKaiiVfGZhPJZ
4PMtEPEmSL9QWJAG5jiBVC3BdVZtXBNkC1HqTCXwZc/wzp5O9MmMXmCrUFr4FfHu
IZ560MNpp/SrtUrOahLmvuG0B+Ze96e2nm5ap5wkCDaQouOIqM7Lj+FGq64cu2B/
oSsl7joBZQUYXv8meNOQssm6jArRLG2oFoiEdRqzd2/RjvvJliLN9OCNvV43f38h
8Ep8RDi9RiHhSKvwrvDD9x/JRm6zQUetjrctmjdIYp8k129LrD0Qr9ULXfphZdrv
xga7/lyQLmukLu7Mxwp+ss2bY/wjT8mlT5P55kBpXXyYILhLsUESCHG6D8/Ov+vv
OoZS+BSfe/0vc1aTfDKxj5wAx27a6z5o25X27feEl3U=
=kqkH
-----END PGP PUBLIC KEY BLOCK-----
EOF
}
```

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

### Required

- `public_key` (String) Raw key data of the GPG key to create

### Read-Only

- `fingerprint` (String) Fingerprint is the fingerprint of the key
- `id` (String) GPG key identifier
- `owner` (String) Owner holds the owner identification, e.g. a name and e-mail address
- `sub_type` (String) SubType holds the key's sub type (e.g. rsa4096)
- `trust` (String) Trust holds the level of trust assigned to this key

## Import

Import is supported using the following syntax:

```shell
# GPG Keys can be imported using the key ID.

# Example:
terraform import argocd_gpg_key.this 9AD92955401D388D
```
4 changes: 4 additions & 0 deletions examples/resources/argocd_gpg_key/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# GPG Keys can be imported using the key ID.

# Example:
terraform import argocd_gpg_key.this 9AD92955401D388D
33 changes: 33 additions & 0 deletions examples/resources/argocd_gpg_key/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
resource "argocd_gpg_key" "this" {
public_key = <<EOF
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBGSJdlcBEACnza+KvWLyKWUHJPhgs//HRL0EEmA/EcFKioBlrgPNYf/O7hNg
KT3NDaNrD26pr+bOb4mfaqNNS9no8b9EP3C7Co3Wf2d4xpJ5/hlpIm3V652S5daZ
I7ylVT8QOrhaqEnHH2hEcOfDaqjrYfrx3qiI8v7DmV6jfGi1tDUUgfJwiOyZk4q1
jiPo5k4+XNp9mCtUAGyidLFcUqQ9XbHKgBwgAoxtIKNSbdPCGhsjgTHHhzswMH/Z
DhhtcraqrfOhoP9lI4/zyCS+B9OfUy7BS/1SqWKIgdsjFIR+zHIOI69lh77+ZAVE
MVYJBdFke5/g/tTPaQGuBqaIJ3d/Mi/ZlbTsoBcq5qam73uh7fcgBV5la6NeuNcR
tvKMVl4DlnkJS8LBtElLEeHEylTCdNltrUFwshDKDBtq6ilTKCK14R6g4lkn8VcE
9xx7Mhdh77tp66FRZ6ge1E8EUEFwEeFhp240KRyaA5U1/kAarn8083zZ7d4+QObp
L4KMqgrwLaxyPLgu0J/f946qLewV7XsbZRXE1jQa9Z7W5TEoJwjcC79DXe1wChc6
cBfCtluDsnklwvldpKTEZU0q/hKE6Zt7NjLUyExV+5guoHllxoVxx7sh+jtKm/J+
5gh+B3xOTDxRV2XYIx1TM6U1iLxAqchzFec8dfkuTbs/5f++PrddvZfiUQARAQAB
tD1BcmdvQ0QgVGVycmFmb3JtIFByb3ZpZGVyIDxmYWtldXNlckB1c2Vycy5ub3Jl
cGx5LmdpdGh1Yi5jb20+iQJOBBMBCgA4FiEEvK9bNlncXDhFAk6kmtkpVUAdOI0F
AmSJdlcCGwMFCwkIBwIGFQoJCAsCBBYCAwECHgECF4AACgkQmtkpVUAdOI2FdA//
YuFYsX6SUVgI4l68ZHE34jLTWU5R2ujB6luErcguAlLyDtrD3melva3V/ETc69/1
5o7Ayn3a7uz5lCEvUSLsCN+V2o3EjrA81pt8Zs+Z9WYeZE5F5DnKzq81PObdASB7
Po2X0qLqqKIhpQxc/E7m26xmePCf82H36gtvPiEVmVA5yduk1lLG3aZtNIRCa4VK
gmDjR8Se+OZeAw7JQCOeJB9/Y8oQ8nVkj1SWNIICaUwIXHtrj7r1z6XTDAEkGeBg
HXW8IEhZDE1Nq3vQtZvgwftEoPT/Ff+8DwvL1JUov2ObQDolallzKaiiVfGZhPJZ
4PMtEPEmSL9QWJAG5jiBVC3BdVZtXBNkC1HqTCXwZc/wzp5O9MmMXmCrUFr4FfHu
IZ560MNpp/SrtUrOahLmvuG0B+Ze96e2nm5ap5wkCDaQouOIqM7Lj+FGq64cu2B/
oSsl7joBZQUYXv8meNOQssm6jArRLG2oFoiEdRqzd2/RjvvJliLN9OCNvV43f38h
8Ep8RDi9RiHhSKvwrvDD9x/JRm6zQUetjrctmjdIYp8k129LrD0Qr9ULXfphZdrv
xga7/lyQLmukLu7Mxwp+ss2bY/wjT8mlT5P55kBpXXyYILhLsUESCHG6D8/Ov+vv
OoZS+BSfe/0vc1aTfDKxj5wAx27a6z5o25X27feEl3U=
=kqkH
-----END PGP PUBLIC KEY BLOCK-----
EOF
}
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.19

require (
github.com/Masterminds/semver/v3 v3.2.1
github.com/ProtonMail/gopenpgp/v2 v2.7.1
github.com/argoproj/argo-cd/v2 v2.6.7
github.com/argoproj/gitops-engine v0.7.3
github.com/argoproj/pkg v0.13.7-0.20221221191914-44694015343d
Expand Down Expand Up @@ -44,7 +45,8 @@ require (
github.com/Masterminds/sprig/v3 v3.2.2 // indirect
github.com/Microsoft/go-winio v0.5.2 // indirect
github.com/PagerDuty/go-pagerduty v1.6.0 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230321155629-9a39f2531310 // indirect
github.com/ProtonMail/go-mime v0.0.0-20230322103455-7d82a3887f2f // indirect
github.com/RocketChat/Rocket.Chat.Go.SDK v0.0.0-20210112200207-10ab4d695d60 // indirect
github.com/acomagu/bufpipe v1.0.4 // indirect
github.com/agext/levenshtein v1.2.2 // indirect
Expand Down
14 changes: 13 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,13 @@ github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMo
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/PagerDuty/go-pagerduty v1.6.0 h1:am81SzvG5Pw+s3JZ5yEy6kGvsXXklTNRrGr3d8WKpsU=
github.com/PagerDuty/go-pagerduty v1.6.0/go.mod h1:7eaBLzsDpK7VUvU0SJ5mohczQkoWrrr5CjDaw5gh1as=
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 h1:wPbRQzjjwFc0ih8puEVAOFGELsn1zoIIYdxvML7mDxA=
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8/go.mod h1:I0gYDMZ6Z5GRU7l58bNFSkPTFN6Yl12dsUlAZ8xy98g=
github.com/ProtonMail/go-crypto v0.0.0-20230321155629-9a39f2531310 h1:dGAdTcqheKrQ/TW76sAcmO2IorwXplUw2inPkOzykbw=
github.com/ProtonMail/go-crypto v0.0.0-20230321155629-9a39f2531310/go.mod h1:8TI4H3IbrackdNgv+92dI+rhpCaLqM0IfpgCgenFvRE=
github.com/ProtonMail/go-mime v0.0.0-20230322103455-7d82a3887f2f h1:tCbYj7/299ekTTXpdwKYF8eBlsYsDVoggDAuAjoK66k=
github.com/ProtonMail/go-mime v0.0.0-20230322103455-7d82a3887f2f/go.mod h1:gcr0kNtGBqin9zDW9GOHcVntrwnjrK+qdJ06mWYBybw=
github.com/ProtonMail/gopenpgp/v2 v2.7.1 h1:Awsg7MPc2gD3I7IFac2qE3Gdls0lZW8SzrFZ3k1oz0s=
github.com/ProtonMail/gopenpgp/v2 v2.7.1/go.mod h1:/BU5gfAVwqyd8EfC3Eu7zmuhwYQpKs+cGD8M//iiaxs=
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
github.com/RocketChat/Rocket.Chat.Go.SDK v0.0.0-20210112200207-10ab4d695d60 h1:prBTRx78AQnXzivNT9Crhu564W/zPPr3ibSlpT9xKcE=
Expand Down Expand Up @@ -1148,6 +1153,7 @@ golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0
golang.org/x/crypto v0.0.0-20220826181053-bd7e27e6170d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw=
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
golang.org/x/crypto v0.10.0 h1:LKqV2xt9+kDzSTfOhx4FrkEBcMrAgHSYgzywV9zcGmM=
golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
Expand Down Expand Up @@ -1195,6 +1201,7 @@ golang.org/x/mod v0.5.1-0.20210830214625-1b1db11ec8f4/go.mod h1:5OXOZSfqPIIbmVBI
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk=
golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down Expand Up @@ -1256,6 +1263,7 @@ golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b/go.mod h1:YDH+HFinaLZZlnHAfS
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
Expand Down Expand Up @@ -1385,13 +1393,15 @@ golang.org/x/sys v0.0.0-20220825204002-c680a09ffe64/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s=
golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.0.0-20220722155259-a9ba230a4035/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
golang.org/x/term v0.9.0 h1:GRRCnKYhdQrD8kfRAdQ6Zcw1P0OcELxGLKJvtjVMZ28=
golang.org/x/term v0.9.0/go.mod h1:M6DEAAIenWoTxdKrOltXcmDY3rSplQUkrvaDU5FcQyo=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand All @@ -1405,6 +1415,7 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.10.0 h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58=
golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand Down Expand Up @@ -1484,6 +1495,7 @@ golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.10-0.20220218145154-897bd77cd717/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
63 changes: 63 additions & 0 deletions internal/provider/model_gpg_key.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package provider

import (
"github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/types"
customtypes "github.com/oboukili/terraform-provider-argocd/internal/types"
)

type gpgKeyModel struct {
ID types.String `tfsdk:"id"`
PublicKey customtypes.PGPPublicKey `tfsdk:"public_key"`
Fingerprint types.String `tfsdk:"fingerprint"`
Owner types.String `tfsdk:"owner"`
SubType types.String `tfsdk:"sub_type"`
Trust types.String `tfsdk:"trust"`
}

func gpgKeySchemaAttributes() map[string]schema.Attribute {
return map[string]schema.Attribute{
"public_key": schema.StringAttribute{
MarkdownDescription: "Raw key data of the GPG key to create",
CustomType: customtypes.PGPPublicKeyType,
Required: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
},
"fingerprint": schema.StringAttribute{
MarkdownDescription: "Fingerprint is the fingerprint of the key",
Computed: true,
},
"id": schema.StringAttribute{
MarkdownDescription: "GPG key identifier",
Computed: true,
},
"owner": schema.StringAttribute{
MarkdownDescription: "Owner holds the owner identification, e.g. a name and e-mail address",
Computed: true,
},
"sub_type": schema.StringAttribute{
MarkdownDescription: "SubType holds the key's sub type (e.g. rsa4096)",
Computed: true,
},
"trust": schema.StringAttribute{
MarkdownDescription: "Trust holds the level of trust assigned to this key",
Computed: true,
},
}
}

func newGPGKey(k *v1alpha1.GnuPGPublicKey) *gpgKeyModel {
return &gpgKeyModel{
Fingerprint: types.StringValue(k.Fingerprint),
ID: types.StringValue(k.KeyID),
Owner: types.StringValue(k.Owner),
PublicKey: customtypes.PGPPublicKeyValue(k.KeyData),
SubType: types.StringValue(k.SubType),
Trust: types.StringValue(k.Trust),
}
}
4 changes: 3 additions & 1 deletion internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,9 @@ func (p *ArgoCDProvider) Configure(ctx context.Context, req provider.ConfigureRe
}

func (p *ArgoCDProvider) Resources(context.Context) []func() resource.Resource {
return nil
return []func() resource.Resource{
NewGPGKeyResource,
}
}

func (p *ArgoCDProvider) DataSources(context.Context) []func() datasource.DataSource {
Expand Down
Loading

0 comments on commit 08682d2

Please sign in to comment.