diff --git a/Makefile b/Makefile index 582a394..356e1d1 100644 --- a/Makefile +++ b/Makefile @@ -20,23 +20,8 @@ depscheck: (echo; echo "Unexpected difference in vendor/ directory. Run 'go mod vendor' command or revert any go.mod/go.sum/vendor changes and commit."; exit 1) docscheck: - @echo "==> Extracting provider json schema..." - $(eval PROVIDER_SCHEMA=$(shell PROVIDER_NAME=$(PKG_NAME) $(CURDIR)/scripts/providerjsonschema.sh)) - @echo "==> Checking docs with tfproviderdocs..." @rm -rf $(CURDIR)/website/docs/assets $(CURDIR)/website/docs/layouts # these are generated by website targets and tfproviderdocs will fail - @docker run \ - --interactive \ - --rm \ - --tty \ - --volume "$(shell pwd)/website:/terraform-provider-megaport/website" \ - --volume "$(PROVIDER_SCHEMA):/provider-schema" \ - --workdir /terraform-provider-megaport \ - bflad/tfproviderdocs \ - check \ - -allowed-resource-subcategories=resources,datasources \ - -providers-schema-json=/provider-schema/schema.json \ - -require-resource-subcategory - @rm -rf $(PROVIDER_SCHEMA) + @sh -c "PROVIDER_NAME=$(PKG_NAME) $(CURDIR)/scripts/docscheck.sh" fmt: @echo "==> Fixing source code with gofmt..." diff --git a/scripts/providerjsonschema.sh b/scripts/docscheck.sh similarity index 53% rename from scripts/providerjsonschema.sh rename to scripts/docscheck.sh index f044e7c..bed2e99 100755 --- a/scripts/providerjsonschema.sh +++ b/scripts/docscheck.sh @@ -2,6 +2,7 @@ set -eou pipefail +echo "==> Extracting provider json schema..." tmpd=$(mktemp -d) go build -o $tmpd . ( @@ -29,4 +30,20 @@ go build -o $tmpd . rm main.tf rm terraform-provider-${PROVIDER_NAME} ) -echo $tmpd + +echo "==> Checking docs with tfproviderdocs..." + +docker run \ + --interactive \ + --rm \ + --tty \ + --volume "${PWD}/website:/terraform-provider-megaport/website" \ + --volume "${tmpd}:/provider-schema" \ + --workdir /terraform-provider-megaport \ + bflad/tfproviderdocs \ + check \ + -allowed-resource-subcategories=resources,datasources \ + -providers-schema-json=/provider-schema/schema.json \ + -require-resource-subcategory + +rm -rf "${tmpd}"