forked from hashicorp/terraform-provider-azurerm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscaffold-website.sh
executable file
·55 lines (49 loc) · 1.57 KB
/
scaffold-website.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env bash
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0
function verifyVars {
echo "==> Verifying required variables are set..."
if [ "${BRAND_NAME}" == "" ]; then
echo -e "\nBRAND_NAME is unset, exiting"
exit 1
fi
if [ "${RESOURCE_NAME}" == "" ]; then
echo -e "\nRESOURCE_NAME is unset, exiting"
exit 1
fi
if [ "${RESOURCE_TYPE}" == "" ]; then
echo -e "\nRESOURCE_TYPE is unset, exiting"
exit 1
fi
if [ "${RESOURCE_TYPE}" == "resource" ]; then
if [ "${RESOURCE_ID}" == "" ]; then
echo -e "\nRESOURCE_ID is unset, exiting"
exit 1
fi
fi
if [[ -n "${EXAMPLE}" ]]; then
if [[ -z "${SERVICE_TYPE}" ]]; then
echo -e "\nSERVICE_TYPE is unset, exiting"
exit 1
fi
if [[ -z "${TESTCASE}" ]]; then
echo -e "\nTESTCASE is unset, exiting"
exit 1
fi
fi
echo "==> Validated."
}
function scaffoldDocumentation {
echo "==> Scaffolding Documentation..."
if [[ -z "$EXAMPLE" ]]; then
go run ./internal/tools/website-scaffold/main.go -name "${RESOURCE_NAME}" -brand-name "${BRAND_NAME}" -type "${RESOURCE_TYPE}" -resource-id "${RESOURCE_ID}" -website-path ./website/
else
go run ./internal/tools/website-scaffold/main.go -name "${RESOURCE_NAME}" -brand-name "${BRAND_NAME}" -type "${RESOURCE_TYPE}" -resource-id "${RESOURCE_ID}" -website-path ./website/ -example -root-dir . -service-pkg ./internal/services/"${SERVICE_TYPE}" -testcase "${TESTCASE}"
fi
echo "==> Done."
}
function main {
verifyVars
scaffoldDocumentation
}
main