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

feat: Lazily evaluated env template variables in path entries #2310

Merged
merged 27 commits into from
Sep 28, 2024

Conversation

josb
Copy link
Contributor

@josb josb commented Jun 20, 2024

Implements #1912.

Please note that there's a TODO entry in mise::EnvMapVisitor.visit_map. The issue is that deserialize_with = "deserialize_arr" can either be left off or added topath: Vec<PathEntry>:

  • If it is left off, the feature works as demonstrated but 3 tests fail;
  • if it is added, lazy path entries ({ value = "{{ env.GEM_HOME }}/bin" }) cause a parse error (invalid type: map, expected a string) but the 3 failing tests now pass.

I am hoping you can help me address this issue, as I don't understand Serde / Rust well enough yet.
This is also the reason why I didn't add any tests for this feature yet.

Thanks!

@josb josb changed the title Lazily evaluated env template variables in path entries feat: Lazily evaluated env template variables in path entries Jun 20, 2024
@@ -79,6 +137,8 @@ impl EnvResults {
) -> eyre::Result<Self> {
let settings = Settings::get();
let mut ctx = BASE_CONTEXT.clone();
debug!("resolve: input: {:#?}", &input);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these should all be trace level

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix, I just added these while trying to understand the code. If you feel some serve little purpose I am happy to remove them.

Also, if you have suggestions for better identifier names, I will happily change them. 🙏🏻

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed all debug calls to trace, and added a custom deserializer to get both the tests to pass and the lazy path entries to be parsed correctly.

@josb
Copy link
Contributor Author

josb commented Sep 14, 2024

Any feedback, @jdx?

@jdx jdx enabled auto-merge (squash) September 28, 2024 13:42
@jdx jdx merged commit 1e840b8 into jdx:main Sep 28, 2024
12 checks 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