-
Notifications
You must be signed in to change notification settings - Fork 10
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
Use glide list #21
Use glide list #21
Conversation
@Fugiman Thanks a lot for your PR! Some notes:
That's good since with glide list we can now if the root repo source files are needed (not possible with glide.lock, see Masterminds/glide#314). |
Ah, excellent. I avoided that approach since it seemed like you already took the "vendor glide" approach, but I can change this PR to do that.
I believe this PR addresses that concern. It does so by keeping any legal files contained in a directory that is a parent of an imported package, or the package itself. This seems like a simpler solution than trying to determine the repository root, and would only have the side effect of including more legal files than perhaps strictly necessary, which didn't seem too bad to me? |
Yeah, I tried to import the less as possible to parse glide.lock, so perhaps with this PR also this part could be removed.
Great!
Seems good! |
I believe I've addressed your concerns, but unfortunately most of the diff is now deleting vendored code. If this is a problem I'd appreciate suggestions on how to make it more readable :) |
|
||
keep := false | ||
for _, name := range pkgList { | ||
// If the file's parent directory is a needed package, keep it. |
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 like how you refactored this part. 👍
@Fugiman I tried it and it worked well! 👍 But I noticed it'll break projects that uses the vendored dirs for keeping additional not needed packages. For example coreos/rkt puts additional vendored programs and builds them (actool, cni plugins). That's probably not a standard practice but sometimes it's needed. I can see two solutions:
@s-urbaniak thoughts?
For clearness I usually split the code changes and the vendor changes in two different commits. But the vendor changes could also become a follow up PR. Additionally there's also the need to change the |
It feels like using glide to manage tools is incorrect behavior. I previously tried to do this myself and ran into a lot of issues, and my understanding of My feeling is that glide is really good at managing dependencies for a repository and should focus on that, and another tool should manage vendoring tools. Then again, we built such a tool at my company and are working on open sourcing it, so I may be biased :) In the short term, I think the I'll move the vendor changes to a different PR and update the README |
Introducing a If glide is converging into this direction, then we will have to adapt in rkt, but I'd like to find a better solution other than @Fugiman I am not aware of |
|
@s-urbaniak (you may have seen
we haven't actually discussed this point yet, but it is listed in the number of major discussion points we need to tackle - Masterminds/glide#565. Interestingly, this topic also happens to be coming up right now in the pkg mgmt committee discussions. so, sdboyer/gps#42 will add support for designating arbitrary additional packages whose dependencies must be satisfied. idk what choice glide folks will make wrt this feature, once added - maybe you'll be able to explicitly designate a main, e.g. The potential problem is, as discussed in Masterminds/glide#418, using that system to designate additional things you want pulled in has a potentially undesirable effect: those dependencies then have to be reconciled with everything else in your actual project depgraph. This probably makes sense for something like msgp, where you want the binary to use the exact same logic to generate msgp structures as your application uses to read them, but makes very little sense for e.g. a linter, where all you really care about is reliably having the same version of that linter associated with the project. The potential for conflicts here isn't an abstract, either; it's easy to imagine annoying things happening around something like, say, logrus - some linter wants to use logrus, and so does your app. Now, you find yourself having to reconcile logrus version disagreements between your linter and your app, even though it's not harmful (in this case) to have two separate versions of logrus, because they'd never need exist in the same compiled binary. So, in sum/to recap, I think it's important to separate these two cases:
sdboyer/gps#42 will facilitate both of these together, but not the first one alone. No plan has yet been made as to how glide will interact with that feature, once converted to gps. |
@sdboyer Many thanks for the very detailed summary! 👍 You are right, inside rkt we have a "naive mono-repo" view at all dependencies right now, be it libraries, or binaries, that perspective didn't change in the transition from godep to glide, so this problem is not new at all. We were lucky not to be bitten by it. We used to have a separate metadata file, see [1], so I have no problem in re-introducing this, given there is some support for this in glide. As long as there is no idiomatic solution in glide itself I am fine on the suggestion from @sgotti for now to provide an option to fallback to [1] https://github.com/coreos/rkt/blob/8b5deb1f0cb61f15aff8e5dc2c77451c20134e30/vendoredApps |
I've added |
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.
@Fugiman Really appreciated your refactor and the additonal efftor to fallback to using glide.lock.
I've got just one little question and a doubt on the use of string.HasPrefix.
After clarifying this I think you should squash your commits and I'll merge it.
} | ||
} | ||
// Keep legal files in directories that are the parent of a needed package | ||
keep = keep || !opts.noLegalFiles && IsLegalFile(path) && strings.HasPrefix(name, lastVendorPathDir) |
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 will do a loop on filepath.Dir
instead of strings.HasPrefix
to not wrongly keep unrelated files.
For example if the pkg name is github.com/repoAAAAA/pkg
and the file path is github.com/repo/LICENSE
then lastVendorPathDir
will be github.com/repo
(no trailing slash) and strings.HasPrefix(github.com/repoAAAAA/pkg, github.com/repo)
will match keeping that file.
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.
peanut gallery: heh, this bit me so often in gps, i made a utility function for it (now largely subsumed into trie logic)
} | ||
// If a directory is a needed package then keep it | ||
keep = keep || info.IsDir() && name == lastVendorPath | ||
|
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.
just noticed than in the previous iteration you called break after setting keep to true. This avoided some unneeded looping on the other packages since the file was already marked to be kept. Did you removed this because it's not a big deal and to keep the code cleaner?
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.
Yes, I figured the comparisons were all operating on things already in memory, so there wouldn't be a huge performance hit, and I felt it made the code easier to follow. It should be pretty easy to add the breaks back if needed.
I've added I'm also personally a big fan of the "squash+merge" functionality of github, but if you prefer I squash & force-push I can do that. |
Great! LGTM!
I tried this just now but it looks strange that I'll be the one creating the squashed commit message instead of leaving this to you 😝 . What's your preferred commit message? Just the title or something more detailed? |
The old glide.lock behavior is still available via --use-lock-file. This also refactors the cleanup function to hopefully be easier to follow. Also adds more tests around getLastVendorPath and isParentDirectory.
Squashed :) |
@Fugiman Thanks a lot! Merged. |
Given that I absolutely don't care about windows, this fixes code and tests on it. PR #21 tried to set the PATH env var in an unix like way with the effect of disabling the go test execution. This patch: * Fixes PATH env to add $GOPATH/bin * Fixes isParentDirectory * Fixes TestGetLastVendorPath and TestIsParentDirectory * Handles missing error check on `glide list` execution
Given that I absolutely don't care about windows, this fixes code and tests on it. PR #21 tried to set the PATH env var in an unix like way with the effect of disabling the go test execution. This patch: * Fixes PATH env to add $GOPATH/bin * Fixes isParentDirectory * Fixes TestGetLastVendorPath and TestIsParentDirectory * Handles missing error check on `glide list` execution
Given that I absolutely don't care about windows, this fixes code and tests on it. PR #21 tried to set the PATH env var in an unix like way with the effect of disabling the go test execution without an error code. This patch: * Fixes PATH env to add $GOPATH/bin * Fixes isParentDirectory * Fixes TestGetLastVendorPath and TestIsParentDirectory * Handles missing error check on `glide list` execution
I noticed in #14 and #20 you stated that you wished to use
glide list
to determine what packages to keep rather thanglide.lock
. This is my attempt to do so.The only effect I've noticed that this has is that files in the repository root are deleted if they aren't imported, which was my goal.