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 proto gen #108365

Merged
merged 2 commits into from
Feb 26, 2022
Merged

Fix proto gen #108365

merged 2 commits into from
Feb 26, 2022

Conversation

liggitt
Copy link
Member

@liggitt liggitt commented Feb 26, 2022

What type of PR is this?

/kind bug

What this PR does / why we need it:

#108358 made proto files contain full go import paths, but broke actual generation of the generated.pb.go files.

This PR fixes that by telling gogo to generate pb.go files next to the proto files when we're given full paths as input.

Which issue(s) this PR fixes:

Fixes #108358

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

Change-Id: I2a563514955d7fc7559ceb7afb73df08ace8fd8b
@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/bug Categorizes issue or PR as related to a bug. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Feb 26, 2022
@@ -260,6 +260,7 @@ func Run(g *Generator) {
if len(g.Conditional) > 0 {
fmt.Fprintf(buf, "// +build %s\n\n", g.Conditional)
}
buf.Write(boilerplate)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was incorrectly removed in #108358

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we create an issue to have some tests for these files ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with the fix to actually write to the checked in files, this bug was apparent (the copyright header wasn't present)

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. area/code-generation kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/auth Categorizes an issue or PR as relevant to SIG Auth. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/storage Categorizes an issue or PR as relevant to SIG Storage. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Feb 26, 2022
// read input
request := command.Read()

// if we're given paths as inputs, generate .pb.go files based on those paths
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is conditional because some generation scripts (kms and runtime) invoke without full paths to proto files, and some generation scripts (like the API type generation) pass full paths


// if we're given paths as inputs, generate .pb.go files based on those paths
for _, file := range request.FileToGenerate {
if strings.Contains(file, "/") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Contains or prefix? strings.HasPrefix(file, "/")

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contains. when given paths, it looks like k8s.io/kubernetes/vendor/k8s.io/api/core/v1/generated.proto

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when given files instead of paths, it's just api.proto, service.proto, etc

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, is not about relative or absolute paths, forget it

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we put in the comment, an example of these expected paths to make it easier for other people looking at this code ?

@aojea
Copy link
Member

aojea commented Feb 26, 2022

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 26, 2022
@liggitt
Copy link
Member Author

liggitt commented Feb 26, 2022

/retest

@dims
Copy link
Member

dims commented Feb 26, 2022

/approve
/lgtm

that line did look suspicious :) thanks Jordan!

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dims, liggitt

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit 05a71be into kubernetes:master Feb 26, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.24 milestone Feb 26, 2022
@fedebongio
Copy link
Contributor

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Mar 3, 2022
@liggitt liggitt deleted the fix-proto-gen branch May 5, 2022 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/code-generation cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/auth Categorizes an issue or PR as relevant to SIG Auth. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/storage Categorizes an issue or PR as relevant to SIG Storage. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

hack/update-generated-protobuf.sh: no longer creates and/or updates generated.pb.go
6 participants