Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
11 changed files
with
255 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ __nixpkgs__ | ||
, makeScript | ||
, makeTerraformEnvironment | ||
, ... | ||
}: | ||
{ config | ||
, name | ||
, version | ||
, src | ||
, ... | ||
}: | ||
makeScript { | ||
entrypoint = ./entrypoint.sh; | ||
replace = { | ||
__argConfig__ = config; | ||
__argSrc__ = src; | ||
}; | ||
name = "lint-terraform-for-${name}"; | ||
searchPaths = { | ||
bin = [ | ||
__nixpkgs__.tflint | ||
]; | ||
source = [ | ||
(makeTerraformEnvironment { | ||
inherit version; | ||
}) | ||
]; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# shellcheck shell=bash | ||
|
||
function main { | ||
cd "$(mktemp -d)" \ | ||
&& copy '__argSrc__' . \ | ||
&& info Initializing '__argSrc__' \ | ||
&& terraform init \ | ||
&& info Linting '__argSrc__' \ | ||
&& tflint -c '__argConfig__' . | ||
} | ||
|
||
main "${@}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# shellcheck shell=bash | ||
|
||
function main { | ||
local pip=(python -m pip --cache-dir .) | ||
|
||
info Creating virtualenv \ | ||
&& python -m venv "${out}" \ | ||
&& info Activating virtualenv \ | ||
&& source "${out}/bin/activate" \ | ||
&& info Installing \ | ||
&& HOME=. "${pip[@]}" install --requirement "${envRequirementsFile}" \ | ||
&& info Freezing \ | ||
&& HOME=. "${pip[@]}" freeze | sort --ignore-case > "${out}/installed" \ | ||
&& sed -E 's|^(.*)\[.*?\](.*)$|\1\2|g' "${envRequirementsFile}" > "${out}/desired" \ | ||
&& if test "$(cat "${out}/desired")" = "$(cat "${out}/installed")"; then | ||
info Integrity check passed | ||
else | ||
info Integrity check failed \ | ||
&& info You need to specify all dependencies: \ | ||
&& git --no-pager diff --no-index "${out}/desired" "${out}/installed" \ | ||
&& error Stopping due to failed integrity check | ||
fi \ | ||
&& rm -f "${out}/desired" \ | ||
&& rm -f "${out}/installed" | ||
} | ||
|
||
main "${@}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ __nixpkgs__ | ||
, makeSearchPaths | ||
, ... | ||
}: | ||
{ version | ||
}: | ||
let | ||
terraform = { | ||
"0.12" = __nixpkgs__.terraform_0_12; | ||
"0.13" = __nixpkgs__.terraform_0_13; | ||
"0.14" = __nixpkgs__.terraform_0_14; | ||
"0.15" = __nixpkgs__.terraform_0_15; | ||
"0.16" = __nixpkgs__.terraform_0_16; | ||
}.${version}; | ||
in | ||
makeSearchPaths { | ||
bin = [ terraform ]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
src/evaluator/modules/outputs/builtins/lint-terraform/default.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
{ __nixpkgs__ | ||
, lintTerraform | ||
, path | ||
, ... | ||
}: | ||
{ config | ||
, lib | ||
, ... | ||
}: | ||
let | ||
makeModule = name: { src, version }: { | ||
name = "/lintTerraform/${name}"; | ||
value = lintTerraform { | ||
config = builtins.toFile "tflint.hcl" config.lintTerraform.config; | ||
inherit name; | ||
src = path src; | ||
inherit version; | ||
}; | ||
}; | ||
in | ||
{ | ||
options = { | ||
lintTerraform = { | ||
enable = lib.mkOption { | ||
default = false; | ||
type = lib.types.bool; | ||
}; | ||
config = lib.mkOption { | ||
default = '' | ||
config { | ||
module = true | ||
} | ||
plugin "aws" { | ||
enabled = true | ||
} | ||
''; | ||
type = lib.types.lines; | ||
}; | ||
modules = lib.mkOption { | ||
default = { }; | ||
type = lib.types.attrsOf (lib.types.submodule (_: { | ||
options = { | ||
src = lib.mkOption { | ||
type = lib.types.str; | ||
}; | ||
version = lib.mkOption { | ||
type = lib.types.enum [ | ||
"0.12" | ||
"0.13" | ||
"0.14" | ||
"0.15" | ||
"0.16" | ||
]; | ||
}; | ||
}; | ||
})); | ||
}; | ||
}; | ||
}; | ||
config = { | ||
outputs = lib.mkIf config.lintTerraform.enable | ||
(builtins.foldl' | ||
(all: one: all // { "${one.name}" = one.value; }) | ||
{ } | ||
(lib.attrsets.mapAttrsToList | ||
makeModule | ||
config.lintTerraform.modules)); | ||
}; | ||
} |
Empty file.