mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-03 20:33:21 +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
|
, cdrtools # libvirt
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
list = lib.importJSON ./providers.json;
|
# Our generic constructor to build new providers.
|
||||||
|
#
|
||||||
buildWithGoModule = data:
|
# 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 {
|
buildGoModule {
|
||||||
pname = data.repo;
|
pname = repo;
|
||||||
inherit (data) vendorSha256 version;
|
inherit vendorSha256 version deleteVendor proxyVendor;
|
||||||
subPackages = [ "." ];
|
subPackages = [ "." ];
|
||||||
doCheck = false;
|
doCheck = false;
|
||||||
# https://github.com/hashicorp/terraform-provider-scaffolding/blob/a8ac8375a7082befe55b71c8cbb048493dd220c2/.goreleaser.yml
|
# https://github.com/hashicorp/terraform-provider-scaffolding/blob/a8ac8375a7082befe55b71c8cbb048493dd220c2/.goreleaser.yml
|
||||||
# goreleaser (used for builds distributed via terraform registry) requires that CGO is disabled
|
# goreleaser (used for builds distributed via terraform registry) requires that CGO is disabled
|
||||||
CGO_ENABLED = 0;
|
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 {
|
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
|
# Terraform allow checking the provider versions, but this breaks
|
||||||
# if the versions are not provided via file paths.
|
# if the versions are not provided via file paths.
|
||||||
postBuild = "mv $NIX_BUILD_TOP/go/bin/${data.repo}{,_v${data.version}}";
|
postBuild = "mv $NIX_BUILD_TOP/go/bin/${repo}{,_v${version}}";
|
||||||
passthru = data;
|
passthru = attrs;
|
||||||
};
|
};
|
||||||
|
|
||||||
# Our generic constructor to build new providers
|
list = lib.importJSON ./providers.json;
|
||||||
mkProvider = attrs:
|
|
||||||
(if (lib.hasAttr "vendorSha256" attrs) then buildWithGoModule else throw /* added 2022/01 */ "vendorSha256 missing: please use `buildGoModule`")
|
|
||||||
attrs;
|
|
||||||
|
|
||||||
# These providers are managed with the ./update-all script
|
# These providers are managed with the ./update-all script
|
||||||
automated-providers = lib.mapAttrs (_: attrs: mkProvider attrs) list;
|
automated-providers = lib.mapAttrs (_: attrs: mkProvider attrs) list;
|
||||||
|
Loading…
Reference in New Issue
Block a user