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

Fixes #25756: Switch to a supported successor of serde_yaml #5974

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion policies/rudderc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ regex = "1"
mdbook = { version = "0.4.28", default-features = false, features = ["search"] }
nom = "7.1.3"
serde = { version = "1", features = ["derive"] }
serde_yaml = "0.9"
serde_yaml_ng = "0.10"
format_serde_error = { git = "https://github.com/fennewald/format_serde_error/", rev = "06ef275" }
strsim = "0.11"
serde_json = "1"
Expand Down
2 changes: 1 addition & 1 deletion policies/rudderc/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub fn read_technique(methods: &'static Methods, input: &str) -> Result<Techniqu
compiler.add_resource(schema_url, schema).unwrap();
let sch_index = compiler.compile(schema_url, &mut schemas).unwrap();
// then load technique file
let instance: Value = serde_yaml::from_str(input)?;
let instance: Value = serde_yaml_ng::from_str(input)?;
// ... and validate
let result = schemas.validate(&instance, sch_index);
if let Err(error) = result {
Expand Down
2 changes: 1 addition & 1 deletion policies/rudderc/src/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,6 @@ You need to replace `${{{class_parameter}}}` with its actual canonified value.
method: m.bundle_name.clone(),
params,
};
Ok(serde_yaml::to_string(&e)?)
Ok(serde_yaml_ng::to_string(&e)?)
}
}
3 changes: 1 addition & 2 deletions policies/rudderc/src/frontends.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
use std::path::PathBuf;

use anyhow::Result;
use format_serde_error::SerdeError;
use rudder_commons::methods::{self, Methods};
use tracing::{error, trace};

Expand All @@ -24,7 +23,7 @@ pub fn read(input: &str) -> Result<Technique> {
// not permitting with an untagged enum.
// * A second manual conversion to get the precise type.
let policy: DeserTechnique =
serde_yaml::from_str(input).map_err(|err| SerdeError::new(input.to_string(), err))?;
serde_yaml_ng::from_str(input)?;
let policy = policy.to_technique()?;

trace!("Parsed input:\n{:#?}", policy);
Expand Down
2 changes: 1 addition & 1 deletion policies/rudderc/src/ir/condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{fmt, str::FromStr};
use anyhow::{bail, Error};
use rudder_commons::is_canonified;
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
use serde_yaml::Value;
use serde_yaml_ng::Value;

/// Valid condition
///
Expand Down
2 changes: 1 addition & 1 deletion policies/rudderc/src/ir/technique.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::{
use anyhow::{bail, Context, Error, Result};
use rudder_commons::{methods::method::MethodInfo, PolicyMode, RegexConstraint, Select};
use serde::{de, Deserialize, Deserializer, Serialize};
use serde_yaml::Value;
use serde_yaml_ng::Value;
use uuid::Uuid;

use crate::ir::condition::Condition;
Expand Down
8 changes: 4 additions & 4 deletions policies/rudderc/src/ir/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use nom::{
Finish, IResult,
};
use rudder_commons::Target;
use serde_yaml::Value;
use serde_yaml_ng::Value;
use tracing::{debug, warn};

use super::technique;
Expand Down Expand Up @@ -56,11 +56,11 @@ where
/// Known vars, for now no distinction between OSes
///
/// Allows checking for incorrect expressions.s
pub fn known_vars() -> &'static serde_yaml::Value {
static KNOWN_VAR: OnceLock<serde_yaml::Value> = OnceLock::new();
pub fn known_vars() -> &'static serde_yaml_ng::Value {
static KNOWN_VAR: OnceLock<serde_yaml_ng::Value> = OnceLock::new();
KNOWN_VAR.get_or_init(|| {
let str = include_str!("../../libs/vars.yml");
serde_yaml::from_str(str).unwrap()
serde_yaml_ng::from_str(str).unwrap()
})
}

Expand Down
10 changes: 5 additions & 5 deletions policies/rudderc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ pub mod action {
if let Some(n) = name {
technique.name = n;
}
let t = serde_yaml::to_string(&technique)?;
let t = serde_yaml_ng::to_string(&technique)?;
let tech_path = output.join(TECHNIQUE_SRC);
let mut file = File::create(tech_path.as_path())
.with_context(|| format!("Failed to create technique file {}", tech_path.display()))?;
Expand Down Expand Up @@ -346,7 +346,7 @@ pub mod action {
.into_owned();
ok_output("Testing", case_path.to_string_lossy());
let yaml = read_to_string(&case_path)?;
let case: TestCase = serde_yaml::from_str(&yaml)?;
let case: TestCase = serde_yaml_ng::from_str(&yaml)?;
// Run test setup
case.setup(test_dir, target_dir)?;
// Run the technique
Expand Down Expand Up @@ -437,7 +437,7 @@ pub mod action {
let src_file = input.with_extension("ids.yml");
let mut file = File::create(&src_file)
.with_context(|| format!("Failed to create output file {}", src_file.display()))?;
file.write_all(serde_yaml::to_string(&policy)?.as_bytes())?;
file.write_all(serde_yaml_ng::to_string(&policy)?.as_bytes())?;
ok_output("Wrote", src_file.display());
}

Expand Down Expand Up @@ -496,8 +496,8 @@ pub mod action {
// We don't need to parse everything, let's just extract what we need
// We use the technique with ids
let technique_src = src.join(TECHNIQUE_SRC).with_extension("ids.yml");
let yml: serde_yaml::Value =
serde_yaml::from_str(&read_to_string(&technique_src).context(format!(
let yml: serde_yaml_ng::Value =
serde_yaml_ng::from_str(&read_to_string(&technique_src).context(format!(
"Could not read source technique {}",
technique_src.display()
))?)?;
Expand Down
4 changes: 2 additions & 2 deletions policies/rudderc/tests/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ use test_generator::test_resources;
fn compile(filename: &str) {
let path = Path::new(filename);
let result: Result<MethodInfo> = read_to_string(path.with_extension("cf")).unwrap().parse();
let reference: MethodInfo = serde_yaml::from_str(&read_to_string(path).unwrap()).unwrap();
let reference: MethodInfo = serde_yaml_ng::from_str(&read_to_string(path).unwrap()).unwrap();

if should_fail(path) {
assert!(result.is_err());
} else {
let parsed = result.unwrap();
println!("{}", serde_yaml::to_string(&parsed).unwrap());
println!("{}", serde_yaml_ng::to_string(&parsed).unwrap());
assert_eq!(reference, parsed)
}
}
Expand Down