libs: bump toml 0.5.8 → 1.1.2

Migrate kata-types and kata-agent from toml 0.5 to 1.x:

- Consolidate kata-types onto the workspace toml version
- Replace toml::to_vec() (removed in 1.x) with to_string().into_bytes()
- Map toml::de::Error with .map_err(std::io::Error::other) where functions
  return io::Result (From impl was removed in 1.x)
- Update test assertions: toml 1.x serializes strings with double quotes
  instead of single quotes

Generated-by: IBM Bob
Signed-off-by: stevenhorsman <steven@uk.ibm.com>
This commit is contained in:
stevenhorsman
2026-07-01 08:25:53 -07:00
parent 320decbcd6
commit b2c91136a1
6 changed files with 47 additions and 15 deletions

38
Cargo.lock generated
View File

@@ -3539,7 +3539,7 @@ dependencies = [
"thiserror 2.0.18",
"tokio",
"tokio-vsock 0.3.4",
"toml",
"toml 1.1.2+spec-1.1.0",
"tracing",
"tracing-opentelemetry 0.17.4",
"tracing-subscriber",
@@ -3640,7 +3640,7 @@ dependencies = [
"test-utils",
"thiserror 2.0.18",
"tokio",
"toml",
"toml 1.1.2+spec-1.1.0",
"url",
"virt_container",
"vmm-sys-util 0.15.0",
@@ -3766,7 +3766,7 @@ dependencies = [
"test-utils",
"thiserror 2.0.18",
"tokio",
"toml",
"toml 1.1.2+spec-1.1.0",
]
[[package]]
@@ -4634,7 +4634,7 @@ dependencies = [
"serde",
"serde_json",
"thiserror 1.0.69",
"toml",
"toml 0.5.11",
]
[[package]]
@@ -7105,6 +7105,15 @@ dependencies = [
"syn 2.0.117",
]
[[package]]
name = "serde_spanned"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6662b5879511e06e8999a8a235d848113e942c9124f211511b16466ee2995f26"
dependencies = [
"serde_core",
]
[[package]]
name = "serde_urlencoded"
version = "0.7.1"
@@ -8083,6 +8092,21 @@ dependencies = [
"serde",
]
[[package]]
name = "toml"
version = "1.1.2+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81f3d15e84cbcd896376e6730314d59fb5a87f31e4b038454184435cd57defee"
dependencies = [
"indexmap 2.14.0",
"serde_core",
"serde_spanned",
"toml_datetime 1.1.1+spec-1.1.0",
"toml_parser",
"toml_writer",
"winnow 1.0.2",
]
[[package]]
name = "toml_datetime"
version = "0.6.11"
@@ -8148,6 +8172,12 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801"
[[package]]
name = "toml_writer"
version = "1.1.1+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "756daf9b1013ebe47a8776667b466417e2d4c5679d441c26230efd9ef78692db"
[[package]]
name = "tonic"
version = "0.9.2"

View File

@@ -206,7 +206,7 @@ thiserror = "2.0.18"
tokio = "1.46.1"
tokio-util = "0.7.17"
tokio-vsock = "0.3.4"
toml = "0.5.8"
toml = "1.1.2"
tracing = "0.1.44"
tracing-opentelemetry = "0.18.0"
tracing-subscriber = "0.3.20"

View File

@@ -24,7 +24,7 @@ slog = "2.5.2"
slog-scope = "4.4.0"
serde_json = "1.0.73"
thiserror = { workspace = true }
toml = "0.5.8"
toml = { workspace = true }
serde-enum-str = "0.5"
sysinfo = "0.34.2"
sha2 = "0.10.8"

View File

@@ -240,7 +240,8 @@ mod drop_in_directory_handling {
));
}
let dropin_contents = fs::read_to_string(dropin_file.path())?;
let dropin_config: toml::Value = toml::from_str(&dropin_contents)?;
let dropin_config: toml::Value =
toml::from_str(&dropin_contents).map_err(std::io::Error::other)?;
super::toml_tree_ops::merge(base_config, dropin_config);
Ok(())
}
@@ -267,12 +268,13 @@ mod drop_in_directory_handling {
pub fn load(base_cfg_file_path: &Path) -> Result<TomlConfig> {
let base_toml_str = fs::read_to_string(base_cfg_file_path)?;
let mut base_config: toml::Value = toml::from_str(&base_toml_str)?;
let mut base_config: toml::Value =
toml::from_str(&base_toml_str).map_err(std::io::Error::other)?;
let dropin_dir = get_dropin_dir_path(base_cfg_file_path)?;
update_from_dropins(&mut base_config, &dropin_dir)?;
let config: TomlConfig = base_config.try_into()?;
let config: TomlConfig = base_config.try_into().map_err(std::io::Error::other)?;
Ok(config)
}

View File

@@ -179,7 +179,7 @@ impl TomlConfig {
/// This function only works with `configuration.toml` and does not handle
/// drop-in config file fragments in config.d/.
pub fn load(content: &str) -> Result<TomlConfig> {
let mut config: TomlConfig = toml::from_str(content)?;
let mut config: TomlConfig = toml::from_str(content).map_err(std::io::Error::other)?;
config.adjust_config()?;
info!(sl!(), "get kata config: {:?}", config);
Ok(config)

View File

@@ -93,7 +93,7 @@ impl InitData {
/// serialize it to Vec<u8>
pub fn to_vec(&self) -> Result<Vec<u8>> {
Ok(toml::to_vec(&self)?)
Ok(toml::to_string(&self)?.into_bytes())
}
/// serialize config to TOML string
@@ -411,8 +411,8 @@ key = "value"
// Test TOML serialization
let toml_str = init_data.to_string().unwrap();
assert!(toml_str.contains("initdata_key = 'initdata_value'\n"));
assert!(toml_str.starts_with("version = '0.1.0'"));
assert!(toml_str.contains("initdata_key = \"initdata_value\"\n"));
assert!(toml_str.starts_with("version = \"0.1.0\""));
}
/// Test calculate_digest with different algorithms
@@ -481,8 +481,8 @@ key = "value"
// Test processing
let result = add_hypervisor_initdata_overrides(&b64_annotation).unwrap();
assert!(result.contains("hypervisor_key = 'config_value'\n"));
assert!(result.contains("algorithm = 'sha512'\n"));
assert!(result.contains("hypervisor_key = \"config_value\"\n"));
assert!(result.contains("algorithm = \"sha512\"\n"));
}
/// Test input validation