-
Notifications
You must be signed in to change notification settings - Fork 40.1k
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
Don't check in zz_generated.openapi.go. #41106
Conversation
421831e
to
16a502a
Compare
hack/update-bazel.sh
Outdated
@@ -22,5 +22,8 @@ source "${KUBE_ROOT}/hack/lib/init.sh" | |||
|
|||
git config http.https://gopkg.in.followRedirects true | |||
|
|||
go get -u gopkg.in/mikedanese/gazel.v13/gazel | |||
# Remove generated files prior to running gazel. | |||
rm -f "${KUBE_ROOT}/pkg/generated/openapi/zz_generated.openapi.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.
... :(
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.
Eventually this will be make clean_generated
instead, but for now this will have to do.
gazel
isn't smart enough to do it any other way iiuc.
a7c8780
to
8626cdc
Compare
hack/update-bazel.sh
Outdated
@@ -22,5 +22,8 @@ source "${KUBE_ROOT}/hack/lib/init.sh" | |||
|
|||
git config http.https://gopkg.in.followRedirects true | |||
|
|||
# Remove generated files prior to running gazel. | |||
rm -f "${KUBE_ROOT}/pkg/generated/openapi/zz_generated.openapi.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.
Will this exist forever? This means that any time we run gazel, we will have to rebuild all generated files, even if net nothing changed...
Or does this come with a TODO?
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 we only use Bazel to build then we can delete this, since Bazel doesn't put the generated file in with the rest of the source. As long as we support both Bazel and make we'll need this.
We could consider adding the ability to gazel to move files to somewhere else and then back after the run, but I don't think it's worth 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.
Can we maybe use +build tags to make bazel ignore it or something? Or can it come with a TODO comment to remove this line completely once Bazel is the only way to build?
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.
Added a TODO. Our generated code has the !ignore_autogenerated
tag on it that we might be able to use, but only once bazel can generate all of our code.
hack/verify-bazel-generated.sh
Outdated
export KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. | ||
cd "${KUBE_ROOT}" | ||
# List go packages with the k8s:openapi-gen tag. | ||
files=$(grep --color=never -l '+k8s:openapi-gen=' \ |
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 is going to include vendor/ - is that intended? The find used in the Make process is very carefully written...
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 copied the find from the makefile, but I'm not sure that there's a good way to keep it up to date. We do want to include vendor/
.
Using the make process, if I touch vendor/k8s.io/apimachinery/pkg/apis/meta/v1/doc.go
then run make generated_files
, it will recreate the generated files under there. Evidently the source of truth for that stuff is vendor/
...
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.
ugggggggggh, I didn't see that coming - the repo splits now force us to codegen for a vendored repo.
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.
but when we codegen, we exclude vendor...
hack/make-rules/helpers/cache_go_dirs.sh
how does it work?
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 I rm vendor/k8s.io/apimachinery/pkg/apis/meta/v1/zz_generated.deepcopy.go
and then run make generated_files
, it recreates the file. Not sure how it works, but for now I was planning on maintaining that behavior.
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 whole staging and vendor thing is super confusing.
hack/verify-bazel.sh
Outdated
@@ -22,6 +22,9 @@ source "${KUBE_ROOT}/hack/lib/init.sh" | |||
|
|||
git config http.https://gopkg.in.followRedirects true | |||
|
|||
# Remove generated files prior to running gazel. | |||
rm -f "${KUBE_ROOT}/pkg/generated/openapi/zz_generated.openapi.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.
same comment as above
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.
Same response.
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.
same response
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.
Copied the TODO here as well.
pkg/generated/openapi/def.bzl
Outdated
|
||
|
||
def openapi_library(name, tags, srcs): | ||
deps = [ |
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.
is this file generated? From what? I'm not seeing where it originates..
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, this file is hand-written. However, gazel will still automanage the go_default_library
in pkg/generated/openapi/BUILD
. This isn't a big deal for this generated file, since its only source is doc.go
, but it will be important for the other zz_generated
files.
Trivial rebase, no changes outside of |
@thockin PTAL |
This seems OK (modulo comments) for this, but now I am worried about the other generators wrt vendor/ - should we hold off on merge until we know we know what is happening there? |
@mikedanese has a PR out (#40777) to put I think this PR can go in before we know what happens with |
pkg/generated/openapi/def.bzl
Outdated
load("@io_kubernetes_build//defs:go.bzl", "go_genrule") | ||
|
||
OPENAPI_TARGETS = [ | ||
"cmd/libs/go2idl/client-gen/test_apis/testgroup/v1", |
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.
@thockin: After talking with @mikedanese, I think it's a good idea to automanage these lists with gazel.
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.
Done.
Clean zz_generated.openapi.go before running gazel.
#40777 is in, so this can proceed. |
"doc.go", | ||
"zz_generated.openapi.go", | ||
srcs = ["doc.go"], | ||
openapi_targets = [ |
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.
Remind me - this list is manually maintained? Or do we auto-figure that out?
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.
Gazel automanages it :)
I'm OK to get this in, but I think being manually managed will catch up with us very quickly. |
@k8s-bot gce etcd3 e2e test this |
I updated #33440
…On Tue, Apr 25, 2017 at 11:26 PM, Joe Finney ***@***.***> wrote:
@k8s-bot <https://github.com/k8s-bot> gce etcd3 e2e test this
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#41106 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFVgVHjKqCuQNB-IyYRt4Qewvdif2-Nbks5rzuONgaJpZM4L6NGf>
.
|
Do I need to change anything in this one or should it go in as-is? It's going to make #3340 need a rebase. |
Do we want to flatten all of these commits into a single PR, in case of
rollback? If not, let's go for it
…On Wed, Apr 26, 2017 at 1:02 PM, Joe Finney ***@***.***> wrote:
Do I need to change anything in this one or should it go in as-is? It's
going to make #3340 <#3340>
need a rebase.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#41106 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFVgVA6rCfvOi7WdwnRRQF6Uvky9Cqzwks5rz6LjgaJpZM4L6NGf>
.
|
If we end up merging both and need to rollback both then we can do so in one PR with multiple |
I'm happy to give this a shot when you guys are.
git revert allows for a revert of a merge commit, which reverts all commits that were merged in a single go. Checkout |
/lgtm |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mikedanese, spxtr, thockin
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
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.
My PR still needs genrules :)
go get gopkg.in/mikedanese/gazel.v16/gazel | ||
# Remove generated files prior to running gazel. | ||
# TODO(spxtr): Remove this line once Bazel is the only way to build. | ||
rm -f "${KUBE_ROOT}/pkg/generated/openapi/zz_generated.openapi.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.
In my PR I went the other way - force it to be generated before running gazel. Otherwise some symbols are missing for other genfiles
Automatic merge from submit-queue |
zz_generated.openapi.go
is the file that causes the most merge conflicts of all. In #33440, @thockin updated the makefile to support generating these files on demand, but that didn't play well with bazel/gazel.In this PR, I add a new build macro that will generate this file with a
go_genrule
. I added support for keeping the BUILD file up to date in mikedanese/gazel#34.Release note: