Skip to content

Commit

Permalink
🔧 Add tflint to terraform feature (#119)
Browse files Browse the repository at this point in the history
Signed-off-by: Gary <26419401+Gary-H9@users.noreply.github.com>
Co-authored-by: Jacob Woffenden <jacob.woffenden@digital.justice.gov.uk>
  • Loading branch information
Gary-H9 and Jacob Woffenden authored Aug 22, 2024
1 parent 078af3f commit 38f659f
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 2 deletions.
6 changes: 6 additions & 0 deletions features/src/terraform/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.1.0] - 2024-08-22

### Changed

- Added `tflint`

## [1.0.0] - 2024-05-13

### Changed
Expand Down
10 changes: 8 additions & 2 deletions features/src/terraform/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
{
"id": "terraform",
"version": "1.0.0",
"version": "1.1.0",
"name": "Terraform",
"documentationURL": "https://github.com/ministryofjustice/.devcontainer/tree/main/features/src/terraform",
"description": "Installs the Terraform CLI",
"description": "Installs the Terraform CLI and tflint",
"options": {
"terraformCliVersion": {
"type": "string",
"description": "Version of the Terraform CLI to install",
"proposals": ["latest"],
"default": "latest"
},
"tflintVersion": {
"type": "string",
"description": "Version of the tflint to install",
"proposals": ["latest"],
"default": "latest"
}
},
"customizations": {
Expand Down
30 changes: 30 additions & 0 deletions features/src/terraform/install-tflint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash

set -e

# shellcheck source=/dev/null
# file not accessible until being built
source /usr/local/bin/devcontainer-utils

get_system_architecture

GITHUB_REPOSITORY="terraform-linters/tflint"
VERSION="${TFLINTVERSION:-"latest"}"

if [[ "${VERSION}" == "latest" ]]; then
get_github_latest_tag "${GITHUB_REPOSITORY}"
VERSION="${GITHUB_LATEST_TAG}"
VERSION_STRIP_V="${GITHUB_LATEST_TAG_STRIP_V}"
else
# shellcheck disable=SC2034
VERSION_STRIP_V="${VERSION#v}"
fi

curl --fail-with-body --location "https://github.com/terraform-linters/tflint/releases/download/${VERSION}/tflint_linux_${ARCHITECTURE}.zip" \
--output "tflint_${VERSION_STRIP_V}_linux_${ARCHITECTURE}.zip"

unzip "tflint_${VERSION_STRIP_V}_linux_${ARCHITECTURE}.zip"

install --owner=vscode --group=vscode --mode=775 tflint /usr/local/bin/tflint

rm --recursive --force tflint "tflint_${VERSION_STRIP_V}_linux_${ARCHITECTURE}.zip"
3 changes: 3 additions & 0 deletions features/src/terraform/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ source /usr/local/bin/devcontainer-utils

logger "info" "Installing Terraform CLI (version: ${TERRAFORMCLIVERSION})"
bash "$(dirname "${0}")"/install-terraform-cli.sh

logger "info" "Installing tflint (version: ${TFLINTVERSION})"
bash "$(dirname "${0}")"/install-tflint.sh
2 changes: 2 additions & 0 deletions features/test/terraform/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ source dev-container-features-test-lib
check "terraform version" terraform version
check "terraform featurerc existence" stat /home/vscode/.devcontainer/featurerc.d/terraform-cli.sh

check "tflint version" tflint --version

reportResults

0 comments on commit 38f659f

Please sign in to comment.