-
-
Notifications
You must be signed in to change notification settings - Fork 15.5k
terraform-providers: build automated providers with Go module #103822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
terraform-providers: build automated providers with Go module #103822
Conversation
ee45748
to
2fb7726
Compare
✔️ Successful provider initialization with
# main.tf
terraform {
required_providers {
ibm = {
source = "IBM-Cloud/ibm"
}
digitalocean = {
source = "digitalocean/digitalocean"
}
}
}
provider "aws" {}
provider "dns" {}
provider "random" {}
provider "null" {}
provider "tls" {}
provider "template" {}
provider "local" {}
provider "http" {}
provider "archive" {}
provider "external" {}
provider "google" {}
provider "google-beta" {}
provider "digitalocean" {}
provider "ibm" {}
provider "helm" {} $ nix-shell -I nixpkgs=$PWD -p 'terraform_0_13.withPlugins (p : with p; [aws dns random tls template local http archive external google google-beta digitalocean ibm helm] ++ [p.null])'
$ terraform init
Initializing the backend...
Initializing provider plugins...
- Finding latest version of hashicorp/external...
- Finding latest version of hashicorp/local...
- Finding latest version of ibm-cloud/ibm...
- Finding latest version of hashicorp/aws...
- Finding latest version of hashicorp/http...
- Finding latest version of hashicorp/null...
- Finding latest version of digitalocean/digitalocean...
- Finding latest version of hashicorp/tls...
- Finding latest version of hashicorp/archive...
- Finding latest version of hashicorp/random...
- Finding latest version of hashicorp/dns...
- Finding latest version of hashicorp/google-beta...
- Finding latest version of hashicorp/helm...
- Finding latest version of hashicorp/template...
- Finding latest version of hashicorp/google...
- Installing digitalocean/digitalocean v2.2.0...
- Installed digitalocean/digitalocean v2.2.0 (unauthenticated)
- Installing hashicorp/local v2.0.0...
- Installed hashicorp/local v2.0.0 (unauthenticated)
- Installing hashicorp/aws v3.15.0...
- Installed hashicorp/aws v3.15.0 (unauthenticated)
- Installing hashicorp/random v3.0.0...
- Installed hashicorp/random v3.0.0 (unauthenticated)
- Installing hashicorp/http v2.0.0...
- Installed hashicorp/http v2.0.0 (unauthenticated)
- Installing hashicorp/archive v2.0.0...
- Installed hashicorp/archive v2.0.0 (unauthenticated)
- Installing hashicorp/dns v3.0.0...
- Installed hashicorp/dns v3.0.0 (unauthenticated)
- Installing hashicorp/template v2.2.0...
- Installed hashicorp/template v2.2.0 (unauthenticated)
- Installing hashicorp/google v3.47.0...
- Installed hashicorp/google v3.47.0 (unauthenticated)
- Installing ibm-cloud/ibm v1.14.0...
- Installed ibm-cloud/ibm v1.14.0 (unauthenticated)
- Installing hashicorp/tls v3.0.0...
- Installed hashicorp/tls v3.0.0 (unauthenticated)
- Installing hashicorp/google-beta v3.47.0...
- Installed hashicorp/google-beta v3.47.0 (unauthenticated)
- Installing hashicorp/helm v1.3.2...
- Installed hashicorp/helm v1.3.2 (unauthenticated)
- Installing hashicorp/external v2.0.0...
- Installed hashicorp/external v2.0.0 (unauthenticated)
- Installing hashicorp/null v3.0.0...
- Installed hashicorp/null v3.0.0 (unauthenticated)
The following providers do not have any version constraints in configuration,
so the latest version was installed.
To prevent automatic upgrades to new major versions that may contain breaking
changes, we recommend adding version constraints in a required_providers block
in your configuration, with the constraint strings suggested below.
* digitalocean/digitalocean: version = "~> 2.2.0"
* hashicorp/archive: version = "~> 2.0.0"
* hashicorp/aws: version = "~> 3.15.0"
* hashicorp/dns: version = "~> 3.0.0"
* hashicorp/external: version = "~> 2.0.0"
* hashicorp/google: version = "~> 3.47.0"
* hashicorp/google-beta: version = "~> 3.47.0"
* hashicorp/helm: version = "~> 1.3.2"
* hashicorp/http: version = "~> 2.0.0"
* hashicorp/local: version = "~> 2.0.0"
* hashicorp/null: version = "~> 3.0.0"
* hashicorp/random: version = "~> 3.0.0"
* hashicorp/template: version = "~> 2.2.0"
* hashicorp/tls: version = "~> 3.0.0"
* ibm-cloud/ibm: version = "~> 1.14.0"
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
although, these seem to build fine
https://github.com/NixOS/nixpkgs/pull/103822
19 packages built:
terraform-full terraform-providers.archive terraform-providers.aws terraform-providers.digitalocean terraform-providers.dns terraform-providers.external terraform-providers.google terraform-providers.google-beta terraform-providers.helm terraform-providers.http terraform-providers.ibm terraform-providers.local terraform-providers.null terraform-providers.random terraform-providers.template terraform-providers.tls terraform_0_11-full terraform_plugins_test terragrunt
(if attrs ? vendorSha256 then buildWithGoModule else buildWithGoPackage) | ||
name attrs) list; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is right. shouldn't it be:
(if attrs ? vendorSha256 then buildWithGoModule else buildWithGoPackage) | |
name attrs) list; | |
(if (lib.hasAttr "vendorSha256" attrs) then buildWithGoModule else buildWithGoPackage) | |
name attrs) list; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is some legit nix (source) 😉
More than happy to use the lib.hasAttr
function instead of the ?
operator if that is the preferred way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, well it seemed to have the expected behavior, but I think lib.hasAttr
is more readable. and isn't contextual like ?
which can also be used to provide a default value when inside an attrset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, the function is the least ambiguous of the two. Fixed it now.
2fb7726
to
16e5e12
Compare
@@ -7,7 +8,23 @@ | |||
let | |||
list = lib.importJSON ./providers.json; | |||
|
|||
toDrv = name: data: | |||
buildWithGoModule = name: data: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name
is not used. Am I missing something? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent spot, fixed in both buildWithGoModule
and buildWithGoPackage
🙇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kalbasit would you be able to give this a once over. I've address all outstanding comments 🙇
16e5e12
to
0c76f11
Compare
0c76f11
to
61ebe1f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but I'll defer to @kalbasit on go packaging
https://github.com/NixOS/nixpkgs/pull/103822
19 packages built:
terraform-full terraform-providers.archive terraform-providers.aws terraform-providers.digitalocean terraform-providers.dns terraform-providers.external terraform-providers.google terraform-providers.google-beta terraform-providers.helm terraform-providers.http terraform-providers.ibm terraform-providers.local terraform-providers.null terraform-providers.random terraform-providers.template terraform-providers.tls terraform_0_11-full terraform_plugins_test terragrunt
"version": "2.65.0" | ||
"rev": "v3.15.0", | ||
"sha256": "0rxpdxg5p478sipbhq2x347gs5wrlwz4ggy9z007cbp34yhb2wka", | ||
"vendorSha256": "0vapfnd4c8jb15pdjnnb97vgsvfakjvl1czccbfy0znhdk2ynz02", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would one update this? Shouldn't the update-provider script be updated to take care of that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, that is the intention, I have a PR that needs a little more work #104696.
The aim is to hook it up to updateScript
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allright then, I think this PR is good to go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Result of nixpkgs-review pr 103822 1
19 packages built:
- terraform-full
- terraform-providers.archive
- terraform-providers.aws
- terraform-providers.digitalocean
- terraform-providers.dns
- terraform-providers.external
- terraform-providers.google
- terraform-providers.google-beta
- terraform-providers.helm
- terraform-providers.http
- terraform-providers.ibm
- terraform-providers.local
- terraform-providers.null
- terraform-providers.random
- terraform-providers.template
- terraform-providers.tls
- terraform_0_11-full
- terraform_plugins_test
- terragrunt
Oof, not sure if this should have been merged, given the |
We should really try to get a full updater story into nixpkgs. |
Motivation for this change
With more providers adopting Go module, nixpkgs needs to follow suit. This work adds a
vendorSha256
key to providers that use Go module. When the key is present the provider will be built with Go module, else with Go package.The
update-provider
script has been updated to handlevendorSha256
and will be made available in a subsequent PR.Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)