Skip to content
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

bump terraform providers #83279

Merged
merged 3 commits into from Apr 2, 2020
Merged

Conversation

flokli
Copy link
Contributor

@flokli flokli commented Mar 24, 2020

Motivation for this change

This updates the terraform provider update script (thanks @zimbatm for helping out here), and updates all providers.

I haven't finished rebuilding all providers yet.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@flokli
Copy link
Contributor Author

flokli commented Mar 24, 2020

terraform-providers.google and terraform-providers.google-beta fail to build:

❯ nix-build -A terraform-providers.google
these derivations will be built:
  /nix/store/ml84kwg898dfy9909cpnz5h428651d8q-terraform-provider-google-3.14.0.drv
building '/nix/store/ml84kwg898dfy9909cpnz5h428651d8q-terraform-provider-google-3.14.0.drv'...
unpacking sources
unpacking source archive /nix/store/jjxmsxl0haxj77xf2jd78cxwpaqp211i-source
source root is source
patching sources
configuring
building
go/src/github.com/terraform-providers/terraform-provider-google/google/config.go:51:2: code in directory /build/go/src/github.com/terraform-providers/terraform-provider-google/vendor/google.golang.org/api/sqladmin/v1beta4 expects import "google.golang.org/api/sql/v1beta4"
builder for '/nix/store/ml84kwg898dfy9909cpnz5h428651d8q-terraform-provider-google-3.14.0.drv' failed with exit code 1
error: build of '/nix/store/ml84kwg898dfy9909cpnz5h428651d8q-terraform-provider-google-3.14.0.drv' failed
❯ nix-build -A terraform-providers.google-beta
these derivations will be built:
  /nix/store/1l01hi54y4glw11hi9yb756ijkx4j8v0-terraform-provider-google-beta-3.14.0.drv
building '/nix/store/1l01hi54y4glw11hi9yb756ijkx4j8v0-terraform-provider-google-beta-3.14.0.drv'...
unpacking sources
unpacking source archive /nix/store/dij55sqlwxrpr98ak99w6vnw6m373qif-source
source root is source
patching sources
configuring
building
go/src/github.com/terraform-providers/terraform-provider-google-beta/google-beta/config.go:52:2: code in directory /build/go/src/github.com/terraform-providers/terraform-provider-google-beta/vendor/google.golang.org/api/sqladmin/v1beta4 expects import "google.golang.org/api/sql/v1beta4"
builder for '/nix/store/1l01hi54y4glw11hi9yb756ijkx4j8v0-terraform-provider-google-beta-3.14.0.drv' failed with exit code 1
error: build of '/nix/store/1l01hi54y4glw11hi9yb756ijkx4j8v0-terraform-provider-google-beta-3.14.0.drv' failed

There seems to be something wrong with the vendored libraries I guess?

@flokli
Copy link
Contributor Author

flokli commented Mar 24, 2020

When checking out and building the provider manually, there seems to be some differing behaviour:

$ GO111MODULE=off go build
google/config.go:51:2: code in directory /home/zimbatm/go/src/github.com/terraform-providers/terraform-provider-google/vendor/google.golang.org/api/sqladmin/v1beta4 expects import "google.golang.org/api/sql/v1beta4"

(fails)

$ GO111MODULE=on go build -mod=vendor                                                                                       

(succeeds)

@flokli
Copy link
Contributor Author

flokli commented Mar 26, 2020

I opened a support ticket at GitHub about the fact that some repositories are missing from the API:

to reproduce, look for terraform-provider-{dns,external,template} in

hub api --paginate https://api.github.com/orgs/terraform-providers/repos | jq | vim -

Or if you want to go fancy, GraphQL:

$ hub api --paginate graphql -f query='
  query($endCursor: String) {
    repositoryOwner(login: "terraform-providers") {
      repositories(first: 100, after: $endCursor) {
        nodes {
          nameWithOwner
          name
          refs(first: 1, refPrefix: "refs/tags/", orderBy: {field: TAG_COMMIT_DATE, direction: DESC}) {
            nodes {
              name                                                                                                                                                                                                                                 
            }                                                                                                                                                                                                                                      
          }                                                                                                                                                                                                                                        
        }                                                                                                                                                                                                                                          
        pageInfo {                                                                                                                                                                                                                                 
          hasNextPage                                                                                                                                                                                                                              
          endCursor                                                                                                                                                                                                                                
        }                                                                                                                                                                                                                                          
      }                                                                                                                                                                                                                                            
    }                                                                                                                                                                                                                                              
  }                                                                                                                                                                                                                                                
' | jq | vim -

@flokli
Copy link
Contributor Author

flokli commented Mar 26, 2020

Alright, already heard back. That was quick! :-)

Turns out, these repos have been moved to the hashicorp organization, and we were fooled by the redirect - so we might want to look at the hashicorp organization too, and filter for terraform-provider-* repos to include these…

@flokli
Copy link
Contributor Author

flokli commented Mar 30, 2020

I pushed a new version, that uses hub, the GraphQL endpoint, and fetches from both hashicorp and terraform-providers.

This required some refactoring, but now we should have back all terraform providers and not run into GitHubs ratelimiting, as we're not generating a HTTP request for each provider.

PTAL.

@flokli flokli force-pushed the bump-terraform-providers branch 2 times, most recently from 6a1550f to 3123e88 Compare March 30, 2020 10:53
@flokli
Copy link
Contributor Author

flokli commented Mar 31, 2020

I bumped the terraform providers once more, now including the fix for hashicorp/terraform-provider-google#5970.

@flokli flokli requested a review from zimbatm March 31, 2020 14:02
@flokli
Copy link
Contributor Author

flokli commented Apr 2, 2020

Some providers that were moved to the hashicorp organization still have references to the terraform-providers organization, which needs patching. Working on this now.

flokli and others added 2 commits April 2, 2020 17:53
Some terraform providers were moved to the `hashicorp` organization,
some are still in the `terraform-providers` organization.

GitHub doesn't show moved repositories when querying via the API (only
on the web interface). In addition, if there are more than 100 results
(there still are), we'd need to implement paging, which is cubersome in curl.

In addition to that, to look up tags, we used to creating a HTTP request
for each and every provider, which caused us to easily get blocked by
GitHubs rate-limiting.

Instead of all that, let's use `hub` (which implements paging) and the
GitHub's GraphQL endpoint to get a list all repositories for a given
organization AND the latest tag for each of them.

We post-process the output with `jq`.

This also removes the providers.txt and folds the data into the script.
The blacklist was becoming too annoying to handle as a config file.

For the whitelist, we still need to individually fetch tags.

Fixes NixOS#83215

Co-Authored-By: zimbatm <zimbatm@zimbatm.com>
@flokli
Copy link
Contributor Author

flokli commented Apr 2, 2020

@GrahamcOfBorg build terraform-full terraform_0_11-full

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants