| 1002 | } |
| 1003 | |
| 1004 | fn parse_promotion_config(path: &Path) -> Result<BTreeMap<String, PromotionRequest>> { |
| 1005 | if !path.exists() { |
| 1006 | return Ok(BTreeMap::new()); |
| 1007 | } |
| 1008 | let text = fs::read_to_string(path).with_context(|| format!("read {}", path.display()))?; |
| 1009 | let config: PromotionConfig = |
| 1010 | toml::from_str(&text).with_context(|| format!("parse {}", path.display()))?; |
| 1011 | ensure!( |
| 1012 | config.format_version == 1, |
| 1013 | "{} format_version must be 1", |
| 1014 | path.display() |
| 1015 | ); |
| 1016 | let mut requests = BTreeMap::new(); |
| 1017 | for request in config.extensions { |
| 1018 | ensure!(!request.id.is_empty(), "promotion request has empty id"); |
| 1019 | ensure!( |
| 1020 | requests.insert(request.id.clone(), request).is_none(), |
| 1021 | "duplicate promotion request" |
| 1022 | ); |
| 1023 | } |
| 1024 | Ok(requests) |
| 1025 | } |
| 1026 | |
| 1027 | fn parse_smoke_config(path: &Path) -> Result<BTreeMap<String, ExtensionSmokeEvidence>> { |
| 1028 | if !path.exists() { |