Commit dfcaa1dc authored by Mathieu Germain's avatar Mathieu Germain Committed by Pierre Smeyers
Browse files

feat: add support for extra APK args

parent ff823205
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -378,6 +378,7 @@ The Terraform template uses some global configuration used throughout all jobs.
| `workspace` / `TF_WORKSPACE` | Default Terraform project [workspace](https://developer.hashicorp.com/terraform/language/state/workspaces) | _none_ (do not use workspaces) |
| `apply-opts` / `TF_APPLY_OPTS` | Default Terraform extra [apply options](https://developer.hashicorp.com/terraform/cli/commands/apply) | _none_ |
| `destroy-opts` / `TF_DESTROY_OPTS` | Default Terraform extra [destroy options](https://developer.hashicorp.com/terraform/cli/commands/destroy) | _none_ |
| `apk-extra-opts` / `TF_APK_EXTRA_OPTS` | Extra [ `apk add` options](https://www.mankier.com/8/apk) (`apk` is used to install `jq` and/or `curl` if necessary) | _none_ |

### Review environments configuration

+5 −0
Original line number Diff line number Diff line
@@ -64,6 +64,11 @@
      "name": "TF_DESTROY_OPTS",
      "description": "Default Terraform extra [destroy options](https://developer.hashicorp.com/terraform/cli/commands/destroy)",
      "advanced": true
    },
    {
      "name": "TF_APK_EXTRA_OPTS",
      "description": "Extra [ `apk add` options](https://www.mankier.com/8/apk) (`apk` is used to install `jq` and/or `curl` if necessary)",
      "advanced": true
    }
  ],
  "features": [
+8 −2
Original line number Diff line number Diff line
@@ -52,6 +52,9 @@ spec:
    destroy-opts:
      description: Default Terraform extra [destroy options](https://developer.hashicorp.com/terraform/cli/commands/destroy)
      default: ''
    apk-extra-opts:
      description: Extra [ `apk add` options](https://www.mankier.com/8/apk)
      default: ''
    tfsec-enabled:
      description: Enable tfsec
      type: boolean
@@ -318,6 +321,7 @@ variables:
  TF_TRIVY_ARGS: $[[ inputs.trivy-args ]]
  TF_TFLINT_IMAGE: $[[ inputs.tflint-image ]]
  TF_TFLINT_ARGS: $[[ inputs.tflint-args ]]
  TF_APK_EXTRA_OPTS: $[[ inputs.apk-extra-opts ]]
  TF_CHECKOV_IMAGE: $[[ inputs.checkov-image ]]
  TF_CHECKOV_ARGS: $[[ inputs.checkov-args ]]
  TF_INFRACOST_IMAGE: $[[ inputs.infracost-image ]]
@@ -847,7 +851,8 @@ stages:
    if ! command -v jq > /dev/null
    then
      log_info "--- installing jq (required to generate GitLab report)..."
      apk add --no-cache jq
      # shellcheck disable=SC2086
      apk add --no-cache ${TF_APK_EXTRA_OPTS:-$TBC_APK_EXTRA_OPTS} jq
    fi
    log_info "--- now generating GitLab report..."
    # impl inspired by GitLab Terraform template
@@ -940,7 +945,8 @@ stages:
      if ! command -v curl > /dev/null
      then
        log_info "--- installing curl (required to remove GitLab terraform state)..."
        apk add --no-cache curl
      # shellcheck disable=SC2086
      apk add --no-cache ${TF_APK_EXTRA_OPTS:-$TBC_APK_EXTRA_OPTS} curl
      fi
      curl --header "Private-Token: ${TF_PASSWORD}" --request DELETE "${TF_ADDRESS}"
    fi