Skip to content

Commit

Permalink
Add terraform 0.12 support
Browse files Browse the repository at this point in the history
  • Loading branch information
sagikazarmark committed Jul 23, 2019
1 parent c432ad7 commit a3e4ba8
Show file tree
Hide file tree
Showing 9 changed files with 535 additions and 129 deletions.
61 changes: 53 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ commands:
parameters:
kubernetes_version:
type: string
terraform_version:
type: string
example_dir:
type: string
steps:
- setup_minikube:
minikube_version: v1.1.0
Expand All @@ -108,7 +112,9 @@ commands:
- restore_go_module_cache
- run:
name: Run integration tests
command: make test-integration
command: make TERRAFORM_VERSION=<< parameters.terraform_version >> test-integration
environment:
EXAMPLE_DIR: << parameters.example_dir >>

jobs:
checks:
Expand All @@ -128,23 +134,53 @@ jobs:
paths:
- /go/pkg/mod

integration-test-k8s1-14:
integration-test-012-k8s1-14:
executor: minikube
steps:
- integration:
kubernetes_version: v1.14.2
terraform_version: 0.12.5
example_dir: examples/0.12

integration-test-k8s1-13:
integration-test-012-k8s1-13:
executor: minikube
steps:
- integration:
kubernetes_version: v1.13.6
terraform_version: 0.12.5
example_dir: examples/0.12

integration-test-k8s1-12:
integration-test-012-k8s1-12:
executor: minikube
steps:
- integration:
kubernetes_version: v1.12.9
terraform_version: 0.12.5
example_dir: examples/0.12

integration-test-pre012-k8s1-14:
executor: minikube
steps:
- integration:
kubernetes_version: v1.14.2
terraform_version: 0.11.14
example_dir: examples/pre0.12

integration-test-pre012-k8s1-13:
executor: minikube
steps:
- integration:
kubernetes_version: v1.13.6
terraform_version: 0.11.14
example_dir: examples/pre0.12

integration-test-pre012-k8s1-12:
executor: minikube
steps:
- integration:
kubernetes_version: v1.12.9
terraform_version: 0.11.14
example_dir: examples/pre0.12

release:
executor: docker
Expand All @@ -162,19 +198,28 @@ workflows:
ci:
jobs:
- checks
- integration-test-k8s1-14:
- integration-test-012-k8s1-14:
requires:
- checks
- integration-test-012-k8s1-13:
requires:
- checks
- integration-test-012-k8s1-12:
requires:
- checks
- integration-test-pre012-k8s1-14:
requires:
- checks
- integration-test-k8s1-13:
- integration-test-pre012-k8s1-13:
requires:
- checks
- integration-test-k8s1-12:
- integration-test-pre012-k8s1-12:
requires:
- checks
- release:
requires:
- checks
- integration-test-k8s1-14
- integration-test-012-k8s1-14
filters:
tags:
only: /^v?\d+\.\d+\.\d+(-\S*)?$/
Expand Down
15 changes: 8 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ TEST_FORMAT = short-verbose
endif

# Dependency versions
GOTESTSUM_VERSION = 0.3.4
GOLANGCI_VERSION = 1.16.0
GORELEASER_VERSION = 0.108.0
TERRAFORM_VERSION = 0.11.14
GOTESTSUM_VERSION = 0.3.5
GOLANGCI_VERSION = 1.17.1
GORELEASER_VERSION = 0.113.0
TERRAFORM_VERSION = 0.12.5

GOLANG_VERSION = 1.12

Expand All @@ -49,11 +49,12 @@ endif
go build ${GOARGS} -tags "${GOTAGS}" -ldflags "${LDFLAGS}" -o ${BUILD_DIR}/${BINARY_NAME} .

.PHONY: test-integration
test-integration: EXAMPLE_DIR ?= examples/0.12
test-integration: build bin/terraform ## Execute integration tests
cp build/terraform-provider-k8s .
bin/terraform init examples
bin/terraform apply -auto-approve examples
bin/terraform destroy -auto-approve examples
bin/terraform init ${EXAMPLE_DIR}
bin/terraform apply -auto-approve ${EXAMPLE_DIR}
bin/terraform destroy -auto-approve ${EXAMPLE_DIR}
rm terraform-provider-k8s

bin/terraform: bin/terraform-${TERRAFORM_VERSION}
Expand Down
24 changes: 24 additions & 0 deletions examples/0.12/example.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
data "template_file" "my-configmap" {
template = file("${path.module}/../manifests/my-configmap.yaml")

vars = {
greeting = var.greeting
}
}

resource "k8s_manifest" "my-configmap" {
content = data.template_file.my-configmap.rendered
}

data "template_file" "nginx-deployment" {
template = file("${path.module}/../manifests/nginx-deployment.yaml")

vars = {
replicas = var.replicas
}
}

resource "k8s_manifest" "nginx-deployment" {
content = data.template_file.nginx-deployment.rendered
}

10 changes: 10 additions & 0 deletions examples/0.12/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
variable "greeting" {
type = string
default = "Hello, world!"
}

variable "replicas" {
type = string
default = 3
}

4 changes: 4 additions & 0 deletions examples/0.12/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

terraform {
required_version = ">= 0.12"
}
4 changes: 2 additions & 2 deletions examples/example.tf → examples/pre0.12/example.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
data "template_file" "my-configmap" {
template = "${file("${path.module}/manifests/my-configmap.yaml")}"
template = "${file("${path.module}/../manifests/my-configmap.yaml")}"

vars {
greeting = "${var.greeting}"
Expand All @@ -11,7 +11,7 @@ resource "k8s_manifest" "my-configmap" {
}

data "template_file" "nginx-deployment" {
template = "${file("${path.module}/manifests/nginx-deployment.yaml")}"
template = "${file("${path.module}/../manifests/nginx-deployment.yaml")}"

vars {
replicas = "${var.replicas}"
Expand Down
File renamed without changes.
49 changes: 1 addition & 48 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,7 @@ module github.com/banzaicloud/terraform-provider-k8s
go 1.12

require (
github.com/agext/levenshtein v1.2.1 // indirect
github.com/apparentlymart/go-cidr v0.0.0-20170616213631-2bd8b58cf427 // indirect
github.com/apparentlymart/go-textseg v0.0.0-20170531203952-b836f5c4d331 // indirect
github.com/armon/go-radix v0.0.0-20170727155443-1fca145dffbc // indirect
github.com/aws/aws-sdk-go v1.12.70 // indirect
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/blang/semver v3.5.1+incompatible // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-ini/ini v1.32.0 // indirect
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect
github.com/golang/protobuf v1.0.0 // indirect
github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce // indirect
github.com/hashicorp/go-cleanhttp v0.0.0-20171218145408-d5fe4b57a186 // indirect
github.com/hashicorp/go-getter v0.0.0-20180123174312-285374cdfad6 // indirect
github.com/hashicorp/go-hclog v0.0.0-20180122232401-5bcb0f17e364 // indirect
github.com/hashicorp/go-multierror v0.0.0-20171204182908-b7773ae21874 // indirect
github.com/hashicorp/go-plugin v0.0.0-20180125190438-e53f54cbf51e // indirect
github.com/hashicorp/go-uuid v0.0.0-20160717022140-64130c7a86d7 // indirect
github.com/hashicorp/go-version v0.0.0-20171129150820-4fe82ae3040f // indirect
github.com/hashicorp/hcl v0.0.0-20171017181929-23c074d0eceb // indirect
github.com/hashicorp/hcl2 v0.0.0-20180202160940-9f91684a1f17 // indirect
github.com/hashicorp/hil v0.0.0-20170627220502-fa9f258a9250 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform v0.11.3
github.com/hashicorp/yamux v0.0.0-20171219165022-683f49123a33 // indirect
github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8 // indirect
github.com/kr/pretty v0.1.0 // indirect
github.com/hashicorp/terraform v0.12.5
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/mattn/go-isatty v0.0.3 // indirect
github.com/mitchellh/cli v0.0.0-20180117155440-518dc677a1e1 // indirect
github.com/mitchellh/copystructure v0.0.0-20170525013902-d23ffcb85de3 // indirect
github.com/mitchellh/go-homedir v0.0.0-20161203194507-b8bc1bf76747 // indirect
github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77 // indirect
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 // indirect
github.com/mitchellh/hashstructure v0.0.0-20170609045927-2bca23e0e452 // indirect
github.com/mitchellh/mapstructure v0.0.0-20180111000720-b4575eea38cc // indirect
github.com/mitchellh/reflectwalk v0.0.0-20170726202117-63d60e9d0dbc // indirect
github.com/oklog/run v1.0.0 // indirect
github.com/posener/complete v0.0.0-20171104095702-dc2bc5a81acc // indirect
github.com/satori/go.uuid v1.2.0 // indirect
github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a // indirect
github.com/stretchr/testify v1.3.0 // indirect
github.com/ulikunitz/xz v0.5.4 // indirect
github.com/zclconf/go-cty v0.0.0-20180106055834-709e4033eeb0 // indirect
golang.org/x/sync v0.0.0-20190423024810-112230192c58 // indirect
google.golang.org/genproto v0.0.0-20180125080656-4eb30f4778ee // indirect
google.golang.org/grpc v1.9.2 // indirect
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
gopkg.in/ini.v1 v1.42.0 // indirect
)
Loading

0 comments on commit a3e4ba8

Please sign in to comment.