Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔧 Add tflint to terraform feature #119

Merged
merged 4 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Gary-H9 marked this conversation as resolved.
Show resolved Hide resolved
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
Loading