forked from proxmox-mirrors/proxmox
switch to new schema verify methods
the deprecated ones only forward to the new ones anyway.. Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
parent
2d9fbc02ab
commit
d363fb2bee
@ -23,7 +23,7 @@ rustyline = { version = "7", optional = true }
|
|||||||
libc = { version = "0.2", optional = true }
|
libc = { version = "0.2", optional = true }
|
||||||
|
|
||||||
proxmox-lang = { path = "../proxmox-lang", version = "1.0" }
|
proxmox-lang = { path = "../proxmox-lang", version = "1.0" }
|
||||||
proxmox-schema = { path = "../proxmox-schema", version = "1.0" }
|
proxmox-schema = { path = "../proxmox-schema", version = "1.1" }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = [ "cli" ]
|
default = [ "cli" ]
|
||||||
|
@ -192,7 +192,7 @@ pub fn parse_arguments<T: AsRef<str>>(
|
|||||||
data.push((name.to_string(), value.to_string()));
|
data.push((name.to_string(), value.to_string()));
|
||||||
}
|
}
|
||||||
|
|
||||||
let options = parse_parameter_strings(&data, schema, true)?;
|
let options = schema.parse_parameter_strings(&data, true)?;
|
||||||
|
|
||||||
Ok((options, remaining))
|
Ok((options, remaining))
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,6 @@ hex = "0.4"
|
|||||||
serde = "1.0"
|
serde = "1.0"
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
|
|
||||||
proxmox-schema = { path = "../proxmox-schema", version = "1.0.0" }
|
proxmox-schema = { path = "../proxmox-schema", version = "1.1" }
|
||||||
# FIXME: remove!
|
# FIXME: remove!
|
||||||
proxmox-lang = { path = "../proxmox-lang", version = "1.0.0" }
|
proxmox-lang = { path = "../proxmox-lang", version = "1.0.0" }
|
||||||
|
@ -325,13 +325,13 @@ impl SectionConfig {
|
|||||||
let plugin = self.plugins.get(type_name).unwrap();
|
let plugin = self.plugins.get(type_name).unwrap();
|
||||||
|
|
||||||
let id_schema = plugin.get_id_schema().unwrap_or(self.id_schema);
|
let id_schema = plugin.get_id_schema().unwrap_or(self.id_schema);
|
||||||
if let Err(err) = parse_simple_value(section_id, id_schema) {
|
if let Err(err) = id_schema.parse_simple_value(section_id) {
|
||||||
bail!("syntax error in section identifier: {}", err.to_string());
|
bail!("syntax error in section identifier: {}", err.to_string());
|
||||||
}
|
}
|
||||||
if section_id.chars().any(|c| c.is_control()) {
|
if section_id.chars().any(|c| c.is_control()) {
|
||||||
bail!("detected unexpected control character in section ID.");
|
bail!("detected unexpected control character in section ID.");
|
||||||
}
|
}
|
||||||
if let Err(err) = verify_json_object(section_config, plugin.properties) {
|
if let Err(err) = plugin.properties.verify_json(section_config) {
|
||||||
bail!("verify section '{}' failed - {}", section_id, err);
|
bail!("verify section '{}' failed - {}", section_id, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -405,7 +405,7 @@ impl SectionConfig {
|
|||||||
if let Some(plugin) = self.plugins.get(§ion_type) {
|
if let Some(plugin) = self.plugins.get(§ion_type) {
|
||||||
let id_schema =
|
let id_schema =
|
||||||
plugin.get_id_schema().unwrap_or(self.id_schema);
|
plugin.get_id_schema().unwrap_or(self.id_schema);
|
||||||
if let Err(err) = parse_simple_value(§ion_id, id_schema) {
|
if let Err(err) = id_schema.parse_simple_value(§ion_id) {
|
||||||
bail!(
|
bail!(
|
||||||
"syntax error in section identifier: {}",
|
"syntax error in section identifier: {}",
|
||||||
err.to_string()
|
err.to_string()
|
||||||
@ -449,7 +449,7 @@ impl SectionConfig {
|
|||||||
None => bail!("unknown property '{}'", key),
|
None => bail!("unknown property '{}'", key),
|
||||||
};
|
};
|
||||||
|
|
||||||
let value = match parse_simple_value(&value, prop_schema) {
|
let value = match prop_schema.parse_simple_value(&value) {
|
||||||
Ok(value) => value,
|
Ok(value) => value,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
bail!("property '{}': {}", key, err.to_string());
|
bail!("property '{}': {}", key, err.to_string());
|
||||||
|
Loading…
Reference in New Issue
Block a user