-
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
tools: require "--kind" and "--proto-resource" when generating types #2686
tools: require "--kind" and "--proto-resource" when generating types #2686
Conversation
kind := o.ResourceKindName | ||
if kind == "" { | ||
kind = o.ResourceProtoName | ||
} |
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.
Actually my experience is that the Kind and resourceProtoName are always different, because Kind always has the service name prefixed, while resourceProtoName is always ignore that (which makes sense for both case due to the different conditions). So I think may be we shall make both --kind and --proto-resource as required to stabilize the output.
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.
Yeah makes sense. Updated
if o.ResourceProtoName == "" { | ||
return fmt.Errorf("`--proto-resource` is required") | ||
} | ||
if o.ResourceKindName == "" { | ||
return fmt.Errorf("`--kind` is required") | ||
} | ||
o.ResourceProtoName = capitalizeFirstRune(o.ResourceProtoName) |
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.
What happens if neither is provided previously? IIRC, if --kind and --proto-resource is not given, this tool generates everything except the "_types.go" file. Maybe we'd better still keep this functionality and only require both if either one is given.
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.
Actually I never tried running the command without --kind and --proto-resource. What is the intended behavior?
- Prior to commit f5960e4, It looks like the tool will re-generate (a.k.a update) all generated types for the given GCP API. This function is already lost after the commit, the question is do we want to bring it back?
- After commit f5960e4, we need to explicitly provide --kind, and the tool will re-generate (a.k.a. update) all generated types for the given kind.
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.
One suggestion, otherwise looks good!
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
We can discuss the flag usage further. But definitely not a blocker! Thanks for sending the improvements PR!
[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 |
abe8356
into
GoogleCloudPlatform:master
This PR introduces the following changes:
--proto-resource
flag as explicitly required, since the proto resource name is required for identifying the starting point of type generation.--kind
flag as required, given that kind and proto message often do not have the same name.