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

Enhancement of 'ref' mechanism #217

Merged

Conversation

ahitacat
Copy link
Contributor

@ahitacat ahitacat commented Jan 28, 2025

Following the previous work done in #214 and #210 we lack the sub-resource reference.

Current problem

If one has define a class with a reference to another service

// In /aro_hcp/v1_alpha1/cluster_type.model
@ref(path = "/clusters_mgmt/v1/cluster")
class Cluster {
}

Which points to this definition

// In /cluster_mgmt/v1/cluster_type.model
@ref(path = "/clusters_mgmt/v1/cluster")
class Cluster {
    link NodePools []NodePool
}

And then want to override the type NodePool so it is also part of aro_hcp.

// In /aro_hcp/v1_alpha1/cluster_type.model
@ref(path = "/clusters_mgmt/v1/node_pool")
class NodePool {
}

With the current approach this reference class (node_pools) will be pointing to the cluster_mgmt/ instead of aro_hcp/. We wanted to preserve this links except if it was explicit defined. As this example shown that was not the case.

Proposed solution

The types will had a new field, ExplicitDeclared. When a type is referenced as the NodePool shown in the example, this will be set to true. And it will go through the read tree to remove the references from the service where the resource is define and change them to the service that is reading the definition.

Additionally, when generating the rest of the reference tree it will look for ExplicitDeclared types and will change its ownership so it is the same as the version the reader is building.

@ahitacat ahitacat force-pushed the add-explicit-declaration-subresource branch 6 times, most recently from f360df4 to a00cc97 Compare January 30, 2025 10:55
Signed-off-by: Alba Hita Catala <ahitacat@redhat.com>
@ahitacat ahitacat force-pushed the add-explicit-declaration-subresource branch from a00cc97 to 5c1de52 Compare January 30, 2025 12:31
Signed-off-by: Alba Hita Catala <ahitacat@redhat.com>
@ahitacat ahitacat marked this pull request as ready for review January 30, 2025 12:36
Signed-off-by: Alba Hita Catala <ahitacat@redhat.com>
@ahitacat ahitacat changed the title Initial work on referencing subresources Fixed for referenced subresources Jan 30, 2025
@ahitacat ahitacat changed the title Fixed for referenced subresources Enhancement of 'ref' mechanism Jan 30, 2025
Signed-off-by: Alba Hita Catala <ahitacat@redhat.com>
@ahitacat ahitacat requested a review from nimrodshn January 31, 2025 08:42
@nimrodshn
Copy link
Collaborator

LGTM 💯

@nimrodshn nimrodshn merged commit 50bf1dc into openshift-online:main Jan 31, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants