Skip to content

Commit 72e3f59

Browse files
committed
* Initial commit.
0 parents  commit 72e3f59

File tree

19 files changed

+1138
-0
lines changed

19 files changed

+1138
-0
lines changed

.gitignore

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
.DS_Store
2+
terraform-provider-swim
3+
bin
4+
5+
# Created by https://www.toptal.com/developers/gitignore/api/go,terraform
6+
# Edit at https://www.toptal.com/developers/gitignore?templates=go,terraform
7+
8+
### Go ###
9+
# Binaries for programs and plugins
10+
*.exe
11+
*.exe~
12+
*.dll
13+
*.so
14+
*.dylib
15+
16+
# Test binary, built with `go test -c`
17+
*.test
18+
19+
# Output of the go coverage tool, specifically when used with LiteIDE
20+
*.out
21+
22+
# Dependency directories (remove the comment below to include it)
23+
# vendor/
24+
25+
### Go Patch ###
26+
/vendor/
27+
/Godeps/
28+
29+
### Terraform ###
30+
# Local .terraform directories
31+
**/.terraform/*
32+
33+
# .tfstate files
34+
*.tfstate
35+
*.tfstate.*
36+
37+
# Crash log files
38+
crash.log
39+
40+
# Ignore any .tfvars files that are generated automatically for each Terraform run. Most
41+
# .tfvars files are managed as part of configuration and so should be included in
42+
# version control.
43+
#
44+
# example.tfvars
45+
46+
# Ignore override files as they are usually used to override resources locally and so
47+
# are not checked in
48+
override.tf
49+
override.tf.json
50+
*_override.tf
51+
*_override.tf.json
52+
53+
# Include override files you do wish to add to version control using negated pattern
54+
# !example_override.tf
55+
56+
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
57+
# example: *tfplan*
58+
59+
# End of https://www.toptal.com/developers/gitignore/api/go,terraform
60+
61+
# Ignore CLI configuration files
62+
.terraformrc
63+
terraform.rc
64+
terraform
65+
**/.idea/*
66+
**/.gradle
67+
**/.idea
68+
**/build
69+
**/out

Makefile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
TEST?=$$(go list ./... | grep -v 'vendor')
2+
HOSTNAME=swim.inc
3+
NAMESPACE=swim
4+
NAME=swim
5+
BINARY=terraform-provider-${NAME}
6+
VERSION=0.1
7+
OS_ARCH=linux_amd64
8+
9+
default: install
10+
11+
build:
12+
go build -o ${BINARY}
13+
14+
release:
15+
GOOS=darwin GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_darwin_amd64
16+
GOOS=freebsd GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_freebsd_386
17+
GOOS=freebsd GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_freebsd_amd64
18+
GOOS=freebsd GOARCH=arm go build -o ./bin/${BINARY}_${VERSION}_freebsd_arm
19+
GOOS=linux GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_linux_386
20+
GOOS=linux GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_linux_amd64
21+
GOOS=linux GOARCH=arm go build -o ./bin/${BINARY}_${VERSION}_linux_arm
22+
GOOS=openbsd GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_openbsd_386
23+
GOOS=openbsd GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_openbsd_amd64
24+
GOOS=solaris GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_solaris_amd64
25+
GOOS=windows GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_windows_386
26+
GOOS=windows GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_windows_amd64
27+
28+
install: build
29+
mkdir -p ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH}
30+
mv ${BINARY} ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH}
31+
32+
test:
33+
go test -i $(TEST) || exit 1
34+
echo $(TEST) | xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4
35+
36+
testacc:
37+
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Terraform Provider Swim
2+
3+
### Install
4+
5+
Run the formatter
6+
```shell
7+
go fmt ./...
8+
```
9+
10+
Build the provider.
11+
```shell
12+
go build -o terraform-provider-swim
13+
```
14+
15+
Build and install the provider locally.
16+
```shell
17+
make install
18+
```
19+
20+
### Run
21+
22+
Run the Swim server.
23+
```shell
24+
(cd swim-server && ./gradlew run)
25+
```
26+
27+
Initialize the workspace and apply the terraform plan.
28+
```shell
29+
(cd examples && terraform init && terraform apply)
30+
```
31+
32+
### Clean up
33+
Destroy the terraform stack.
34+
```shell
35+
(cd examples && terraform destroy)
36+
```

examples/main.tf

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
terraform {
2+
required_providers {
3+
swim = {
4+
version = "0.1"
5+
source = "swim.inc/swim/swim"
6+
}
7+
8+
docker = {
9+
source = "kreuzwerker/docker"
10+
version = "~> 2.21.0"
11+
}
12+
}
13+
}
14+
15+
# Docker
16+
provider "docker" {}
17+
18+
resource "docker_image" "nginx" {
19+
name = "nginx:latest"
20+
keep_locally = false
21+
}
22+
23+
resource "docker_container" "nginx" {
24+
image = docker_image.nginx.image_id
25+
name = "tutorial"
26+
ports {
27+
internal = 80
28+
external = 8000
29+
}
30+
}
31+
32+
# Swim
33+
provider "swim" {
34+
url = "ws://127.0.0.1:9001/"
35+
}
36+
37+
resource "swim_endpoint" "state" {
38+
node = "/unit"
39+
lane = "state"
40+
value = docker_container.nginx.id
41+
}
42+
43+
output "status" {
44+
value = swim_endpoint.state
45+
}

go.mod

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
module terraform-swim-provider
2+
3+
go 1.18
4+
5+
require github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.0
6+
7+
require (
8+
github.com/gin-contrib/sse v0.1.0 // indirect
9+
github.com/go-playground/locales v0.14.0 // indirect
10+
github.com/go-playground/universal-translator v0.18.0 // indirect
11+
github.com/go-playground/validator/v10 v10.10.0 // indirect
12+
github.com/goccy/go-json v0.9.7 // indirect
13+
github.com/gorilla/websocket v1.5.0 // indirect
14+
github.com/json-iterator/go v1.1.12 // indirect
15+
github.com/leodido/go-urn v1.2.1 // indirect
16+
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
17+
github.com/modern-go/reflect2 v1.0.2 // indirect
18+
github.com/pelletier/go-toml/v2 v2.0.1 // indirect
19+
github.com/sacOO7/go-logger v0.0.0-20180719173527-9ac9add5a50d // indirect
20+
github.com/ugorji/go/codec v1.2.7 // indirect
21+
golang.org/x/crypto v0.0.0-20220517005047-85d78b3ac167 // indirect
22+
gopkg.in/yaml.v2 v2.4.0 // indirect
23+
)
24+
25+
require (
26+
github.com/agext/levenshtein v1.2.2 // indirect
27+
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
28+
github.com/fatih/color v1.13.0 // indirect
29+
github.com/gin-gonic/gin v1.8.1
30+
github.com/golang/protobuf v1.5.2 // indirect
31+
github.com/google/go-cmp v0.5.9 // indirect
32+
github.com/hashicorp/errwrap v1.0.0 // indirect
33+
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
34+
github.com/hashicorp/go-hclog v1.2.1 // indirect
35+
github.com/hashicorp/go-multierror v1.1.1 // indirect
36+
github.com/hashicorp/go-plugin v1.4.4 // indirect
37+
github.com/hashicorp/go-uuid v1.0.3 // indirect
38+
github.com/hashicorp/go-version v1.6.0 // indirect
39+
github.com/hashicorp/hcl/v2 v2.14.1 // indirect
40+
github.com/hashicorp/logutils v1.0.0 // indirect
41+
github.com/hashicorp/terraform-plugin-go v0.14.0 // indirect
42+
github.com/hashicorp/terraform-plugin-log v0.7.0 // indirect
43+
github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c // indirect
44+
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect
45+
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
46+
github.com/mattn/go-colorable v0.1.12 // indirect
47+
github.com/mattn/go-isatty v0.0.14 // indirect
48+
github.com/mitchellh/copystructure v1.2.0 // indirect
49+
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
50+
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
51+
github.com/mitchellh/mapstructure v1.5.0 // indirect
52+
github.com/mitchellh/reflectwalk v1.0.2 // indirect
53+
github.com/oklog/run v1.0.0 // indirect
54+
github.com/olahol/melody v1.1.1
55+
github.com/sacOO7/gowebsocket v0.0.0-20210515122958-9396f1a71e23
56+
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
57+
github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect
58+
github.com/vmihailenco/tagparser v0.1.1 // indirect
59+
github.com/zclconf/go-cty v1.11.0 // indirect
60+
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect
61+
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6 // indirect
62+
golang.org/x/text v0.3.7 // indirect
63+
google.golang.org/appengine v1.6.6 // indirect
64+
google.golang.org/genproto v0.0.0-20200711021454-869866162049 // indirect
65+
google.golang.org/grpc v1.48.0 // indirect
66+
google.golang.org/protobuf v1.28.1 // indirect
67+
)

0 commit comments

Comments
 (0)