Skip to content

Commit 03e722b

Browse files
authored
Merge pull request #209 from szymonos/feat/tflint
feat(sh): install_tflint
2 parents c2fd4df + a98507f commit 03e722b

File tree

4 files changed

+53
-3
lines changed

4 files changed

+53
-3
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env bash
2+
: '
3+
sudo .assets/provision/install_tflint.sh >/dev/null
4+
'
5+
if [ $EUID -ne 0 ]; then
6+
printf '\e[31;1mRun the script as root.\e[0m\n' >&2
7+
exit 1
8+
fi
9+
10+
# dotsource file with common functions
11+
. .assets/provision/source.sh
12+
13+
# define variables
14+
APP='tflint'
15+
REL=$1
16+
OWNER='terraform-linters'
17+
REPO='tflint'
18+
# get latest release if not provided as a parameter
19+
if [ -z "$REL" ]; then
20+
REL="$(get_gh_release_latest --owner $OWNER --repo $REPO)"
21+
if [ -z "$REL" ]; then
22+
printf "\e[31mFailed to get the latest version of $APP.\e[0m\n" >&2
23+
exit 1
24+
fi
25+
fi
26+
# return the release
27+
echo $REL
28+
29+
if type $APP &>/dev/null; then
30+
VER=$($APP --version | sed -En 's/.* ([0-9\.]+)$/\1/p')
31+
if [ "$REL" = "$VER" ]; then
32+
printf "\e[32m$APP v$VER is already latest\e[0m\n" >&2
33+
exit 0
34+
fi
35+
fi
36+
37+
printf "\e[92minstalling \e[1m$APP\e[22m v$REL\e[0m\n" >&2
38+
# create temporary dir for the downloaded binary
39+
TMP_DIR=$(mktemp -dp "$HOME")
40+
# calculate download uri
41+
URL="https://github.com/$OWNER/$REPO/releases/download/v${REL}/tflint_linux_amd64.zip"
42+
# download and install file
43+
if download_file --uri "$URL" --target_dir "$TMP_DIR"; then
44+
unzip -q "$TMP_DIR/$(basename $URL)" -d "$TMP_DIR"
45+
install -m 0755 "$TMP_DIR/tflint" /usr/bin/
46+
fi
47+
# remove temporary dir
48+
rm -fr "$TMP_DIR"

.assets/scripts/linux_setup.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,9 @@ for sc in ${scope_arr[@]}; do
210210
terraform)
211211
printf "\e[96minstalling terraform utils...\e[0m\n"
212212
sudo .assets/provision/install_terraform.sh
213-
sudo .assets/provision/install_tfswitch.sh
214213
sudo .assets/provision/install_terrascan.sh
214+
sudo .assets/provision/install_tflint.sh
215+
sudo .assets/provision/install_tfswitch.sh
215216
;;
216217
zsh)
217218
printf "\e[96minstalling zsh...\e[0m\n"

wsl/wsl_install.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ List of installation scopes. Valid values:
2828
- python: uv, prek, pip, venv
2929
- rice: btop, cmatrix, cowsay, fastfetch
3030
- shell: bat, eza, oh-my-posh, ripgrep, yq
31-
- terraform: terraform, terrascan, tfswitch
31+
- terraform: terraform, terrascan, tflint, tfswitch
3232
- zsh: zsh shell with plugins
3333
.PARAMETER Repos
3434
List of GitHub repositories in format "Owner/RepoName" to clone into the WSL.

wsl/wsl_setup.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ List of installation scopes. Valid values:
3030
- python: uv, prek, pip, venv
3131
- rice: btop, cmatrix, cowsay, fastfetch
3232
- shell: bat, eza, oh-my-posh, ripgrep, yq
33-
- terraform: terraform, terrascan, tfswitch
33+
- terraform: terraform, terrascan, tflint, tfswitch
3434
- zsh: zsh shell with plugins
3535
.PARAMETER OmpTheme
3636
Specify to install oh-my-posh prompt theme engine and name of the theme to be used.
@@ -587,6 +587,7 @@ process {
587587
Write-Host 'installing terraform utils...' -ForegroundColor Cyan
588588
$rel_tf = wsl.exe --distribution $Distro --user root --exec .assets/provision/install_terraform.sh $Script:rel_tf
589589
$rel_trs = wsl.exe --distribution $Distro --user root --exec .assets/provision/install_terrascan.sh $Script:rel_trs
590+
$rel_tfl = wsl.exe --distribution $Distro --user root --exec .assets/provision/install_tflint.sh $Script:rel_tfl
590591
$rel_tfs = wsl.exe --distribution $Distro --user root --exec .assets/provision/install_tfswitch.sh $Script:rel_tfs
591592
continue
592593
}

0 commit comments

Comments
 (0)