Merge pull request #2758 from cgwalters/treefile-validate-repos

compose: Move repos/lockfile-repos validation to Rust
This commit is contained in:
Jonathan Lebon 2021-04-19 11:43:21 -04:00 committed by GitHub
commit 2ad8543b3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 6 deletions

View File

@ -612,6 +612,11 @@ impl Treefile {
}
}
}
if config.repos.is_none() && config.lockfile_repos.is_none() {
return Err(anyhow!(
r#"Treefile has neither "repos" nor "lockfile-repos""#
));
}
if let Some(version_suffix) = config.automatic_version_suffix.as_ref() {
if !(version_suffix.len() == 1 && version_suffix.is_ascii()) {
return Err(io::Error::new(
@ -1235,6 +1240,8 @@ pub(crate) mod tests {
pub(crate) static VALID_PRELUDE: &str = indoc! {r#"
ref: "exampleos/x86_64/blah"
repos:
- baserepo
packages:
- foo bar
- baz
@ -1485,6 +1492,8 @@ pub(crate) mod tests {
"foo.yaml",
0o644,
indoc! {"
repos:
- foo
packages:
- fooinclude
"},
@ -1506,6 +1515,8 @@ pub(crate) mod tests {
"foo-x86_64.yaml",
0o644,
r#"
repos:
- foo
packages:
- foo-x86_64-include
"#,

View File

@ -185,12 +185,6 @@ rpmostree_composeutil_get_treespec (RpmOstreeContext *ctx,
return NULL;
if (!treespec_bind_array (treedata, treespec, "lockfile-repos", NULL, FALSE, error))
return NULL;
/* at least one of `repos` and `lockfile-repos` should be defined */
if (!json_object_has_member (treedata, "repos") &&
!json_object_has_member (treedata, "lockfile-repos"))
return (RpmOstreeTreespec*)glnx_null_throw (error, "Treefile has neither \"repos\" nor \"lockfile-repos\" members");
if (!treespec_bind_array (treedata, treespec, "install-langs", "instlangs", FALSE, error))
return NULL;