Skip to content

Commit

Permalink
docs: Generate with tfplugindocs
Browse files Browse the repository at this point in the history
  • Loading branch information
OJFord committed Mar 7, 2021
1 parent 78a5cd8 commit 41ab758
Show file tree
Hide file tree
Showing 17 changed files with 504 additions and 139 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Check

on:
push: {}
pull_request: {}

jobs:

go:
name: Go
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.13

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Get dependencies
run: |
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi
- name: Build
run: go build -v ./...

- name: Test
run: go test -v ./...

- name: Format check
run: |
fmtdiff="$(gofmt -s -e -d .)"
if [ -n "$fmtdiff" ]; then
>&2 echo "$fmtdiff"
exit 1
fi
terraform:
name: Terraform
runs-on: ubuntu-latest
defaults:
run:
shell: bash

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Terraform
uses: hashicorp/setup-terraform@v1

- name: Terraformat
run: terraform fmt -recursive examples

- name: Check docs updated
run: |
curl -L https://github.com/hashicorp/terraform-plugin-docs/releases/download/v0.4.0/tfplugindocs_0.4.0_linux_amd64.zip --output tfplugindocs.zip
unzip tfplugindocs.zip tfplugindocs
./tfplugindocs
change="$(git diff)"
if [ -n "$change" ]; then
>&2 echo "$change"
exit 1
fi
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/dist/
/terraform-provider-wireguard
*.tfstate
20 changes: 20 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
layout: ""
page_title: "Provider: Mullvad"
description: |-
The WireGuard provider is used to handle WireGuard metadata.
---

# WireGuard Provider

The WireGuard provider is used to handle WireGuard metadata.

## Example Usage

```terraform
provider "wireguard" {
}
```

<!-- schema generated by tfplugindocs -->
## Schema
44 changes: 44 additions & 0 deletions docs/resources/asymmetric_key.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "wireguard_asymmetric_key Resource - terraform-provider-wireguard"
subcategory: ""
description: |-
Provides a WireGuard asymmetric key resource. This can be used to create, read, and delete WireGuard keys in terraform state.
---

# wireguard_asymmetric_key (Resource)

Provides a WireGuard asymmetric key resource. This can be used to create, read, and delete WireGuard keys in terraform state.

## Example Usage

```terraform
resource "wireguard_asymmetric_key" "example" {
}
output "wg_public_key" {
description = "Example's public WireGuard key"
value = wireguard_asymmetric_key.example.public_key
}
output "wg_private_key" {
description = "Example's private WireGuard key"
value = wireguard_asymmetric_key.example.private_key
sensitive = true
}
```

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

### Optional

- **bind** (String) A string to tie the lifecycle to, e.g. the terraform ID of another resource.
- **id** (String) The ID of this resource.
- **private_key** (String, Sensitive) A supplied WireGuard private key. By default one is generated.

### Read-Only

- **public_key** (String) The public key corresponding to the (given or generated) private key.


5 changes: 0 additions & 5 deletions examples/asymmetric_key/main.tf

This file was deleted.

Empty file.
2 changes: 2 additions & 0 deletions examples/provider/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
provider "wireguard" {
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
resource "wireguard_asymmetric_key" "example" {
}

output "wg_public_key" {
description = "Example's public WireGuard key"
value = wireguard_asymmetric_key.example.public_key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ terraform {
source = "OJFord/wireguard"
}
}
required_version = ">= 0.13"
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module github.com/OJFord/terraform-provider-wireguard
go 1.12

require (
github.com/hashicorp/terraform-plugin-sdk v1.7.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.4.4
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20200205215550-e35592f146e4
)
366 changes: 319 additions & 47 deletions go.sum

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package main

import (
"github.com/OJFord/terraform-provider-wireguard/wireguard"
"github.com/hashicorp/terraform-plugin-sdk/plugin"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
"github.com/OJFord/terraform-provider-wireguard/provider"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/plugin"
)

func main() {
plugin.Serve(&plugin.ServeOpts{
ProviderFunc: func() terraform.ResourceProvider {
return wireguard.Provider()
ProviderFunc: func() *schema.Provider {
return provider.Provider()
},
})
}
4 changes: 2 additions & 2 deletions wireguard/provider.go → provider/provider.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package wireguard
package provider

import (
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func Provider() *schema.Provider {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
package wireguard
package provider

import (
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
)

func resourceWireguardAsymmetricKey() *schema.Resource {
return &schema.Resource{
Description: "Provides a WireGuard asymmetric key resource. This can be used to create, read, and delete WireGuard keys in terraform state.",

Create: resourceWireguardAsymmetricKeyCreate,
Read: resourceWireguardAsymmetricKeyRead,
Delete: resourceWireguardAsymmetricKeyDelete,

Schema: map[string]*schema.Schema{
"bind": &schema.Schema{
Default: "",
ForceNew: true,
Optional: true,
Type: schema.TypeString,
"bind": {
Description: "A string to tie the lifecycle to, e.g. the terraform ID of another resource.",
Default: "",
ForceNew: true,
Optional: true,
Type: schema.TypeString,
},
"private_key": &schema.Schema{
Computed: true,
ForceNew: true,
Optional: true,
Sensitive: true,
Type: schema.TypeString,
"private_key": {
Description: "A supplied WireGuard private key. By default one is generated.",
Computed: true,
ForceNew: true,
Optional: true,
Sensitive: true,
Type: schema.TypeString,
},
"public_key": &schema.Schema{
Computed: true,
Type: schema.TypeString,
"public_key": {
Description: "The public key corresponding to the (given or generated) private key.",
Computed: true,
Type: schema.TypeString,
},
},
}
Expand Down
16 changes: 16 additions & 0 deletions templates/index.md.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
layout: ""
page_title: "Provider: Mullvad"
description: |-
The WireGuard provider is used to handle WireGuard metadata.
---

# WireGuard Provider

The WireGuard provider is used to handle WireGuard metadata.

## Example Usage

{{ tffile "examples/provider/provider.tf" }}

{{ .SchemaMarkdown | trimspace }}
28 changes: 0 additions & 28 deletions website/docs/index.html.markdown

This file was deleted.

33 changes: 0 additions & 33 deletions website/docs/r/asymmetric_key.html.markdown

This file was deleted.

0 comments on commit 41ab758

Please sign in to comment.