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

Fix godep-save by ignoring cmd/cluster-capacity and cmd/service-catalog dirs. #14787

Merged

Conversation

aveshagarwal
Copy link
Contributor

@aveshagarwal aveshagarwal changed the title Fix godep-save by ignoring cmd/cluster-capacity and cmd/service-cataog dirs. Fix godep-save by ignoring cmd/cluster-capacity and cmd/service-catalog dirs. Jun 20, 2017
@@ -56,7 +56,13 @@ REQUIRED_BINS=(
)

TMPGOPATH=`mktemp -d`
trap "rm -rf $TMPGOPATH" EXIT
TMPCMDREPOS=`mktemp -d`
Copy link
Contributor

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 )"

Copy link
Contributor

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}" )" 

trap "rm -rf $TMPGOPATH" EXIT
TMPCMDREPOS=`mktemp -d`
function finish {
mv $TMPCMDREPOS/* cmd/
Copy link
Contributor

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/

Copy link
Contributor

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

@eparis
Copy link
Member

eparis commented Jun 20, 2017

uggh. Could we do it by making REQUIRED_BINS not have ./... and instead have:

[things and stuffs]
pkg/...
api/...
assets/...
contrib/...
 docs/...
examples/...
hack/...
images/...
pkg/...
test/...
tools/...
cmd/dockerregistry/...
cmd/gitserver/...
cmd/kubefed/...
cmd/oc/...
cmd/openshift/...

I'm sure there is some way to generate that. But just using that list will tell us if it works...

@aveshagarwal
Copy link
Contributor Author

Could we do it by making REQUIRED_BINS not have ./... and instead have:

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.

@aveshagarwal
Copy link
Contributor Author

aveshagarwal commented Jun 20, 2017

Could we do it by making REQUIRED_BINS not have ./... and instead have:

Also do we need to include files too? Like there is doc.go?

@aveshagarwal aveshagarwal force-pushed the master-origin-issue-14751 branch from 8d91c3f to 352e165 Compare June 21, 2017 03:01
@aveshagarwal
Copy link
Contributor Author

@eparis @stevekuznetsov updated PTAL.

@@ -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)"
Copy link
Contributor

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

Copy link
Contributor Author

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).

Copy link
Contributor

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

@@ -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)"
Copy link
Member

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)

Copy link
Member

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)

Copy link
Contributor Author

@aveshagarwal aveshagarwal Jun 21, 2017

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.

Copy link
Contributor Author

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?

Copy link
Member

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.

@@ -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)"
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

@aveshagarwal aveshagarwal force-pushed the master-origin-issue-14751 branch from 352e165 to 3ca7432 Compare June 21, 2017 18:32
@aveshagarwal
Copy link
Contributor Author

@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: verify-govet.sh and godep-save.sh, as not sure to find a common stuff that really helps. Do you have any suggestion?

@stevekuznetsov
Copy link
Contributor

Not sure vetting and linting needs to care about the top-level doc.go either so it seems like both places could use the same manipulations to os::util::list_go_src_files

@aveshagarwal
Copy link
Contributor Author

Not sure vetting and linting needs to care about the top-level doc.go either so it seems like both places could use the same manipulations to os::util::list_go_src_files

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?

@stevekuznetsov
Copy link
Contributor

I am very confident that there will never be any file other than the single doc.go at the top level or directly under cmd/.

@aveshagarwal aveshagarwal force-pushed the master-origin-issue-14751 branch from 3ca7432 to da2edb1 Compare June 21, 2017 23:02
@aveshagarwal
Copy link
Contributor Author

@stevekuznetsov @eparis updated PTAL.

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}"
Copy link
Contributor

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
}

@aveshagarwal aveshagarwal force-pushed the master-origin-issue-14751 branch from da2edb1 to e1b2918 Compare June 22, 2017 01:16
@aveshagarwal
Copy link
Contributor Author

@stevekuznetsov updated PTAL.

@eparis
Copy link
Member

eparis commented Jun 22, 2017

seems good to me...
@aveshagarwal will you remind us all to merge on monday? (or is this blocking you on something you must get in today/tomorrow)

@aveshagarwal
Copy link
Contributor Author

@eparis sure.

@aveshagarwal
Copy link
Contributor Author

@eparis @stevekuznetsov Reminder for merge tag.

@stevekuznetsov
Copy link
Contributor

[merge]

@openshift-bot
Copy link
Contributor

openshift-bot commented Jun 27, 2017

continuous-integration/openshift-jenkins/merge Waiting: You are in the build queue at position: 1

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to e1b2918

@smarterclayton smarterclayton merged commit 2197c0e into openshift:master Jun 27, 2017
@aveshagarwal aveshagarwal deleted the master-origin-issue-14751 branch July 24, 2017 13:54
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.

5 participants