diff --git a/.gitignore b/.gitignore index fd3ad8e..805e66f 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,7 @@ website/node_modules *.test *.iml +test/.terraform.lock.hcl website/vendor # Test exclusions diff --git a/GNUmakefile b/GNUmakefile index eb69bd4..bd11633 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -3,7 +3,7 @@ HOSTNAME=github.com NAMESPACE=nleiva NAME=nautobot BINARY=terraform-provider-${NAME} -VERSION=0.2.4 +VERSION=0.3.0 OS_ARCH=$(shell go env GOOS)_$(shell go env GOARCH) @@ -27,8 +27,8 @@ 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 $(HOME)/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH} + mv ${BINARY} $(HOME)/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH} get-api: cd client; wget https://demo.nautobot.com/api/swagger.yaml\?api_version\=1.3 -O swagger.yaml @@ -46,4 +46,16 @@ gpg-key: gpg --armor --export-secret-key $(EMAIL) -w0 | xclip -selection clipboard -i testacc: - TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m + TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m + +local: install + sed -i "s-/home/nleiva-${HOME}-" test/.terraform/plugin_path + sed -i 's-version =.*-version = "${VERSION}"-' test/main.tf + cd test; terraform init -upgrade && \ + terraform apply -auto-approve; cd .. + +tag: local + git add . + git commit -m "Bump to version ${VERSION}" + git tag -a -m "Bump to version ${VERSION}" v${VERSION} + git push --follow-tag \ No newline at end of file diff --git a/test/main.tf b/test/main.tf new file mode 100644 index 0000000..9cce70e --- /dev/null +++ b/test/main.tf @@ -0,0 +1,18 @@ +terraform { + required_providers { + nautobot = { + version = "0.3.0" + source = "github.com/nleiva/nautobot" + } + } +} + +provider "nautobot" { + url = "https://demo.nautobot.com/api/" + token = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +} + +resource "nautobot_manufacturer" "new" { + description = "Created with Terraform" + name = "New Vendor" +} \ No newline at end of file diff --git a/test/output.tf b/test/output.tf new file mode 100644 index 0000000..bc8b69d --- /dev/null +++ b/test/output.tf @@ -0,0 +1,17 @@ +data "nautobot_manufacturers" "all" { + depends_on = [nautobot_manufacturer.new] +} + +variable "manufacturer_name" { + type = string + default = "New Vendor" +} + +# Only returns te created manufacturer +output "data_source_example" { + value = { + for manufacturer in data.nautobot_manufacturers.all.manufacturers : + manufacturer.id => manufacturer + if manufacturer.name == var.manufacturer_name + } +} \ No newline at end of file