Bugfix/compat auto config (#812)

* account for no dependent config when auto configuring

* fix config path

* add check for config file to dependency check command
This commit is contained in:
Lucy C
2021-11-18 14:18:12 -07:00
committed by Aiden McClelland
parent 1d1844e092
commit 018b7e972c
2 changed files with 26 additions and 17 deletions

View File

@@ -201,18 +201,19 @@ fn inner_main() -> Result<(), anyhow::Error> {
("dependency", Some(sub_m)) => match sub_m.subcommand() {
("check", Some(sub_m)) => {
let parent_config = serde_yaml::from_reader(stdin())?;
let config = serde_yaml::from_reader(
File::open(
Path::new(sub_m.value_of("mountpoint").unwrap()).join("start9/config.yaml"),
)
.unwrap(),
)?;
let cfg_path =
Path::new(sub_m.value_of("mountpoint").unwrap()).join("start9/config.yaml");
let config = if cfg_path.exists() {
Some(serde_yaml::from_reader(File::open(cfg_path).unwrap()).unwrap())
} else {
None
};
let rules_path = Path::new(sub_m.value_of("assets").unwrap());
let name = sub_m.value_of("dependent_package_id").unwrap();
let parent_name = sub_m.value_of("dependency_package_id").unwrap();
match validate_dependency_configuration(
name,
config,
&config,
parent_name,
parent_config,
rules_path,
@@ -229,12 +230,13 @@ fn inner_main() -> Result<(), anyhow::Error> {
}
("auto-configure", Some(sub_m)) => {
let dep_config = serde_yaml::from_reader(stdin())?;
let config = serde_yaml::from_reader(
File::open(
Path::new(sub_m.value_of("mountpoint").unwrap()).join("start9/config.yaml"),
)
.unwrap(),
)?;
let cfg_path =
Path::new(sub_m.value_of("mountpoint").unwrap()).join("start9/config.yaml");
let config = if cfg_path.exists() {
Some(serde_yaml::from_reader(File::open(cfg_path).unwrap()).unwrap())
} else {
None
};
let rules_path = Path::new(sub_m.value_of("assets").unwrap());
let package_id = sub_m.value_of("dependent_package_id").unwrap();
let dependency_id = sub_m.value_of("dependency_package_id").unwrap();