I have a list of entities (profiles) I have another list of entities (openapis)
each openapi can be pointed at by several profiles
ex: openapis: "Alpha", "Beta"
profiles: profile1 > "Alpha" profile2 > "Alpha" profile3 > "Beta"
I need to display list of openapis ["Alpha", "Beta"] and their pointing profile ex:
"Alpha" : profile1 ,profile2
"Beta": profile3
I dont have database Im using "kebernetes" CRs what is the best approch for this ? I know I can just filter profiles for each openapi but is there a better approch ?
Given that you're working with Kubernetes Custom Resources (CRs) and you don't have a traditional database, you might need to handle this association in your application logic. Here are a couple of approaches you can consider:
You can maintain an in-memory data structure to keep track of the associations between openapis and profiles. This can be done using a JavaScript object where the keys are openapis and the values are arrays of associated profile Whenever you add or remove a profile from an openapi, you update this data structure accordingly. This approach is suitable if your data set is not too large and can fit comfortably in memory.
If your entities (profiles and openapis) are represented as Kubernetes Custom Resources, you can use labels to associate profiles with openapis. Labels are key-value pairs that can be attached to Kubernetes resources.
For example, you can add labels like:
Then, you can use Kubernetes API queries to retrieve profiles associated with a particular openapi. This approach provides a more declarative way to represent associations.