fix: Properly escape module json

This commit is contained in:
Gerald Pinder 2024-09-14 00:58:41 -04:00
parent ce717118ce
commit fbf57e5c83
6 changed files with 11 additions and 17 deletions

View file

@ -9,7 +9,7 @@ license.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rinja = "0.3.0"
rinja = { version = "0.3.0", features = ["serde_json"] }
blue-build-recipe = { version = "=0.8.17", path = "../recipe" }
blue-build-utils = { version = "=0.8.17", path = "../utils" }

View file

@ -152,7 +152,10 @@ fn should_color() -> bool {
mod filters {
#[allow(clippy::unnecessary_wraps)]
pub fn replace<T: std::fmt::Display>(input: T, from: char, to: &str) -> rinja::Result<String> {
pub fn replace<T>(input: T, from: char, to: &str) -> rinja::Result<String>
where
T: std::fmt::Display,
{
Ok(format!("{input}").replace(from, to))
}
}

View file

@ -27,7 +27,7 @@ RUN \
{%- endif %}
--mount=type=bind,from=ghcr.io/blue-build/cli:{{ exports_tag }}-build-scripts,src=/scripts/,dst=/tmp/scripts/ \
--mount=type=cache,dst=/var/cache/rpm-ostree,id=rpm-ostree-cache-{{ recipe.name }}-{{ recipe.image_version }},sharing=locked \
/tmp/scripts/run_module.sh '{{ module.module_type }}' '{{ module.print_module_context() }}' \
/tmp/scripts/run_module.sh '{{ module.module_type }}' '{{ module|json|safe }}' \
&& ostree container commit
{%- endif %}
{%- endif %}
@ -59,7 +59,7 @@ RUN \
--mount=type=bind,from=stage-modules,src=/modules,dst=/tmp/modules,rw \
{%- endif %}
--mount=type=bind,from=ghcr.io/blue-build/cli:{{ exports_tag }}-build-scripts,src=/scripts/,dst=/tmp/scripts/ \
/tmp/scripts/run_module.sh '{{ module.module_type }}' '{{ module.print_module_context() }}'
/tmp/scripts/run_module.sh '{{ module.module_type }}' '{{ module|json|safe }}'
{%- endif %}
{%- endif %}
{%- endfor %}