Skip to content

Support injecting dev variables in tests#181

Merged
alex-hunt-materialize merged 4 commits intomainfrom
dev_vars_support
Apr 7, 2026
Merged

Support injecting dev variables in tests#181
alex-hunt-materialize merged 4 commits intomainfrom
dev_vars_support

Conversation

@alex-hunt-materialize
Copy link
Copy Markdown
Contributor

Support injecting dev variables in tests.

This makes it much easier to test development versions of the helm chart, orchestratord, and environmentd.

@alex-hunt-materialize alex-hunt-materialize marked this pull request as ready for review April 6, 2026 16:55
bobbyiliev
bobbyiliev previously approved these changes Apr 7, 2026
Copy link
Copy Markdown
Collaborator

@bobbyiliev bobbyiliev left a comment

Choose a reason for hiding this comment

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

Looks good! Just one minor nit/question.

Comment on lines +331 to +357
fn inject_into_module(content: &str, module_name: &str, vars: &[&str]) -> String {
let target = format!("module \"{module_name}\"");
let mut lines: Vec<&str> = content.lines().collect();
let mut in_module = false;
let mut insert_after = None;

for (i, line) in lines.iter().enumerate() {
if line.contains(&target) {
in_module = true;
}
if in_module && line.trim_start().starts_with("source") {
insert_after = Some(i);
break;
}
}

if let Some(idx) = insert_after {
let mut offset = 1;
lines.insert(idx + offset, "");
offset += 1;
for var in vars {
let line = format!(" {var}");
// Leak is fine here – this runs once during init.
lines.insert(idx + offset, Box::leak(line.into_boxed_str()));
offset += 1;
}
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nit: I think that if insert_after is None (eg. module block not found in main.tf), this silently returns the content unchanged. Might be worth logging a warning or returning an Err so a missing/renamed module doesn't go unnoticed?

bobbyiliev
bobbyiliev previously approved these changes Apr 7, 2026
Copy link
Copy Markdown
Collaborator

@bobbyiliev bobbyiliev left a comment

Choose a reason for hiding this comment

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

Looks good!

@alex-hunt-materialize alex-hunt-materialize added this pull request to the merge queue Apr 7, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 7, 2026
@alex-hunt-materialize alex-hunt-materialize added this pull request to the merge queue Apr 7, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 7, 2026
@alex-hunt-materialize alex-hunt-materialize added this pull request to the merge queue Apr 7, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 7, 2026
@alex-hunt-materialize alex-hunt-materialize added this pull request to the merge queue Apr 7, 2026
Merged via the queue into main with commit bd92fab Apr 7, 2026
6 checks passed
@alex-hunt-materialize alex-hunt-materialize deleted the dev_vars_support branch April 7, 2026 17:06
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