-
Notifications
You must be signed in to change notification settings - Fork 26
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
Add support for 'ref' annotation #210
Add support for 'ref' annotation #210
Conversation
9635173
to
b8b62a0
Compare
LGTM, but would like to have more eyes on this |
It seems that the "ref" value is mixing the URL endpoint (@ref(path = "/clusters_mgmt/v1/cluster")) with the struct definition. Same struct can be shared on different endpoint. How about to make the path binded to the actual class definition path, rather than the endpoint itself, which can change. |
@tzvatot You're correct. This implementation is somewhat naive, we are now enhancing this mechanism to bind the struct like you suggested. |
b8b62a0
to
c64d3a7
Compare
c64d3a7
to
ab9daad
Compare
b5183a1
to
a676eb2
Compare
8f7c7ee
to
1af7b0d
Compare
3f1f0d8
to
342522c
Compare
342522c
to
3fc89e6
Compare
Please add UT |
97ac562
to
34762d8
Compare
ddaf15c
to
017e2a7
Compare
017e2a7
to
e4374af
Compare
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
@jhernand Mind merging please? |
Done, and you should have permissions now. |
Many thanks @jhernand ! |
What this does?
Adds support for a reference directive -
@ref(name="/path/to/service")
in order to share resources and definitions between services.Currently this is only supported for types in order to share their definition between services, however, as we continue to implement the
/aro_hcp
service we will likely enhance this implementation.Here is an example use case where we share the Cluster type:
With sdk that looks like the following:
Important detail is that this preserves the "links" or references to other resources unless defined explicitly, for example:
From the docs [committed here]:
Class references using @ref annotation
One can define a class reference inside a service such that it will inherit its content from
another service using the special
@ref
annotation, for example:The above decelaration will inherit its content from the
Cluster
class under the/clusters_mgmt/v1
service.This means that any changes made in
Cluster
class will be reflected under this derived type as well.Links to other resources are preserved as they are.
If one wishes to override a type she can create a class inside
/aro_hcp/v1_alpha1/
in order to override any nested types defined.For example the following type declaration will override the
NodePools
link insideCluster
under/aro_hcp/v1
:This means that now under
Cluster
theNodePools
field type is linked to the one defined in/aro_hcp/v1_alpha1
(i.e.v1alpha.NodePool
) which itself references and derived from theNodePool
type under/clusters_mgmt/v1
.