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

YDefsLoader: add variable interpolation support #858

Conversation

xmkg
Copy link
Contributor

@xmkg xmkg commented May 8, 2024

the default YAML format does not support variable interpolation e.g. referring to another key's value, but it's possible to add it with the help of 'add_constructorandadd_implicit_resolver`.

Example usage:

c: cool
x:
  y: abcdefg
  z: hijklmno
  t: ${c}

foo: ${x.y}${x.z} ${x.t}
# foo's value would be `abcdefghijklmno cool`

@xmkg xmkg marked this pull request as draft May 8, 2024 11:48
@xmkg xmkg force-pushed the feature/yaml-implement-variable-interpolation branch from bfedd2a to 13c5289 Compare May 8, 2024 11:51
@dosaboy
Copy link
Member

dosaboy commented May 8, 2024

This is interesting. one bit of initial feedback i'd have is that it is providing an alternate way to define variables that doesn't behave in the same way e.g. with the existing vars: you can set a variable to a literal, property, factory etc. If we could somehow meld the two that would be cool but I think having two independent ways of doing this might not be a benefit. Thoughts?

@xmkg
Copy link
Contributor Author

xmkg commented May 8, 2024

This is interesting. one bit of initial feedback i'd have is that it is providing an alternate way to define variables that doesn't behave in the same way e.g. with the existing vars: you can set a variable to a literal, property, factory etc. If we could somehow meld the two that would be cool but I think having two independent ways of doing this might not be a benefit. Thoughts?

I feel the same way as well. The proposition value of this patch is not to provide an alternate way to bring properties or replace any other run-time interpreted values, on the contrary, it aims to complement it. I'll experiment with the existing scenarios and see how these two will behave together.

the default YAML format does not support variable interpolation
e.g. referring to another key's value, but it's possible to add
it with the help of 'add_constructor` and `add_implicit_resolver`.

Example usage:

```yaml
c: cool
x:
  y: abcdefg
  z: hijklmno
  t: ${c}

foo: ${x.y}${x.z} ${x.t}
```

Signed-off-by: Mustafa Kemal Gilor <[email protected]>
@xmkg xmkg force-pushed the feature/yaml-implement-variable-interpolation branch from 13c5289 to f74d0c5 Compare May 8, 2024 13:20
@xmkg
Copy link
Contributor Author

xmkg commented Jul 30, 2024

Closing this in favor of #913

@xmkg xmkg closed this Jul 30, 2024
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