From 1e47036528bb06c06b63485c89e09820ee4badbc Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Mon, 4 Sep 2023 17:14:19 +0200 Subject: [PATCH] apt: add Ceph Reef to standard repo list For now just duplicate the Ceph Quincy entries, as I want to avoid using macros and we do not yet have support for enums inside enums with the api macro. Adapt and expand the tests slightly to have at least some simple coverage there too. Signed-off-by: Thomas Lamprecht --- proxmox-apt/src/repositories/mod.rs | 7 +++ proxmox-apt/src/repositories/standard.rs | 49 ++++++++++++++++++- proxmox-apt/tests/repositories.rs | 33 ++++++++++++- .../ceph-reef-enterprise-bookworm.list | 2 + .../ceph-reef-enterprise-bookworm.list | 2 + 5 files changed, 90 insertions(+), 3 deletions(-) create mode 100644 proxmox-apt/tests/sources.list.d.expected/ceph-reef-enterprise-bookworm.list create mode 100644 proxmox-apt/tests/sources.list.d/ceph-reef-enterprise-bookworm.list diff --git a/proxmox-apt/src/repositories/mod.rs b/proxmox-apt/src/repositories/mod.rs index 45adc85f..7bfe9cae 100644 --- a/proxmox-apt/src/repositories/mod.rs +++ b/proxmox-apt/src/repositories/mod.rs @@ -94,6 +94,13 @@ pub fn standard_repositories( APTStandardRepository::from(APTRepositoryHandle::CephQuincyNoSubscription), APTStandardRepository::from(APTRepositoryHandle::CephQuincyTest), ]); + if suite == DebianCodename::Bookworm { + result.append(&mut vec![ + APTStandardRepository::from(APTRepositoryHandle::CephReefEnterprise), + APTStandardRepository::from(APTRepositoryHandle::CephReefNoSubscription), + APTStandardRepository::from(APTRepositoryHandle::CephReefTest), + ]); + } } for file in files.iter() { diff --git a/proxmox-apt/src/repositories/standard.rs b/proxmox-apt/src/repositories/standard.rs index d998357d..5224e2f8 100644 --- a/proxmox-apt/src/repositories/standard.rs +++ b/proxmox-apt/src/repositories/standard.rs @@ -52,6 +52,14 @@ pub enum APTRepositoryHandle { CephQuincyNoSubscription, /// Ceph Quincy test repository. CephQuincyTest, + // TODO: Add separate enum for ceph releases and use something like + // `CephTest(CephReleaseCodename),` once the API macro supports it. + /// Ceph Reef enterprise repository. + CephReefEnterprise, + /// Ceph Reef no-subscription repository. + CephReefNoSubscription, + /// Ceph Reef test repository. + CephReefTest, } impl From for APTStandardRepository { @@ -76,6 +84,9 @@ impl TryFrom<&str> for APTRepositoryHandle { "ceph-quincy-enterprise" => Ok(APTRepositoryHandle::CephQuincyEnterprise), "ceph-quincy-no-subscription" => Ok(APTRepositoryHandle::CephQuincyNoSubscription), "ceph-quincy-test" => Ok(APTRepositoryHandle::CephQuincyTest), + "ceph-reef-enterprise" => Ok(APTRepositoryHandle::CephReefEnterprise), + "ceph-reef-no-subscription" => Ok(APTRepositoryHandle::CephReefNoSubscription), + "ceph-reef-test" => Ok(APTRepositoryHandle::CephReefTest), _ => bail!("unknown repository handle '{}'", string), } } @@ -92,6 +103,9 @@ impl Display for APTRepositoryHandle { write!(f, "ceph-quincy-no-subscription") } APTRepositoryHandle::CephQuincyTest => write!(f, "ceph-quincy-test"), + APTRepositoryHandle::CephReefEnterprise => write!(f, "ceph-reef-enterprise"), + APTRepositoryHandle::CephReefNoSubscription => write!(f, "ceph-reef-no-subscription"), + APTRepositoryHandle::CephReefTest => write!(f, "ceph-reef-test"), } } } @@ -125,6 +139,18 @@ impl APTRepositoryHandle { "This repository contains the Ceph Quincy packages before they are moved to the \ main repository." } + APTRepositoryHandle::CephReefEnterprise => { + "This repository holds the production-ready Proxmox Ceph Reef packages." + } + APTRepositoryHandle::CephReefNoSubscription => { + "This repository holds the Proxmox Ceph Reef packages intended for \ + non-production use. The deprecated 'main' repository is an alias for this in \ + Proxmox VE 8." + } + APTRepositoryHandle::CephReefTest => { + "This repository contains the Ceph Reef packages before they are moved to the \ + main repository." + } } .to_string() } @@ -138,6 +164,9 @@ impl APTRepositoryHandle { APTRepositoryHandle::CephQuincyEnterprise => "Ceph Quincy Enterprise", APTRepositoryHandle::CephQuincyNoSubscription => "Ceph Quincy No-Subscription", APTRepositoryHandle::CephQuincyTest => "Ceph Quincy Test", + APTRepositoryHandle::CephReefEnterprise => "Ceph Reef Enterprise", + APTRepositoryHandle::CephReefNoSubscription => "Ceph Reef No-Subscription", + APTRepositoryHandle::CephReefTest => "Ceph Reef Test", } .to_string() } @@ -152,7 +181,10 @@ impl APTRepositoryHandle { APTRepositoryHandle::Test => "/etc/apt/sources.list".to_string(), APTRepositoryHandle::CephQuincyEnterprise | APTRepositoryHandle::CephQuincyNoSubscription - | APTRepositoryHandle::CephQuincyTest => "/etc/apt/sources.list.d/ceph.list".to_string(), + | APTRepositoryHandle::CephQuincyTest + | APTRepositoryHandle::CephReefEnterprise + | APTRepositoryHandle::CephReefNoSubscription + | APTRepositoryHandle::CephReefTest => "/etc/apt/sources.list.d/ceph.list".to_string(), } } @@ -209,6 +241,21 @@ impl APTRepositoryHandle { vec!["http://download.proxmox.com/debian/ceph-quincy".to_string()], "test".to_string(), ), + APTRepositoryHandle::CephReefEnterprise => ( + APTRepositoryPackageType::Deb, + vec!["https://enterprise.proxmox.com/debian/ceph-reef".to_string()], + "enterprise".to_string(), + ), + APTRepositoryHandle::CephReefNoSubscription => ( + APTRepositoryPackageType::Deb, + vec!["http://download.proxmox.com/debian/ceph-reef".to_string()], + "no-subscription".to_string(), + ), + APTRepositoryHandle::CephReefTest => ( + APTRepositoryPackageType::Deb, + vec!["http://download.proxmox.com/debian/ceph-reef".to_string()], + "test".to_string(), + ), } } diff --git a/proxmox-apt/tests/repositories.rs b/proxmox-apt/tests/repositories.rs index 7ed2f110..3225e73d 100644 --- a/proxmox-apt/tests/repositories.rs +++ b/proxmox-apt/tests/repositories.rs @@ -361,6 +361,9 @@ fn test_standard_repositories() -> Result<(), Error> { APTStandardRepository::from(APTRepositoryHandle::CephQuincyEnterprise), APTStandardRepository::from(APTRepositoryHandle::CephQuincyNoSubscription), APTStandardRepository::from(APTRepositoryHandle::CephQuincyTest), + APTStandardRepository::from(APTRepositoryHandle::CephReefEnterprise), + APTStandardRepository::from(APTRepositoryHandle::CephReefNoSubscription), + APTStandardRepository::from(APTRepositoryHandle::CephReefTest), ]; let absolute_suite_list = read_dir.join("absolute_suite.list"); @@ -369,6 +372,14 @@ fn test_standard_repositories() -> Result<(), Error> { let std_repos = standard_repositories(&[file], "pve", DebianCodename::Bullseye); + assert_eq!(std_repos, &expected[0..=5]); + + let absolute_suite_list = read_dir.join("absolute_suite.list"); + let mut file = APTRepositoryFile::new(&absolute_suite_list)?.unwrap(); + file.parse()?; + + let std_repos = standard_repositories(&[file], "pve", DebianCodename::Bookworm); + assert_eq!(std_repos, expected); let pve_list = read_dir.join("pve.list"); @@ -386,7 +397,7 @@ fn test_standard_repositories() -> Result<(), Error> { let std_repos = standard_repositories(&file_vec, "pve", DebianCodename::Bullseye); - assert_eq!(std_repos, expected); + assert_eq!(std_repos, &expected[0..=5]); let pve_alt_list = read_dir.join("pve-alt.list"); let mut file = APTRepositoryFile::new(&pve_alt_list)?.unwrap(); @@ -398,7 +409,7 @@ fn test_standard_repositories() -> Result<(), Error> { let std_repos = standard_repositories(&[file], "pve", DebianCodename::Bullseye); - assert_eq!(std_repos, expected); + assert_eq!(std_repos, &expected[0..=5]); let pve_alt_list = read_dir.join("ceph-quincy-bookworm.list"); let mut file = APTRepositoryFile::new(&pve_alt_list)?.unwrap(); @@ -430,6 +441,24 @@ fn test_standard_repositories() -> Result<(), Error> { assert_eq!(std_repos, expected); + let pve_alt_list = read_dir.join("ceph-reef-enterprise-bookworm.list"); + let mut file = APTRepositoryFile::new(&pve_alt_list)?.unwrap(); + file.parse()?; + + expected[0].status = None; + expected[1].status = None; + expected[2].status = None; + expected[3].status = None; + expected[4].status = None; + expected[5].status = None; + expected[6].status = Some(true); + expected[7].status = None; + expected[8].status = None; + + let std_repos = standard_repositories(&[file], "pve", DebianCodename::Bookworm); + + assert_eq!(std_repos, expected); + Ok(()) } diff --git a/proxmox-apt/tests/sources.list.d.expected/ceph-reef-enterprise-bookworm.list b/proxmox-apt/tests/sources.list.d.expected/ceph-reef-enterprise-bookworm.list new file mode 100644 index 00000000..1d370300 --- /dev/null +++ b/proxmox-apt/tests/sources.list.d.expected/ceph-reef-enterprise-bookworm.list @@ -0,0 +1,2 @@ +deb https://enterprise.proxmox.com/debian/ceph-reef bookworm enterprise + diff --git a/proxmox-apt/tests/sources.list.d/ceph-reef-enterprise-bookworm.list b/proxmox-apt/tests/sources.list.d/ceph-reef-enterprise-bookworm.list new file mode 100644 index 00000000..1d370300 --- /dev/null +++ b/proxmox-apt/tests/sources.list.d/ceph-reef-enterprise-bookworm.list @@ -0,0 +1,2 @@ +deb https://enterprise.proxmox.com/debian/ceph-reef bookworm enterprise +