This repository has been archived by the owner on Jan 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
4,312 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
name: Test and build | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set up Go 1.13 | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: 1.13 | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v2 | ||
|
||
- name: Test | ||
working-directory: src | ||
run: go clean -testcache && go test -v ./... | ||
|
||
build: | ||
needs: test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set up Go 1.13 | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: 1.13 | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v2 | ||
|
||
- name: Build | ||
working-directory: src | ||
run: go build -o ../dist/terraform-provider-caddy . | ||
|
||
- name: Upload artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: terraform-provider-caddy | ||
path: dist/terraform-provider-caddy | ||
|
||
release: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/download-artifact@v2 | ||
with: | ||
name: terraform-provider-caddy | ||
path: dist/terraform-provider-caddy | ||
- name: Setup node | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 12 | ||
- name: PNPM install | ||
run: npm i -g pnpm && pnpm i -P | ||
- run: pnpm install | ||
- name: Semantic Release Action | ||
uses: saitho/semantic-release-action-pnpm@master | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | ||
env: | ||
GIT_AUTHOR_EMAIL: [email protected] | ||
GIT_AUTHOR_NAME: stackhead-bot | ||
GIT_COMMITTER_EMAIL: [email protected] | ||
GIT_COMMITTER_NAME: stackhead-bot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
dist | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
|
||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"plugins": [ | ||
"@semantic-release/commit-analyzer", | ||
"@semantic-release/release-notes-generator", | ||
[ | ||
"@semantic-release/github", | ||
{ | ||
"assets": [ | ||
{"path": "dist/terraform-provider-nginx", "label": "Provider binary"} | ||
] | ||
} | ||
] | ||
], | ||
"branches": [ | ||
"master" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Terraform Caddy provider | ||
|
||
This provider can be used to manage Caddy configurations. | ||
|
||
## [Documentation](docs/index.md) | ||
|
||
## Development | ||
|
||
### Build Go binary file | ||
|
||
```yaml | ||
go build -o dist/terraform-provider-caddy ./src | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Caddy Provider | ||
|
||
This provider can be used to manage Caddy configurations. | ||
|
||
## Installation | ||
|
||
1. Download a binary from the [release section](https://github.com/getstackhead/terraform-caddy/releases). | ||
2. Install it into the user plugins directory. | ||
* Windows: `%APPDATA%\terraform.d\plugins` | ||
* other OS: `~/.terraform.d/plugins` | ||
|
||
## Example Usage | ||
|
||
```hcl | ||
resource "caddy_server_block" "my-server" { | ||
filename = "test.conf" | ||
content = <<EOF | ||
my-server.com { | ||
respond "Hello, world!" | ||
} | ||
sub.my-server.com { | ||
respond "Hello, world!" | ||
} | ||
EOF | ||
} | ||
``` | ||
|
||
The file will be stored inside the configured folder. | ||
|
||
## Argument Reference | ||
|
||
In addition to [generic `provider` arguments](https://www.terraform.io/docs/configuration/providers.html) (e.g. `alias` and `version`), the following arguments are supported in the Nginx provider block: | ||
|
||
* `config_folder` - (Optional) Folder where all configurations are stored. Default: `/etc/caddy/conf.d` | ||
|
||
## Resources | ||
|
||
### [server_block](./resources/server_block.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Server Block Resource | ||
|
||
This resource represents a [Caddyfile](https://caddyserver.com/docs/caddyfile) in Caddy configuration directories. | ||
|
||
## Example Usage | ||
|
||
```hcl | ||
# This will create file //etc/caddy/conf.d/test.conf | ||
resource "caddy_server_block" "my-server" { | ||
filename = "test.conf" | ||
markers = { | ||
docker_port = docker_container.web.ports.external | ||
docker_ports = "${docker_container.web.ports.external},${docker_container.web2.ports.external}" | ||
} | ||
markers_split = { | ||
docker_ports = "," | ||
} | ||
content = <<EOF | ||
# content of file here | ||
# external docker port is: {# docker_port #} | ||
# access web port in array: {# docker_ports[0] #} | ||
# access web2 port in array: {# docker_ports[1] #} | ||
EOF | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
* `filename` - (Required) Name of the configuration file | ||
* `content` - (Required) Content of the configuration file | ||
* `markers`- (Optional) Key-Value map. Keys specified as marker (e.g. `{# key #}`, `{~ key ~}`, `{* key *}`) will be replaced by the assigned value. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module stackhead.io/terraform-caddy-provider | ||
|
||
go 1.13 | ||
|
||
require ( | ||
github.com/hashicorp/terraform-plugin-sdk v1.12.0 | ||
github.com/stretchr/testify v1.3.0 | ||
) |
Oops, something went wrong.