-
Notifications
You must be signed in to change notification settings - Fork 236
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: Fix g3doc for refs #3398
fix: Fix g3doc for refs #3398
Conversation
/assign @acpana @maqiuyujoyce |
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.
Thanks
@@ -34,7 +34,7 @@ var _ refsv1beta1.ExternalNormalizer = &{{.ProtoResource}}Ref{} | |||
// holds the GCP identifier for the KRM object. | |||
type {{.ProtoResource}}Ref struct { | |||
// A reference to an externally managed {{.Kind}} resource. | |||
// Should be in the format "projects/<projectID>/locations/<location>/{{.ProtoResource | ToLower }}s/<{{.ProtoResource | ToLower }}ID>". | |||
// Should be in the format "projects/{{"{{"}}projectID{{"}}"}}/locations/{{"{{"}}location{{"}}"}}/{{.ProtoResource | ToLower }}s/{{"{{"}}{{.ProtoResource | ToLower }}ID{{"}}"}}". |
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 intended?
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, this is the easiest way: https://stackoverflow.com/questions/17641887/how-do-i-escape-and-delimiters-in-go-templates
@@ -109,7 +109,7 @@ func New{{.ProtoResource}}Identity(ctx context.Context, reader client.Reader, ob | |||
func Parse{{.ProtoResource}}External(external string) (parent *{{.ProtoResource}}Parent, resourceID string, err error) { | |||
tokens := strings.Split(external, "/") | |||
if len(tokens) != 6 || tokens[0] != "projects" || tokens[2] != "locations" || tokens[4] != "{{.ProtoResource | ToLower }}s" { | |||
return nil, "", fmt.Errorf("format of {{.Kind}} external=%q was not known (use projects/<projectId>/locations/<location>/{{.ProtoResource | ToLower }}s/<{{.ProtoResource | ToLower }}ID>)", external) | |||
return nil, "", fmt.Errorf("format of {{.Kind}} external=%q was not known (use projects/{{"{{"}}projectID{{"}}"}}/locations/{{"{{"}}location{{"}}"}}/{{.ProtoResource | ToLower }}s/{{"{{"}}{{.ProtoResource | ToLower }}ID{{"}}"}})", external) |
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.
ditto
Is there a way to enforce this consistent format? Can we have checkers of for potential incorrect strings like |
If files are generated by the template, they should be fine. I think I can add unit test to make sure we do not have "<>" in CRD/g3doc field descriptions. b/384795846 |
/lgtm |
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.
/lgtm
/approve
THank you
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: yuwenma 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 |
7da399c
into
GoogleCloudPlatform:master
Change description
We are using
projects/<projectID>/global/networks/<network>
in template but that will cause issues in our g3doc, screenshot: https://screenshot.googleplex.com/5Hg3goroSATbXDF.png. I changed the template to escape braces{{
and}}
during Golang Template rendering:projects/{{projectID}}/global/networks/{{network}}
.I noticed there are other refs using
[[
and]]
. Other than consistency I don't see doc issues, so I skip them for now.Tests you have done
make ready-pr
to ensure this PR is ready for review.