From eac3db5292198bd966b8ccac442f360ba02244ec Mon Sep 17 00:00:00 2001 From: aidenvaines-cgi Date: Tue, 10 Mar 2026 12:15:34 +0000 Subject: [PATCH 1/2] CCM-14307 Fixing Hook path for TF Lint --- scripts/terraform/terraform.lib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/terraform/terraform.lib.sh b/scripts/terraform/terraform.lib.sh index 1f0aeb4..8a488bf 100644 --- a/scripts/terraform/terraform.lib.sh +++ b/scripts/terraform/terraform.lib.sh @@ -53,7 +53,7 @@ function terraform-destroy() { # dir=[path to a directory where the command will be executed, relative to the project's top-level directory, default is '.'] # opts=[options to pass to the Terraform fmt command, default is '-recursive'] function terraform-fmt() { - for d in "${PWD}infrastructure/"*; do + for d in "${PWD}/infrastructure/"*; do if [ -d "$d" ]; then terraform fmt --recursive "${d}" fi From 0794b80b4d918c968bc4b0859026bb68c66f0cad Mon Sep 17 00:00:00 2001 From: aidenvaines-cgi Date: Tue, 10 Mar 2026 14:22:48 +0000 Subject: [PATCH 2/2] CCM-14307 Fixing Hook path for TF Lint --- scripts/terraform/terraform.lib.sh | 96 ------------------------------ 1 file changed, 96 deletions(-) delete mode 100644 scripts/terraform/terraform.lib.sh diff --git a/scripts/terraform/terraform.lib.sh b/scripts/terraform/terraform.lib.sh deleted file mode 100644 index 8a488bf..0000000 --- a/scripts/terraform/terraform.lib.sh +++ /dev/null @@ -1,96 +0,0 @@ -#!/bin/bash - -# WARNING: Please DO NOT edit this file! It is maintained in the Repository Template (https://github.com/nhs-england-tools/repository-template). Raise a PR instead. - -set -euo pipefail - -# A set of Terraform functions written in Bash. -# -# Usage: -# $ source ./terraform.lib.sh - -# ============================================================================== -# Common Terraform functions. - -# Initialise Terraform. -# Arguments (provided as environment variables): -# dir=[path to a directory where the command will be executed, relative to the project's top-level directory, default is '.'] -# opts=[options to pass to the Terraform init command, default is none/empty] -function terraform-init() { - - _terraform init # 'dir' and 'opts' are passed to the function as environment variables, if set -} - -# Plan Terraform changes. -# Arguments (provided as environment variables): -# dir=[path to a directory where the command will be executed, relative to the project's top-level directory, default is '.'] -# opts=[options to pass to the Terraform plan command, default is none/empty] -function terraform-plan() { - - _terraform plan # 'dir' and 'opts' are passed to the function as environment variables, if set -} - -# Apply Terraform changes. -# Arguments (provided as environment variables): -# dir=[path to a directory where the command will be executed, relative to the project's top-level directory, default is '.'] -# opts=[options to pass to the Terraform apply command, default is none/empty] -function terraform-apply() { - - _terraform apply # 'dir' and 'opts' are passed to the function as environment variables, if set -} - -# Destroy Terraform resources. -# Arguments (provided as environment variables): -# dir=[path to a directory where the command will be executed, relative to the project's top-level directory, default is '.'] -# opts=[options to pass to the Terraform destroy command, default is none/empty] -function terraform-destroy() { - - _terraform apply -destroy # 'dir' and 'opts' are passed to the function as environment variables, if set -} - -# Format Terraform code. -# Arguments (provided as environment variables): -# dir=[path to a directory where the command will be executed, relative to the project's top-level directory, default is '.'] -# opts=[options to pass to the Terraform fmt command, default is '-recursive'] -function terraform-fmt() { - for d in "${PWD}/infrastructure/"*; do - if [ -d "$d" ]; then - terraform fmt --recursive "${d}" - fi - done -} - -# Validate Terraform code. -# Arguments (provided as environment variables): -# dir=[path to a directory where the command will be executed, relative to the project's top-level directory, default is '.'] -# opts=[options to pass to the Terraform validate command, default is none/empty] -function terraform-validate() { - - _terraform validate # 'dir' and 'opts' are passed to the function as environment variables, if set -} - -# shellcheck disable=SC2001,SC2155 -function _terraform() { - - local dir="$(echo "${dir:-$PWD}" | sed "s#$PWD#.#")" - local cmd="-chdir=$dir $* ${opts:-}" - local project_dir="$(git rev-parse --show-toplevel)" - - cmd="$cmd" "$project_dir/scripts/terraform/terraform.sh" -} - -# Remove Terraform files. -# Arguments (provided as environment variables): -# dir=[path to a directory where the command will be executed, relative to the project's top-level directory, default is '.'] -function terraform-clean() { - - ( - cd "${dir:-$PWD}" - rm -rf \ - .terraform \ - terraform.log \ - terraform.tfplan \ - terraform.tfstate \ - terraform.tfstate.backup - ) -}