-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Fix godep-save by ignoring cmd/cluster-capacity and cmd/service-catalog dirs. #14787
Fix godep-save by ignoring cmd/cluster-capacity and cmd/service-catalog dirs. #14787
Conversation
hack/godep-save.sh
Outdated
@@ -56,7 +56,13 @@ REQUIRED_BINS=( | |||
) | |||
|
|||
TMPGOPATH=`mktemp -d` | |||
trap "rm -rf $TMPGOPATH" EXIT | |||
TMPCMDREPOS=`mktemp -d` |
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.
Don't use deprecated back-tick expansions, instead:
TMPGOPATH="$( mktemp -d )"
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.
We put temporary dirs under ${BASETMPDIR}
:
TMPGOPATH="$( mktemp --directory --tmpdir="${BASETMPDIR}" )"
hack/godep-save.sh
Outdated
trap "rm -rf $TMPGOPATH" EXIT | ||
TMPCMDREPOS=`mktemp -d` | ||
function finish { | ||
mv $TMPCMDREPOS/* cmd/ |
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.
Always use braces and quote expansions:
mv "${TMPCMDREPOS}"/* cmd/
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.
and likewise for other additions
uggh. Could we do it by making REQUIRED_BINS not have ./... and instead have:
I'm sure there is some way to generate that. But just using that list will tell us if it works... |
Though I understand its not everyday that we are adding top level dirs that should be handled by godep-save, but whenever it is done, that means remembering updating hack/godep-save.sh. |
Also do we need to include files too? Like there is doc.go? |
8d91c3f
to
352e165
Compare
@eparis @stevekuznetsov updated PTAL. |
hack/godep-save.sh
Outdated
@@ -164,8 +163,13 @@ fork-with-fake-packages github.com/docker/docker \ | |||
# kubernetes tests, we have to extract the missing test dependencies and run godep-save again | |||
# until we converge. Because we rsync kubernetes itself above, two iterations should be enough. | |||
MISSING_TEST_DEPS="" | |||
ALL_DIRS="$(os::util::list_go_src_files | cut -d '/' -f 1-2 | sort -u | grep -v "^./cmd"|grep -v doc.go)" | |||
ALL_DIRS+=" $(os::util::list_go_src_files | grep "^./cmd/"| cut -d '/' -f 1-3 | LC_ALL=C sort -u|grep -v doc.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.
We're doing this three times now -- let's make a function for it, slap it into hack/lib/util/misc.sh
and not dupe 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.
This one is a bit different than the one in verify-govet.go as it also ignores doc.go (grep -v doc.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.
OK, so cut out the part that is shared maybe? There's too many pipes in general and too much shared for my liking -- suuuuper easy to have a visually indistinguishable change that breaks something between the three this way
hack/godep-save.sh
Outdated
@@ -164,8 +163,13 @@ fork-with-fake-packages github.com/docker/docker \ | |||
# kubernetes tests, we have to extract the missing test dependencies and run godep-save again | |||
# until we converge. Because we rsync kubernetes itself above, two iterations should be enough. | |||
MISSING_TEST_DEPS="" | |||
ALL_DIRS="$(os::util::list_go_src_files | cut -d '/' -f 1-2 | sort -u | grep -v "^./cmd"|grep -v doc.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.
For predictability please use LC_ALL=C
(agree it shouldn't matter)
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 doc.go
scares me a little. Would this work? What if other .go files show up in the root dir?
ALL_DIRS="$(os::util::list_go_src_files | cut -d '/' -f 1-2 | grep -v ".go$" | grep -v "^./cmd" | LC_ALL=C sort -u)
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.
If you are concerned about other .go files show up in the root dir in future, why do want to have grep -v ".go$"
? Thats why I was only excluding doc.go specifically not *.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.
Another thing to consider what if buildable
*.go show up?
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.
Then you'd end up with buildable.go/...
in REQUIRED_ALL_DIRS, which would be bad.
hack/godep-save.sh
Outdated
@@ -164,8 +163,13 @@ fork-with-fake-packages github.com/docker/docker \ | |||
# kubernetes tests, we have to extract the missing test dependencies and run godep-save again | |||
# until we converge. Because we rsync kubernetes itself above, two iterations should be enough. | |||
MISSING_TEST_DEPS="" | |||
ALL_DIRS="$(os::util::list_go_src_files | cut -d '/' -f 1-2 | sort -u | grep -v "^./cmd"|grep -v doc.go)" | |||
ALL_DIRS+=" $(os::util::list_go_src_files | grep "^./cmd/"| cut -d '/' -f 1-3 | LC_ALL=C sort -u|grep -v doc.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.
doc.go worries me similarly. But, that also doesn't seem to do what we need. Since it isn't excluding cc and sc.
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.
@eparis what do you mean it is not excluding cc and sc? os::util::list_go_src_files
already excludes cc and sc.
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.
ohhhhhh, I'm an idiot.
352e165
to
3ca7432
Compare
@eparis @stevekuznetsov updated PTAL. @stevekuznetsov I am not sure how to really do what you are suggesting as only 2 places I see these changes: |
Not sure vetting and linting needs to care about the top-level |
Its just not doc.go now (though those are the ones that exists today) but any *.go in top level origin/ and cmd/ dirs. Are we ok now to remove them from vetting and linting? |
I am very confident that there will never be any file other than the single |
3ca7432
to
da2edb1
Compare
@stevekuznetsov @eparis updated PTAL. |
hack/lib/util/misc.sh
Outdated
function os::util::list_go_src_dirs() { | ||
local ALL_DIRS="$(os::util::list_go_src_files | cut -d '/' -f 1-2 | grep -v ".go$" | grep -v "^./cmd" | LC_ALL=C sort -u)" | ||
ALL_DIRS+=" $(os::util::list_go_src_files | grep "^./cmd/"| cut -d '/' -f 1-3 | grep -v ".go$" | LC_ALL=C sort -u)" | ||
echo "${ALL_DIRS}" |
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.
No need for echo
or for collecting in a variable:
function os::util::list_go_src_dirs() {
os::util::list_go_src_files | cut -d '/' -f 1-2 | grep -v ".go$" | grep -v "^./cmd" | LC_ALL=C sort -u
os::util::list_go_src_files | grep "^./cmd/"| cut -d '/' -f 1-3 | grep -v ".go$" | LC_ALL=C sort -u
}
da2edb1
to
e1b2918
Compare
@stevekuznetsov updated PTAL. |
seems good to me... |
@eparis sure. |
@eparis @stevekuznetsov Reminder for merge tag. |
[merge] |
continuous-integration/openshift-jenkins/merge Waiting: You are in the build queue at position: 1 |
Evaluated for origin merge up to e1b2918 |
@derekwaynecarr @eparis @stevekuznetsov @jpeeler
Fix #14751