mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-02 20:03:16 +00:00
terraform-providers.mkProvider: cleanup
Remove the layer of indirection. Expose what parameters are expected from the function call.
This commit is contained in:
parent
689155195f
commit
f3fa6bfe96
@ -7,34 +7,40 @@
|
||||
, cdrtools # libvirt
|
||||
}:
|
||||
let
|
||||
list = lib.importJSON ./providers.json;
|
||||
|
||||
buildWithGoModule = data:
|
||||
# Our generic constructor to build new providers.
|
||||
#
|
||||
# Is designed to combine with the terraform.withPlugins implementation.
|
||||
mkProvider =
|
||||
{ owner
|
||||
, repo
|
||||
, rev
|
||||
, version
|
||||
, sha256
|
||||
, vendorSha256 ? throw "vendorSha256 missing: please use `buildGoModule`" /* added 2022/01 */
|
||||
, deleteVendor ? false
|
||||
, proxyVendor ? false
|
||||
, provider-source-address
|
||||
}@attrs:
|
||||
buildGoModule {
|
||||
pname = data.repo;
|
||||
inherit (data) vendorSha256 version;
|
||||
pname = repo;
|
||||
inherit vendorSha256 version deleteVendor proxyVendor;
|
||||
subPackages = [ "." ];
|
||||
doCheck = false;
|
||||
# https://github.com/hashicorp/terraform-provider-scaffolding/blob/a8ac8375a7082befe55b71c8cbb048493dd220c2/.goreleaser.yml
|
||||
# goreleaser (used for builds distributed via terraform registry) requires that CGO is disabled
|
||||
CGO_ENABLED = 0;
|
||||
ldflags = [ "-s" "-w" "-X main.version=${data.version}" "-X main.commit=${data.rev}" ];
|
||||
ldflags = [ "-s" "-w" "-X main.version=${version}" "-X main.commit=${rev}" ];
|
||||
src = fetchFromGitHub {
|
||||
inherit (data) owner repo rev sha256;
|
||||
inherit owner repo rev sha256;
|
||||
};
|
||||
deleteVendor = data.deleteVendor or false;
|
||||
proxyVendor = data.proxyVendor or false;
|
||||
|
||||
# Terraform allow checking the provider versions, but this breaks
|
||||
# if the versions are not provided via file paths.
|
||||
postBuild = "mv $NIX_BUILD_TOP/go/bin/${data.repo}{,_v${data.version}}";
|
||||
passthru = data;
|
||||
postBuild = "mv $NIX_BUILD_TOP/go/bin/${repo}{,_v${version}}";
|
||||
passthru = attrs;
|
||||
};
|
||||
|
||||
# Our generic constructor to build new providers
|
||||
mkProvider = attrs:
|
||||
(if (lib.hasAttr "vendorSha256" attrs) then buildWithGoModule else throw /* added 2022/01 */ "vendorSha256 missing: please use `buildGoModule`")
|
||||
attrs;
|
||||
list = lib.importJSON ./providers.json;
|
||||
|
||||
# These providers are managed with the ./update-all script
|
||||
automated-providers = lib.mapAttrs (_: attrs: mkProvider attrs) list;
|
||||
|
Loading…
Reference in New Issue
Block a user