mirror of
https://github.com/moghtech/komodo.git
synced 2026-09-10 08:01:11 +00:00
escape incoming sync backslashes (BREAKING)
This commit is contained in:
@@ -517,6 +517,6 @@ pub async fn init_execution_update(
|
||||
// Don't actually send it here, let the handlers send it after they can set action state.
|
||||
update.id = add_update_without_send(&update).await?;
|
||||
}
|
||||
|
||||
|
||||
Ok(update)
|
||||
}
|
||||
|
||||
@@ -143,9 +143,7 @@ fn read_resource_file(
|
||||
path: file_path.display().to_string(),
|
||||
contents: contents.clone(),
|
||||
});
|
||||
let more = toml::from_str::<ResourcesToml>(&contents)
|
||||
// the error without this comes through with multiple lines (\n) and looks bad
|
||||
.map_err(|e| anyhow!("{e:#}"))
|
||||
let more = super::deserialize_resources_toml(&contents)
|
||||
.context("failed to parse resource file contents")?;
|
||||
log.push('\n');
|
||||
let path_for_view =
|
||||
|
||||
@@ -1,11 +1,21 @@
|
||||
use std::{collections::HashMap, str::FromStr};
|
||||
|
||||
use anyhow::anyhow;
|
||||
use komodo_client::entities::{
|
||||
action::Action, alerter::Alerter, build::Build, builder::Builder,
|
||||
deployment::Deployment, procedure::Procedure, repo::Repo,
|
||||
server::Server, server_template::ServerTemplate, stack::Stack,
|
||||
sync::ResourceSync, tag::Tag, toml::ResourceToml, ResourceTarget,
|
||||
ResourceTargetVariant,
|
||||
action::Action,
|
||||
alerter::Alerter,
|
||||
build::Build,
|
||||
builder::Builder,
|
||||
deployment::Deployment,
|
||||
procedure::Procedure,
|
||||
repo::Repo,
|
||||
server::Server,
|
||||
server_template::ServerTemplate,
|
||||
stack::Stack,
|
||||
sync::ResourceSync,
|
||||
tag::Tag,
|
||||
toml::{ResourceToml, ResourcesToml},
|
||||
ResourceTarget, ResourceTargetVariant,
|
||||
};
|
||||
use mungos::mongodb::bson::oid::ObjectId;
|
||||
use toml::ToToml;
|
||||
@@ -209,3 +219,17 @@ impl AllResourcesById {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn deserialize_resources_toml(
|
||||
toml_str: &str,
|
||||
) -> anyhow::Result<ResourcesToml> {
|
||||
::toml::from_str::<ResourcesToml>(
|
||||
&toml_str
|
||||
// Escape the \ for the user on incoming.
|
||||
// After deserialized by `toml` crate, the contents
|
||||
// will match what would be passed on eg command line exactly.
|
||||
.replace(r#"\"#, r#"\\"#),
|
||||
)
|
||||
// the error without this comes through with multiple lines (\n) and looks bad
|
||||
.map_err(|e| anyhow!("{e:#}"))
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ pub async fn get_remote_resources(
|
||||
// ==========
|
||||
let mut resources = ResourcesToml::default();
|
||||
let resources = if !sync.config.file_contents.is_empty() {
|
||||
toml::from_str::<ResourcesToml>(&sync.config.file_contents)
|
||||
super::deserialize_resources_toml(&sync.config.file_contents)
|
||||
.context("failed to parse resource file contents")
|
||||
.map(|more| {
|
||||
extend_resources(
|
||||
|
||||
Reference in New Issue
Block a user