terraform-providers: support providers with Go module
This commit is contained in:
parent
4f165c6d7d
commit
31589fe918
|
@ -1,4 +1,5 @@
|
||||||
{ lib
|
{ lib
|
||||||
|
, buildGoModule
|
||||||
, buildGoPackage
|
, buildGoPackage
|
||||||
, fetchFromGitHub
|
, fetchFromGitHub
|
||||||
, callPackage
|
, callPackage
|
||||||
|
@ -7,7 +8,23 @@
|
||||||
let
|
let
|
||||||
list = lib.importJSON ./providers.json;
|
list = lib.importJSON ./providers.json;
|
||||||
|
|
||||||
toDrv = name: data:
|
buildWithGoModule = data:
|
||||||
|
buildGoModule {
|
||||||
|
pname = data.repo;
|
||||||
|
version = data.version;
|
||||||
|
subPackages = [ "." ];
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
inherit (data) owner repo rev sha256;
|
||||||
|
};
|
||||||
|
vendorSha256 = data.vendorSha256 or null;
|
||||||
|
|
||||||
|
# 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;
|
||||||
|
};
|
||||||
|
|
||||||
|
buildWithGoPackage = data:
|
||||||
buildGoPackage {
|
buildGoPackage {
|
||||||
pname = data.repo;
|
pname = data.repo;
|
||||||
version = data.version;
|
version = data.version;
|
||||||
|
@ -50,7 +67,9 @@ let
|
||||||
});
|
});
|
||||||
|
|
||||||
# These providers are managed with the ./update-all script
|
# These providers are managed with the ./update-all script
|
||||||
automated-providers = lib.mapAttrs (toDrv) list;
|
automated-providers = lib.mapAttrs (_: attrs:
|
||||||
|
(if (lib.hasAttr "vendorSha256" attrs) then buildWithGoModule else buildWithGoPackage)
|
||||||
|
attrs) list;
|
||||||
|
|
||||||
# These are the providers that don't fall in line with the default model
|
# These are the providers that don't fall in line with the default model
|
||||||
special-providers = {
|
special-providers = {
|
||||||
|
|
Loading…
Reference in New Issue