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

Change qualifier from key-value structure to list of labels #235

Open
danielwiehl opened this issue Jun 1, 2023 · 3 comments
Open

Change qualifier from key-value structure to list of labels #235

danielwiehl opened this issue Jun 1, 2023 · 3 comments

Comments

@danielwiehl
Copy link
Collaborator

The qualifier is used to distinguish capabilities of the same type. It was originally designed as a dictionary, primarily to support the passing of identifiers. However, the qualifier is now static (i.e., no longer supports wildcard values), and identifiers are passed as parameters.

Therefore, consider changing the qualifier to a list of distinct labels instead of a key-value structure. Then, finding a reasonable dictionary key often turned out to be tricky.

Actual structure:
qualifier: {[key: string]: string | number | boolean}

Proposed change:
qualifier: string | Set<string>

@danielwiehl danielwiehl added this to Triage in SCION via automation Jun 1, 2023
@ova2
Copy link
Contributor

ova2 commented Jul 1, 2023

Distinct arrays as type is probably better than Set because you don't need to carry all methods from Sets. You're just interested in data container with distinct values. Such type can be defined e.g. as follows: https://tompicton.com/typescript-distinct-array/

Means:

qualifier: string | DistinctArray<string>

The same for Map. Why to model a data structure as "heavyweight" Map if you only need a dictionary?

@Marcarrian
Copy link
Collaborator

Hey @ova2,
Thank you for your suggestion. The type definition for DistinctArray is quite complex and is hard to read especially for the users of the API. I am unsure if the added complexity outweights the disadvantages of simply using Sets. Furthermore, since qualifiers are defined in the manifest.json file, only array types are supported anyways. We might just define the qualifier as such:

qualifier: string | Array<string>

@ova2
Copy link
Contributor

ova2 commented Jul 3, 2023

Hey @ova2, Thank you for your suggestion. The type definition for DistinctArray is quite complex and is hard to read especially for the users of the API. I am unsure if the added complexity outweights the disadvantages of simply using Sets. Furthermore, since qualifiers are defined in the manifest.json file, only array types are supported anyways. We might just define the qualifier as such:

qualifier: string | Array<string>

I see. This sounds good for me:

qualifier: string | string[]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
SCION
  
Triage
Development

No branches or pull requests

3 participants