terraform: fmt
This commit is contained in:
parent
4b7c8d538e
commit
319537cb02
1 changed files with 68 additions and 47 deletions
|
@ -1,10 +1,21 @@
|
|||
{ stdenv, lib, buildGoModule, fetchFromGitHub, makeWrapper, coreutils
|
||||
, runCommand, runtimeShell, writeText, terraform-providers, fetchpatch }:
|
||||
{ stdenv
|
||||
, lib
|
||||
, buildGoModule
|
||||
, fetchFromGitHub
|
||||
, makeWrapper
|
||||
, coreutils
|
||||
, runCommand
|
||||
, runtimeShell
|
||||
, writeText
|
||||
, terraform-providers
|
||||
, fetchpatch
|
||||
}:
|
||||
|
||||
let
|
||||
generic = { version, sha256, vendorSha256 ? null, ... }@attrs:
|
||||
let attrs' = builtins.removeAttrs attrs [ "version" "sha256" "vendorSha256" ];
|
||||
in buildGoModule ({
|
||||
in
|
||||
buildGoModule ({
|
||||
name = "terraform-${version}";
|
||||
|
||||
inherit vendorSha256;
|
||||
|
@ -62,7 +73,9 @@ let
|
|||
actualPlugins = plugins terraform.plugins;
|
||||
|
||||
# Make providers available in Terraform 0.13 and 0.12 search paths.
|
||||
pluginDir = lib.concatMapStrings (pl: let
|
||||
pluginDir = lib.concatMapStrings
|
||||
(pl:
|
||||
let
|
||||
inherit (pl) version GOOS GOARCH;
|
||||
|
||||
pname = pl.pname or (throw "${pl.name} is missing a pname attribute");
|
||||
|
@ -76,7 +89,8 @@ let
|
|||
#!${runtimeShell}
|
||||
exec ${pl}/bin/${pname}_v${version} "$@"
|
||||
'';
|
||||
in ''
|
||||
in
|
||||
''
|
||||
TF_0_13_PROVIDER_PATH=$out/plugins/${slug}/${version}/${GOOS}_${GOARCH}/${pname}_v${version}
|
||||
mkdir -p "$(dirname $TF_0_13_PROVIDER_PATH)"
|
||||
|
||||
|
@ -88,7 +102,8 @@ let
|
|||
cp ${shim} "$TF_0_12_PROVIDER_PATH"
|
||||
chmod +x "$TF_0_12_PROVIDER_PATH"
|
||||
''
|
||||
) actualPlugins;
|
||||
)
|
||||
actualPlugins;
|
||||
|
||||
# Wrap PATH of plugins propagatedBuildInputs, plugins may have runtime dependencies on external binaries
|
||||
wrapperInputs = lib.unique (lib.flatten
|
||||
|
@ -110,7 +125,8 @@ let
|
|||
};
|
||||
# Don't bother wrapping unless we actually have plugins, since the wrapper will stop automatic downloading
|
||||
# of plugins, which might be counterintuitive if someone just wants a vanilla Terraform.
|
||||
in if actualPlugins == [ ] then
|
||||
in
|
||||
if actualPlugins == [ ] then
|
||||
terraform.overrideAttrs
|
||||
(orig: { passthru = orig.passthru // passthru; })
|
||||
else
|
||||
|
@ -127,14 +143,16 @@ let
|
|||
|
||||
inherit passthru;
|
||||
});
|
||||
in withPlugins (_: [ ]);
|
||||
in
|
||||
withPlugins (_: [ ]);
|
||||
|
||||
plugins = removeAttrs terraform-providers [
|
||||
"override"
|
||||
"overrideDerivation"
|
||||
"recurseForDerivations"
|
||||
];
|
||||
in rec {
|
||||
in
|
||||
rec {
|
||||
terraform_0_12 = pluggable (generic {
|
||||
version = "0.12.31";
|
||||
sha256 = "03p698xdbk5gj0f9v8v1fpd74zng3948dyy4f2hv7zgks9hid7fg";
|
||||
|
@ -144,7 +162,8 @@ in rec {
|
|||
name = "fix-mac-mojave-crashes.patch";
|
||||
url = "https://github.com/hashicorp/terraform/commit/cd65b28da051174a13ac76e54b7bb95d3051255c.patch";
|
||||
sha256 = "1k70kk4hli72x8gza6fy3vpckdm3sf881w61fmssrah3hgmfmbrs";
|
||||
}) ];
|
||||
})
|
||||
];
|
||||
passthru = { inherit plugins; };
|
||||
});
|
||||
|
||||
|
@ -183,7 +202,8 @@ in rec {
|
|||
# file pattern and if the plugin is not found it will try to download it
|
||||
# from the Internet. With sandboxing enable this test will fail if that is
|
||||
# the case.
|
||||
terraform_plugins_test = let
|
||||
terraform_plugins_test =
|
||||
let
|
||||
mainTf = writeText "main.tf" ''
|
||||
resource "random_id" "test" {}
|
||||
'';
|
||||
|
@ -197,6 +217,7 @@ in rec {
|
|||
terraform init
|
||||
touch $out
|
||||
'';
|
||||
in test;
|
||||
in
|
||||
test;
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue