-
Notifications
You must be signed in to change notification settings - Fork 144
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
AIP-122, AIP-123: Validate the singular
and plural
fields of google.api.resource annotations.
#722
Comments
I talked to Eric Tune, who said the k8s convention is all lower case (meaning they suppress word separators, ick). Honestly, I wonder if we need these fields at all. I am not aware of anyone that uses them and we have the information in the |
Good to know! And yeah, adopting that would break convention with a bunch of existing examples...
We use these fields when generating names of GraphQL connections and other similar plural stuff, so I can see the benefit of having the information accessible in a more structured way than by parsing the resource type and resource name pattern(s). If the fields are set, do you still think it would make sense to the above-mentioned consistency checks on them? |
I went through our code and we also use these fields to infer method names for resources (also for GraphQL generation, to know e.g. whether a resource has List and BatchGet methods). |
Yes, I think it makes sense that if they are set, we ensure they are correct. But I would like to not make people set them if we can help it. And still not sure what the naming convention should be. |
I think we do need to set them, so that consumers of protobufs have the ability to clearly understand what the resource singular and plural are intended to be. There already is linting against plural / singular nouns in rules such as aip0136/http_name_variable. I'm a little wary myself that we would rely on a library for plural / singular (e.g. https://github.com/gertd/go-pluralize) and match against those instead of referencing a field of the service owners choosing as the source for consistency. |
A few more thoughts:
So we have to require the plural at least. At that point, why not also require stable? it can match the type, and it's one extra line. |
Requiring singular and plural annotations on resources can enable new use cases in code generation and documentation, and prevents incorrect inferences about these values from the resource type. See googleapis/api-linter#722 for additional discussion around the usage of singular and plural.
Requiring singular and plural annotations on resources can enable new use cases in code generation and documentation, and prevents incorrect inferences about these values from the resource type. See googleapis/api-linter#722 for additional discussion around the usage of singular and plural.
Requiring singular and plural annotations on resources can enable new use cases in code generation and documentation, and prevents incorrect inferences about these values from the resource type. See googleapis/api-linter#722 for additional discussion around the usage of singular and plural.
I think we're missing a linter that enforces consistency between the plural/singular fields within google.api.ResourceDescriptor - specifically:
singular
should be in sync withtype
(the resource type)plural
should be in sync with the collection identifier inpattern
(the resource name)From AIP-122 (Resource names):
From AIP-123 (Resource types):
From google/api/resource.proto:
From the k8s CRD spec:
As such, what are your thoughts about a linter rules that enforce:
pattern
values match theplural
fieldType
component of the resourcetype
field ({Service Name}/{Type}
) matches the UpperCamelCase version of thesingular
fieldThe text was updated successfully, but these errors were encountered: