Skip to content

Commit

Permalink
terraform: add plugins tests (#47861)
Browse files Browse the repository at this point in the history
I wasn't sure if the plugins were downloaded from the Internet or not.
This makes sure that there is no regression in the plugin detection.
  • Loading branch information
zimbatm committed Oct 4, 2018
1 parent bc46aa9 commit d4ff6ca
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions pkgs/applications/networking/cluster/terraform/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
, buildGoPackage
, fetchFromGitHub
, makeWrapper
, runCommand
, writeText
, terraform-providers
}:

Expand Down Expand Up @@ -118,4 +120,25 @@ in rec {
});

terraform_0_11-full = terraform_0_11.withPlugins lib.attrValues;

# Tests that the plugins are being used. Terraform looks at the specific
# 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
mainTf = writeText "main.tf" ''
resource "random_id" "test" {}
'';
terraform = terraform_0_11.withPlugins (p: [ p.random ]);
test = runCommand "terraform-plugin-test" { buildInputs = [terraform]; }
''
set -e
# make it fail outside of sandbox
export HTTP_PROXY=http://127.0.0.1:0 HTTPS_PROXY=https://127.0.0.1:0
cp ${mainTf} main.tf
terraform init
touch $out
'';
in test;

}
1 change: 1 addition & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22162,6 +22162,7 @@ with pkgs;
terraform_0_10-full
terraform_0_11
terraform_0_11-full
terraform_plugins_test
;

terraform = terraform_0_11;
Expand Down

0 comments on commit d4ff6ca

Please sign in to comment.