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

terraform: revamp the providers list #29097

Merged
merged 1 commit into from Sep 8, 2017
Merged

terraform: revamp the providers list #29097

merged 1 commit into from Sep 8, 2017

Conversation

zimbatm
Copy link
Member

@zimbatm zimbatm commented Sep 8, 2017

Motivation for this change

The updater script wasn't downloading all the providers. It now uses the
github auth to work around API rate-limits.

Switch back to using derivations as the data-only approach wasn't saving
much space. By using folders it allows to interrupt the updater script
and still get a valid plugin set.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • 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 nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

dirs = lib.filterAttrs (k: v: v == "directory") files;
importDir = dir: _: { name = builtins.baseNameOf dir; value = importer (path + "/${dir}"); };
in
lib.mapAttrs' importDir dirs;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copumpkin what do you think of this method of importing a bunch of derivations? the importer could also be a callPackage

@copumpkin
Copy link
Member

copumpkin commented Sep 8, 2017

My reasoning for wanting data vs. derivations wasn't about space, as much as "implied space of variation". Having a file checked into source control with a comment at the top saying "this might look like a normal source file you can change, but it isn't, so please don't modify it; instead modify the thing that generated it" is a maintenance liability. I realize we do a lot of that and this is just another straw on the camel's back, but for example I now need to be aware of that sort of thing if I apply any broad refactoring to the repo. As a really simple example, if I rename buildGoPackage, I might think "oh, I'll use sed to automatically change every instance of buildGoPackage in .nix files to the new name". Indeed, with the current setup, that will work, for now, and I won't notice that I ran afoul of the little comment at the top of the file telling me not to change it. All will be well until someone goes and regenerates the file and produces a bogus nix file expecting buildGoPackage. Obviously this example would be a quick fix but autogenerated code (vs. data) is tricky like this and I'd rather stay away from it.

So tl;dr: I have knee-jerk reactions to all autogenerated code, especially when in a source repo, and especially when the language is capable of expressing the sort of factoring that's being autogenerated natively. So I'd have way less issues generating assembly (hah) or a language like tcsh than I do with something like Haskell or Nix.

Having said all that, I won't fight on this PR you if you think this is more maintainable, but I don't personally like it 😄 It seems like the folder-valid-interruption concern would still be addressed by putting data expressions in each folder rather than code. But I'm also not sure I get why you want it to be interruptible; I'd probably want to rerun the updater if it failed mid-run, or I'd end up with a set of half-updated plugins, right? When would I ever want to say "oh, it crashed, looks good, I guess I'll do something else"? Or am I misunderstanding?

@zimbatm
Copy link
Member Author

zimbatm commented Sep 8, 2017

Thanks, that kind of comment is exactly why I asked a review from you.

The premise was that it's easy to hit the github rate-limit, so I wanted a resumable way of doing things. Since I was generating separated files, that's where I came up with the importDirs method, which I think it quite nice (on a more general note) to avoid having to build and maintain indices unnecessarily.

That being said, I solved the issue later on by introducing the personal github token to the fetching method so I will revert to the old ways of doing this.

This fixes the ./update-all script to actually fetch all the available
providers (thanks pagination). It was also improver to user a more
compact representation of the data.
@zimbatm zimbatm merged commit 9f2ff1d into master Sep 8, 2017
@copumpkin
Copy link
Member

thank you ❤️

@zimbatm zimbatm deleted the terraform-plugins-all branch September 8, 2017 20:16
fpletz pushed a commit that referenced this pull request Oct 3, 2017
This fixes the ./update-all script to actually fetch all the available
providers (thanks pagination). It was also improver to user a more
compact representation of the data.

(cherry picked from commit 9f2ff1d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants