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 ownership ref issue #214

Merged
merged 3 commits into from
Dec 18, 2024

Conversation

ahitacat
Copy link
Contributor

@ahitacat ahitacat commented Dec 18, 2024

Idea behind this solution

For referenced classes the idea is to preserve the links (version and service):

If we have a class that references to another service:

"my_service/v1_alpha1/my_class.model",
`
@ref(path="other_service/v1/my_class")
class MyClass {
}
`,
"other_service/v1/my_class.model",
`
class MyClass {
  link Foo []MyAttribute
  Loo MyAttribute
}`,

We would like that the metamodel reader conserves this attribute reference and that it builds it by pointing to the correct version/service. While at the same time change get the ownership of the attributes that are not linked.

So the my_class_type.go would look like:

type MyClass struct {
  foo  *v1.MyAttributeList
  loo   *MyAttribute
}

The builders of foo will point to the other_service/v1 and the builders of loo will point to my_service/v1_alpha1

Previous approach

Previous approach #210 was relying on ownership to know the service and version of type. Whoever this caused a problem with link types and nested type. A type could be link in a class and be an attribute of another class. This causes a conflict on preservation of link and it depended on how the tree representation was created, as it was in that moment where the ownership was modified.

Current solution

This work adds a new field in the attribute type linkOwner, that will preserve the link ownership if exists. When it is a link of a referenced class this field will held the version of the attribute. So, it is used in the reader and the builders to generate the sdk.

@ahitacat ahitacat changed the title Fix reader and generators Fix ownership ref issue Dec 18, 2024
Signed-off-by: Alba Hita Catala <[email protected]>
@ahitacat ahitacat force-pushed the fix-ownership-issue branch from 19c6ba9 to 07233bc Compare December 18, 2024 12:31
Signed-off-by: Alba Hita Catala <[email protected]>
Signed-off-by: Alba Hita Catala <[email protected]>
@nimrodshn
Copy link
Collaborator

Very nice! LGTM 💯

@nimrodshn nimrodshn merged commit 141354a into openshift-online:main Dec 18, 2024
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