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 1 commit
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
7 changes: 7 additions & 0 deletions features/src/terraform/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.1.0] - 2024-05-13
Gary-H9 marked this conversation as resolved.
Show resolved Hide resolved

### Changed

- Added `tflint`


Gary-H9 marked this conversation as resolved.
Show resolved Hide resolved
## [1.0.0] - 2024-05-13

### Changed
Expand Down
4 changes: 2 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,9 +1,9 @@
{
"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 + tflint",
Gary-H9 marked this conversation as resolved.
Show resolved Hide resolved
"options": {
"terraformCliVersion": {
"type": "string",
Expand Down
32 changes: 32 additions & 0 deletions features/src/terraform/install-tflint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/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

install --owner=vscode --group=vscode --mode=775 "$(dirname "${0}")"/src/home/vscode/.devcontainer/featurerc.d/tflint-cli.sh /home/vscode/.devcontainer/featurerc.d/tflint-cli.sh

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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

complete -o nospace -C /usr/local/bin/tflint tflint
Gary-H9 marked this conversation as resolved.
Show resolved Hide resolved
Loading