-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from mineiros-io/peterdam/support-recursive
feat: add support for recursive terradoc `fmt` and `generate`
- Loading branch information
Showing
5 changed files
with
161 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,31 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
set -u | ||
set -o pipefail | ||
|
||
if ! command -v terradoc >/dev/null 2>&1; then | ||
echo >&2 "terradoc is not available on this system." | ||
echo >&2 "Please install it by running 'go install github.com/mineiros-io/terradoc/cmd/terradoc@latest'" | ||
exit 1 | ||
fi | ||
# shellcheck disable=SC2155,SC2034 | ||
readonly ARGS=("$@") | ||
|
||
terradoc fmt $1 -w | ||
function is_binary_available() { | ||
local bin_list=( terradoc ) | ||
for b in "${bin_list[@]}"; do | ||
if [ -x "$(type -p "${b}")" ]; then | ||
declare -g "_${b}"="$(type -p "${b}")" | ||
else | ||
echo >&2 "The executable ${b} is missing" | ||
exit 1 | ||
fi | ||
done | ||
} | ||
|
||
main() { | ||
is_binary_available | ||
|
||
for filename in "${ARGS[@]}"; do | ||
# shellcheck disable=SC2154 | ||
"${_terradoc}" fmt -w "${filename}" | ||
done | ||
} | ||
# Run script | ||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,34 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
set -u | ||
set -o pipefail | ||
|
||
if ! command -v terradoc >/dev/null 2>&1; then | ||
echo >&2 "terradoc is not available on this system." | ||
echo >&2 "Please install it by running 'go install github.com/mineiros-io/terradoc/cmd/terradoc@latest'" | ||
exit 1 | ||
fi | ||
# shellcheck disable=SC2155,SC2034 | ||
readonly ARGS=("$@") | ||
|
||
terradoc generate $1 -o $2 | ||
function is_binary_available() { | ||
local bin_list=( terradoc ) | ||
for b in "${bin_list[@]}"; do | ||
if [ -x "$(type -p "${b}")" ]; then | ||
declare -g "_${b}"="$(type -p "${b}")" | ||
else | ||
echo >&2 "The executable ${b} is missing" | ||
exit 1 | ||
fi | ||
done | ||
} | ||
|
||
main() { | ||
is_binary_available | ||
|
||
local filename_base="" | ||
|
||
for filename in "${ARGS[@]}"; do | ||
filename_base="$(basename "${filename}")" | ||
# shellcheck disable=SC2154 | ||
"${_terradoc}" generate "${filename}" -o "$(dirname "${filename}")/${filename_base/.tfdoc.hcl/.md}" | ||
done | ||
} | ||
# Run script | ||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,31 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
set -u | ||
set -o pipefail | ||
|
||
if ! command -v terradoc >/dev/null 2>&1; then | ||
echo >&2 "terradoc is not available on this system." | ||
echo >&2 "Please install it by running 'go install github.com/mineiros-io/terradoc/cmd/terradoc@latest'" | ||
exit 1 | ||
fi | ||
# shellcheck disable=SC2155,SC2034 | ||
readonly ARGS=("$@") | ||
|
||
terradoc validate $1 | ||
function is_binary_available() { | ||
local bin_list=( terradoc ) | ||
for b in "${bin_list[@]}"; do | ||
if [ -x "$(type -p "${b}")" ]; then | ||
declare -g "_${b}"="$(type -p "${b}")" | ||
else | ||
echo >&2 "The executable ${b} is missing" | ||
exit 1 | ||
fi | ||
done | ||
} | ||
|
||
main() { | ||
is_binary_available | ||
|
||
local filename="${ARGS[0]}" | ||
echo "$filename" | ||
# shellcheck disable=SC2154 | ||
"${_terradoc}" validate "${filename}" | ||
} | ||
# Run script | ||
main |