Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
Make terraform-validate script executable

Initial commit
  • Loading branch information
lukiffer committed Sep 2, 2020
0 parents commit 40c0423
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
hooks:
- id: check-added-large-files
- id: check-byte-order-marker
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-json
- id: check-merge-conflict
- id: check-symlinks
- id: check-yaml
- id: detect-private-key
- id: end-of-file-fixer
- id: mixed-line-ending
args: [--fix=no]
- id: trailing-whitespace
- repo: https://github.com/gruntwork-io/pre-commit
rev: v0.0.8
hooks:
- id: shellcheck
11 changes: 11 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This configuration file allows our pre-commit hooks to be used with pre-commit: http://pre-commit.com/

- id: terraform-validate
name: Terraform validate
description: Validates all Terraform configuration files
entry: hooks/terraform-validate.sh
language: script
files: \.tf$
exclude: \.+.terraform\/.*$
require_serial: true
args: [--azurerm-provider-version=2.25.0]
3 changes: 3 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@quantum-sec/semantic-release-config/base"
}
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
© 2020 Quantum Security Pte. Ltd. All Rights Reserved.
16 changes: 16 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
trigger:
branches:
include:
- master
- feature/*
- fix/*

resources:
repositories:
- repository: pipeline-library
type: github
endpoint: quantum-sec-github
name: quantum-sec/pipeline-library

jobs:
- template: templates/jobs/default.yml@pipeline-library
34 changes: 34 additions & 0 deletions hooks/terraform-validate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

set -e

# This is a clone of https://github.com/gruntwork-io/pre-commit/blob/master/hooks/terraform-validate.sh
# It adds support for modules that use the Azure Resource Manager provider 2.0+.
# This provider requires an explicit `features` block which in most cases is supplied by a super module.
# See: https://github.com/hashicorp/terraform/pull/24896

function main() {
local azurerm_provider_version="2.25.0"

if [[ "$1" = "--azurerm-provider-version"* ]]; then
azurerm_provider_version="${1//--azurerm-provider-version=/}"
fi

for dir in $(echo "$@" | xargs -n1 dirname | sort -u | uniq); do
pushd "$dir" >/dev/null
if [ -n "$azurerm_provider_version" ]; then
cat << EOF > provider.tf
provider "azurerm" {
version = "$azurerm_provider_version"
features {}
}
EOF
fi
terraform init -backend=false
terraform validate
rm provider.tf
popd >/dev/null
done
}

main "$@"
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "@quantum-sec/pre-commit",
"version": "0.0.0-development",
"repository": {
"type": "git",
"url": "[email protected]:quantum-sec/pre-commit.git"
},
"author": "Quantum Security Pte. Ltd.",
"license": "SEE LICENSE IN LICENSE"
}

0 comments on commit 40c0423

Please sign in to comment.