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

add silent mode #2

Closed
wants to merge 1 commit into from
Closed

add silent mode #2

wants to merge 1 commit into from

Conversation

phinze
Copy link

@phinze phinze commented Jan 30, 2015

👋 Cool little tool you've got here!

I'm trying it out to solve a problem we're seeing over in hashicorp/terraform#901, but I had to add this feature to make it do what we needed.

For now we can point to my fork, but let me know if you're interested in pulling this in. 👍


support -s flag for silent mode, which continues to process even when a
dependency is not found locally

useful for using deplist to build a list of potentially missing
dependencies suitable for shoving into go get.

support -s flag for silent mode, which continues to process even when a
dependency is not found locally

useful for using deplist to build a list of potentially missing
dependencies suitable for shoving into `go get`.
@cespare
Copy link
Owner

cespare commented Jan 30, 2015

Interesting. The only problem I have which this is that what you get back depends on what's currently loaded on your machine. If you only depend on one package, but that has 100 transitive dependences, then whether you get 1 or 101 results from deplist depends on whether you have that package available.

I feel like what you actually want is a way to force maxdepth = 1 (maybe -recursive=false). Would that cover your needs? I think that is actually the list of things you want to go get in terraform.

@phinze
Copy link
Author

phinze commented Jan 30, 2015

@cespare Thanks for the response! I'm still trying to fully grok the details of how go get walks dependencies. Maybe you can help me out.

I thought that "what you get back depends on what's currently loaded on your machine" was necessary in order to properly feed a list of packages into go get, but maybe just a top level list is sufficient and go get will walk the transitive dependencies properly?

My worry was the case where a direct dependency updates one of it's transitive dependencies. But maybe go get handles all that for me?

@cespare
Copy link
Owner

cespare commented Jan 30, 2015

go get fetches all transitive dependencies. Typically something like deplist isn't required, because you can just do go get github.com/my/pkg and it will go out and fetch everything you need.

From glancing at the terraform issue, it seems like you guys are doing something special/fancy with your dependencies.

In any case, I don't see how the list you get with deplist -s is useful, because it includes some, but not all, transitive dependencies, depending on what packages are available locally. So I'm pretty sure you either want to fetch all the packages and run deplist, or else you only want the first-order dependencies (which we could do with deplist -recur=false).

@cespare
Copy link
Owner

cespare commented Jan 30, 2015

I looked at your Makefile more closely. I understand what's happening now. You basically just want go get, except that you don't want to update git in the current repo (but you apparently do want to update all deps to latest). In that case, I think my -recur=false suggestion is what you want.

(You should also consider using godep or similar for such a project, to lock dependency versions, so that you get more reproducible builds.)

@phinze
Copy link
Author

phinze commented Jan 30, 2015

@cespare so our problem was with travis builds was that go get was not respecting the branch on which the build was running - forcing travis to check out master every time. that's the thing we're trying to solve. i guess if go get resolves transitive dependencies, all i need is go list | grep -v terraform | go get. will play with that.

@cespare
Copy link
Owner

cespare commented Jan 30, 2015

go get doesn't balk on stdlib packages, so yes, that should work.

@phinze
Copy link
Author

phinze commented Jan 31, 2015

Cool, after some fiddling, this seems to do what I need:

go list ./... | xargs go list -f '{{join .Deps "\n"}}' | sort -u | grep -v github.com/hashicorp/terraform/ | xargs go get -f -u -v

Thanks for the help!

@phinze phinze closed this Jan 31, 2015
phinze added a commit to hashicorp/terraform that referenced this pull request Jan 31, 2015
After discussing with the very gracious @cespare over at
cespare/deplist#2 I now understand that we can
pull off the same logic with just `go list`.

The logic is now simpler and more consistent:

 * List out all packages in our repo
 * For each of those packages, list their dependencies
 * Filter out any dependencies that already live in this repo
 * Remove duplicates
 * And fetch the rest. `go get` will work out all transitive dependencies
   from there
@cespare
Copy link
Owner

cespare commented Jan 31, 2015

Glad I could help :)

yahyapo pushed a commit to yahyapo/terraform that referenced this pull request Mar 13, 2015
After discussing with the very gracious @cespare over at
cespare/deplist#2 I now understand that we can
pull off the same logic with just `go list`.

The logic is now simpler and more consistent:

 * List out all packages in our repo
 * For each of those packages, list their dependencies
 * Filter out any dependencies that already live in this repo
 * Remove duplicates
 * And fetch the rest. `go get` will work out all transitive dependencies
   from there
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.

2 participants