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: Fix g3doc for refs #3398

Merged
merged 1 commit into from
Dec 18, 2024

Conversation

gemmahou
Copy link
Collaborator

@gemmahou gemmahou commented Dec 17, 2024

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

  • Run make ready-pr to ensure this PR is ready for review.
  • Perform necessary E2E testing for changed resources.

@gemmahou
Copy link
Collaborator Author

/assign @acpana @maqiuyujoyce
/cc @yuwenma

Copy link
Collaborator

@yuwenma yuwenma left a 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{{"}}"}}".
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this intended?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

ditto

@maqiuyujoyce
Copy link
Collaborator

Is there a way to enforce this consistent format? Can we have checkers of for potential incorrect strings like "<project>"/"[projectID]"?

@gemmahou
Copy link
Collaborator Author

Is there a way to enforce this consistent format? Can we have checkers of for potential incorrect strings like "<project>"/"[projectID]"?

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

@maqiuyujoyce
Copy link
Collaborator

/lgtm

@google-oss-prow google-oss-prow bot added the lgtm label Dec 18, 2024
Copy link
Collaborator

@yuwenma yuwenma left a 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

Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@google-oss-prow google-oss-prow bot merged commit 7da399c into GoogleCloudPlatform:master Dec 18, 2024
17 checks passed
@gemmahou gemmahou deleted the fix-g3doc branch December 18, 2024 18:02
@acpana acpana mentioned this pull request Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants