I'm using this crate to allow users to "override" a JSON file that is generated.
This worked previously, but seems to have been broken(/changed?) by 772afa0.
Jsonnet: tried to import /.../base.jsonnet from virtual:combined.jsonnet, but imports are not supported
I guess it's due to it being a "virtual" file?
I don't know if there would be a more idiomatic way to achieve this and this is a deliberate change, or if this an actual bug?
pub fn apply_jsonnet_overlays<P: AsRef<Path>>(
self,
jsonnet_paths: impl Iterator<Item = P>,
) -> Result<Self, CustomError> {
let mut jsonnet_paths = jsonnet_paths.peekable();
if jsonnet_paths.peek().is_none() {
return Ok(self);
}
let mut jsonnet = serde_json::to_string(&self)?;
for path in jsonnet_paths {
write!(
jsonnet,
"\n + (import {})",
escape_string_json(&path.as_ref().display().to_string())
)?;
}
trace!("jsonnet_file: {jsonnet}");
let mut state_builder = StateBuilder::default();
state_builder.import_resolver(FileImportResolver::new(vec![std::env::current_dir()?]));
let state = state_builder.build();
let merged_jsonnet_val = state
.evaluate_snippet("combined.jsonnet", jsonnet)
.map_err(|e| CustomError::Jsonnet(e.to_string()))?;
let json_string = merged_jsonnet_val
.to_string()
.map_err(|e| CustomError::Jsonnet(e.to_string()))?;
Ok(serde_json::from_str(&json_string)?)
}
I'm using this crate to allow users to "override" a JSON file that is generated.
This worked previously, but seems to have been broken(/changed?) by 772afa0.
Jsonnet: tried to import /.../base.jsonnet from virtual:combined.jsonnet, but imports are not supportedI guess it's due to it being a "virtual" file?
I don't know if there would be a more idiomatic way to achieve this and this is a deliberate change, or if this an actual bug?