Skip to content

Commit 9e5ecf0

Browse files
build: Add docs, goreleaser, and GH actions
2 parents a77ef7c + f107f0b commit 9e5ecf0

29 files changed

+642
-141
lines changed

.editorconfig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# defaults
7+
[*]
8+
charset = utf-8
9+
end_of_line = lf
10+
insert_final_newline = true
11+
trim_trailing_whitespace = true
12+
13+
[*.{yaml,yml}]
14+
indent_style = space
15+
indent_size = 2
16+
17+
# Go
18+
# https://golang.org/cmd/gofmt/
19+
[{go.mod,*.go}]
20+
indent_style = tab

.github/workflows/release.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# This GitHub action can publish assets for release when a tag is created.
2+
# Currently its setup to run on any tag that matches the pattern "v*" (ie. v0.1.0).
3+
#
4+
# This uses an action (crazy-max/ghaction-import-gpg) that assumes you set your
5+
# private key in the `GPG_PRIVATE_KEY` secret and passphrase in the `PASSPHRASE`
6+
# secret. If you would rather own your own GPG handling, please fork this action
7+
# or use an alternative one for key handling.
8+
#
9+
# You will need to pass the `--batch` flag to `gpg` in your signing step
10+
# in `goreleaser` to indicate this is being used in a non-interactive mode.
11+
#
12+
name: release
13+
on:
14+
push:
15+
tags:
16+
- 'v*'
17+
permissions:
18+
contents: write
19+
jobs:
20+
goreleaser:
21+
runs-on: ubuntu-latest
22+
steps:
23+
-
24+
name: Checkout
25+
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
26+
-
27+
name: Unshallow
28+
run: git fetch --prune --unshallow
29+
-
30+
name: Set up Go
31+
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0
32+
with:
33+
go-version-file: 'go.mod'
34+
cache: true
35+
-
36+
name: Import GPG key
37+
uses: crazy-max/ghaction-import-gpg@111c56156bcc6918c056dbef52164cfa583dc549 # v5.2.0
38+
id: import_gpg
39+
with:
40+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
41+
passphrase: ${{ secrets.PASSPHRASE }}
42+
-
43+
name: Run GoReleaser
44+
uses: goreleaser/goreleaser-action@f82d6c1c344bcacabba2c841718984797f664a6b # v4.2.0
45+
with:
46+
version: latest
47+
args: release --rm-dist
48+
env:
49+
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
50+
# GitHub sets this automatically
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.goreleaser.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Copyright (c) HashiCorp, Inc.
2+
# SPDX-License-Identifier: MPL-2.0
3+
4+
# Visit https://goreleaser.com for documentation on how to customize this
5+
# behavior.
6+
before:
7+
hooks:
8+
# this is just an example and not a requirement for provider building/publishing
9+
- go mod tidy
10+
builds:
11+
- env:
12+
# goreleaser does not work with CGO, it could also complicate
13+
# usage by users in CI/CD systems like Terraform Cloud where
14+
# they are unable to install libraries.
15+
- CGO_ENABLED=0
16+
mod_timestamp: '{{ .CommitTimestamp }}'
17+
flags:
18+
- -trimpath
19+
ldflags:
20+
- '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}'
21+
goos:
22+
- freebsd
23+
- windows
24+
- linux
25+
- darwin
26+
goarch:
27+
- amd64
28+
- '386'
29+
- arm
30+
- arm64
31+
ignore:
32+
- goos: darwin
33+
goarch: '386'
34+
binary: '{{ .ProjectName }}_v{{ .Version }}'
35+
archives:
36+
- format: zip
37+
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
38+
checksum:
39+
extra_files:
40+
- glob: 'terraform-registry-manifest.json'
41+
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
42+
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
43+
algorithm: sha256
44+
signs:
45+
- artifacts: checksum
46+
args:
47+
# if you are using this in a GitHub action or some other automated pipeline, you
48+
# need to pass the batch flag to indicate its not interactive.
49+
- "--batch"
50+
- "--local-user"
51+
- "{{ .Env.GPG_FINGERPRINT }}" # set this environment variable for your signing key
52+
- "--output"
53+
- "${signature}"
54+
- "--detach-sign"
55+
- "${artifact}"
56+
release:
57+
extra_files:
58+
- glob: 'terraform-registry-manifest.json'
59+
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
60+
# If you want to manually examine the release before its live, uncomment this line:
61+
# draft: true
62+
changelog:
63+
skip: true

Initialize-TerraformDocumentation.ps1

Lines changed: 0 additions & 27 deletions
This file was deleted.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Stack Overflow
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 0 additions & 37 deletions
This file was deleted.

README.md

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,43 @@
1-
# Terraform Provider Stack Overflow
1+
# Terraform Provider for Stack Overflow
22

3-
Run the following command to build the provider
3+
The Terraform Provider for Stack Overflow is a Terraform plugin provider that allows you to manage questions, answers, and articles for your Stack Overflow for Teams.
44

5-
```powershell
6-
# Windows
7-
go build -o terraform-provider-stackoverflow.exe
8-
cp terraform-provider-stackoverflow.exe ~/go/bin
9-
```
5+
## Using the Provider
6+
---------------------
107

11-
Create a `terraform.rc` file in the %APPDATA% directory.
8+
To use a released version of the Terraform provider in your environment, run `terraform init` and Terraform will automatically install the provider from the Terraform Registry. To specify a particular provider version when installing released providers, see the [Terraform documentation on provider versioning](https://www.terraform.io/docs/configuration/providers.html#version-provider-versions).
129

13-
```powershell
14-
cd $env:APPDATA
15-
mk terraform.rc
16-
```
10+
## Example
11+
----------
1712

18-
Add the following content to the `terraform.rc` file:
13+
```terraform
14+
provider "stackoverflow" {
15+
team_name = "my-team-name"
16+
access_token = "xxxx"
17+
default_tags = ["terraform"]
18+
}
1919
20-
```
21-
provider_installation {
22-
dev_overrides {
23-
"registry.terraform.io/hashicorp/stackoverflow" = "C:/Users/rbolhofer/go/bin"
24-
}
25-
direct {}
20+
resource "stackoverflow_filter" "filter" {
2621
}
27-
```
2822
29-
## Test sample configuration
23+
resource "stackoverflow_article" "article" {
24+
article_type = "announcement"
25+
title = "Terraform Provider for Stack Overflow is available!"
26+
body_markdown = "Look for the Stack Overflow provider in the Terraform registry"
27+
tags = ["example"]
28+
filter = stackoverflow_filter.filter.id
29+
}
3030
31-
In a new directory, create a file named `main.tf` and add the following content:
31+
resource "stackoverflow_question" "question" {
32+
title = "Stack Overflow Terraform Provider"
33+
body_markdown = "What is the Terraform Provider for Stack Overflow?"
34+
tags = ["example"]
35+
filter = stackoverflow_filter.filter.id
36+
}
3237
33-
```
34-
resource "stackoverflow_article" "test_article" {
35-
article_type = "knowledge-article"
36-
title = "Test Article"
37-
body_markdown = "# Hello World"
38-
tags = ["test"]
38+
resource "stackoverflow_answer" "answer" {
39+
question_id = stackoverflow_question.question.id
40+
body_markdown = "It is a Terraform plugin provider to manage resources in Stack Overflow for Teams"
41+
filter = stackoverflow_filter.filter.id
3942
}
4043
```
41-
42-
Then initialize and run Terraform:
43-
44-
```powershell
45-
terraform init
46-
terraform plan -out terraform.tfplan
47-
```

docs/data-sources/answer.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "stackoverflow_answer Data Source - terraform-provider-stackoverflow"
4+
subcategory: ""
5+
description: |-
6+
7+
---
8+
9+
# stackoverflow_answer (Data Source)
10+
11+
The `answer` data source allows for referencing an existing answer in Stack Overflow.
12+
13+
## Example
14+
15+
```
16+
data "stackoverflow_answer" "answer" {
17+
answer_id = 1
18+
filter = "XXXX"
19+
}
20+
```
21+
22+
<!-- schema generated by tfplugindocs -->
23+
## Schema
24+
25+
### Required
26+
27+
- `answer_id` (Number) The identifier for the answer
28+
- `filter` (String) The API filter to use
29+
30+
### Read-Only
31+
32+
- `id` (String) The ID of this resource.
33+
34+

docs/data-sources/article.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "stackoverflow_article Data Source - terraform-provider-stackoverflow"
4+
subcategory: ""
5+
description: |-
6+
7+
---
8+
9+
# stackoverflow_article (Data Source)
10+
11+
The `article` data source allows for referencing an existing article in Stack Overflow.
12+
13+
```
14+
data "stackoverflow_article" "article" {
15+
article_id = 1
16+
filter = "XXXX"
17+
}
18+
```
19+
20+
<!-- schema generated by tfplugindocs -->
21+
## Schema
22+
23+
### Required
24+
25+
- `article_id` (Number) The identifier for the article
26+
- `filter` (String) The API filter to use
27+
28+
### Read-Only
29+
30+
- `id` (String) The ID of this resource.
31+
32+

0 commit comments

Comments
 (0)