Skip to content
This repository has been archived by the owner on Feb 11, 2025. It is now read-only.

Commit

Permalink
add terratest suite
Browse files Browse the repository at this point in the history
  • Loading branch information
Ludovic Vannoorenberghe committed Feb 23, 2021
1 parent d43a9f2 commit 2e2509c
Show file tree
Hide file tree
Showing 6 changed files with 913 additions and 6 deletions.
16 changes: 11 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ NAMESPACE=edu
NAME=kuma
BINARY=terraform-provider-${NAME}
VERSION=0.1
OS_ARCH=linux_amd64
OS_ARCH=darwin_amd64

default: install

Expand All @@ -26,12 +26,18 @@ release:
GOOS=windows GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_windows_amd64

install: build
mkdir -p ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH}
mv ${BINARY} ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH}
mkdir -p ~/.terraform.d/plugins/${OS_ARCH}
mkdir -p ./examples/.terraform/plugins/${OS_ARCH}
cp ./bin/${BINARY} ~/.terraform.d/plugins/${OS_ARCH}
cp ./bin/${BINARY} ./examples/.terraform/plugins/${OS_ARCH}

setup:
curl https://releases.hashicorp.com/terraform/0.12.30/terraform_0.12.30_${OS_ARCH}.zip -o /tmp/terraform_0.12.30.zip
unzip /tmp/terraform_0.12.30.zip -d ./test

.PHONY: test
test:
go test -i $(TEST) || exit 1
echo $(TEST) | xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4
cd test && PATH=$(PWD)/test:${PATH} go test

testacc:
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3.7'
services:
cp:
image: kong-docker-kuma-docker.bintray.io/kuma-cp:0.7.3
image: kong-docker-kuma-docker.bintray.io/kuma-cp:1.0.8
command: run
ports:
- '5681:5681'
14 changes: 14 additions & 0 deletions examples/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,23 @@ provider "kuma" {
api_token = "test123"
}

resource "kuma_traffic_permission" "yolo_permission" {
mesh = "default"
name = "yolo_permission"

sources {
match = {
"kuma.io/service" = "*"
}
}

destinations {
match = {
"kuma.io/service" = "*"
}
}
}

output "yolo_permission_name" {
value = kuma_traffic_permission.yolo_permission.name
}
9 changes: 9 additions & 0 deletions test/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module github.com/datacamp-engineering/terraform-provider-kuma/test

go 1.15

require (
github.com/gruntwork-io/terratest v0.32.7
github.com/hashicorp/terraform-plugin-sdk/v2 v2.4.3
github.com/stretchr/testify v1.6.1
)
Loading

0 comments on commit 2e2509c

Please sign in to comment.