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

feature: SchemaMappingTransform allow kinds to be defined #7

Open
minitriga opened this issue Sep 25, 2024 · 1 comment
Open

feature: SchemaMappingTransform allow kinds to be defined #7

minitriga opened this issue Sep 25, 2024 · 1 comment
Labels
state/backlog This issue is part of the backlog type/feature New feature or request

Comments

@minitriga
Copy link
Contributor

The addition of SchemaMappingTransform is wonderful however it will always return a string.

There are some reasons why you might not want to return a string. Such as in IP Fabrics case we display an interface state as up or down. But I need to be able to convert it to a boolean for a generic InfrahubSchema to be useful to anyone.

Interface Schema:

attributes:
  - name: enabled
     kind: Boolean

Sync Config

  - name: InfraInterface
    transforms:
       - field: l1
          expression: '{{ "true" if "up" in l1 else "false" }}'
    mapping: ...
    fields:
      - name: enabled
        mapping: l1

Returning a string will fail as enabled expects a Boolean. If there was a way to define the kind in the transforms like so:

  - name: InfraInterface
    transforms:
       - field: l1
          expression: '{{ "true" if "up" in l1 else "false" }}'
          kind: Boolean
    mapping: ...
    fields:
      - name: enabled
        mapping: l1

Then it would be good to convert the string to another type allowing yes/no or true false, if kind is Number then it converts the string to an int if its valid for the infrahub schema.

@minitriga
Copy link
Contributor Author

After speaking about this with the Infrahub Team it makes sense to not have a kind and derive the kind from the destination schema.

@BeArchiTek BeArchiTek removed their assignment Nov 20, 2024
@BeArchiTek BeArchiTek changed the title SchemaMappingTransform allow kinds to be defined feature: SchemaMappingTransform allow kinds to be defined Jan 6, 2025
@BeArchiTek BeArchiTek added the type/feature New feature or request label Jan 6, 2025
@exalate-issue-sync exalate-issue-sync bot added state/need-triage This issue needs to be triaged state/backlog This issue is part of the backlog and removed state/need-triage This issue needs to be triaged labels Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state/backlog This issue is part of the backlog type/feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants