Skip to content

Commit

Permalink
Translate docscheck target to a shell script
Browse files Browse the repository at this point in the history
Signed-off-by: Dimitrios Karagiannis <[email protected]>
  • Loading branch information
alkar committed Feb 3, 2020
1 parent f14aa12 commit 82f1822
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
17 changes: 1 addition & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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..."
Expand Down
19 changes: 18 additions & 1 deletion scripts/providerjsonschema.sh → scripts/docscheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

set -eou pipefail

echo "==> Extracting provider json schema..."
tmpd=$(mktemp -d)
go build -o $tmpd .
(
Expand Down Expand Up @@ -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}"

0 comments on commit 82f1822

Please sign in to comment.