files: &[APTRepositoryFile],
) -> Vec<APTStandardRepository> {
let mut result = vec![
- APTStandardRepository {
- handle: APTRepositoryHandle::Enterprise,
- status: None,
- name: APTRepositoryHandle::Enterprise.name(),
- },
- APTStandardRepository {
- handle: APTRepositoryHandle::NoSubscription,
- status: None,
- name: APTRepositoryHandle::NoSubscription.name(),
- },
- APTStandardRepository {
- handle: APTRepositoryHandle::Test,
- status: None,
- name: APTRepositoryHandle::Test.name(),
- },
+ APTStandardRepository::from(APTRepositoryHandle::Enterprise),
+ APTStandardRepository::from(APTRepositoryHandle::NoSubscription),
+ APTStandardRepository::from(APTRepositoryHandle::Test),
];
if product == "pve" {
result.append(&mut vec![
- APTStandardRepository {
- handle: APTRepositoryHandle::CephPacific,
- status: None,
- name: APTRepositoryHandle::CephPacific.name(),
- },
- APTStandardRepository {
- handle: APTRepositoryHandle::CephPacificTest,
- status: None,
- name: APTRepositoryHandle::CephPacificTest.name(),
- },
- APTStandardRepository {
- handle: APTRepositoryHandle::CephOctopus,
- status: None,
- name: APTRepositoryHandle::CephOctopus.name(),
- },
- APTStandardRepository {
- handle: APTRepositoryHandle::CephOctopusTest,
- status: None,
- name: APTRepositoryHandle::CephOctopusTest.name(),
- },
+ APTStandardRepository::from(APTRepositoryHandle::CephPacific),
+ APTStandardRepository::from(APTRepositoryHandle::CephPacificTest),
+ APTStandardRepository::from(APTRepositoryHandle::CephOctopus),
+ APTStandardRepository::from(APTRepositoryHandle::CephOctopusTest),
]);
}
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<bool>,
- /// Full name of the repository.
+ /// Display name of the repository.
pub name: String,
+
+ /// Description of the repository.
+ pub description: String,
}
#[api]
CephOctopusTest,
}
+impl From<APTRepositoryHandle> for APTStandardRepository {
+ fn from(handle: APTRepositoryHandle) -> Self {
+ APTStandardRepository {
+ handle,
+ status: None,
+ name: handle.name(),
+ description: handle.description(),
+ }
+ }
+}
+
impl TryFrom<&str> for APTRepositoryHandle {
type Error = Error;
}
impl APTRepositoryHandle {
- /// Get the full name of the repository.
+ /// Get the description for the repository.
+ pub fn description(self) -> String {
+ match self {
+ APTRepositoryHandle::Enterprise => {
+ "This is the default, stable, and recommended repository, available for all \
+ Proxmox subscription users."
+ }
+ APTRepositoryHandle::NoSubscription => {
+ "This is the recommended repository for testing and non-production use."
+ }
+ APTRepositoryHandle::Test => {
+ "This repository contains the latest packages and is primarily used by developers \
+ to test new features."
+ }
+ APTRepositoryHandle::CephPacific => {
+ "This repository holds the main Proxmox Ceph Pacific packages."
+ }
+ APTRepositoryHandle::CephPacificTest => {
+ "This repository contains the Ceph Pacific packages before they are moved to the \
+ main repository."
+ }
+ APTRepositoryHandle::CephOctopus => {
+ "This repository holds the main Proxmox Ceph Octopus packages."
+ }
+ APTRepositoryHandle::CephOctopusTest => {
+ "This repository contains the Ceph Octopus packages before they are moved to the \
+ main repository."
+ }
+ }
+ .to_string()
+ }
+
+ /// Get the display name of the repository.
pub fn name(self) -> String {
match self {
- APTRepositoryHandle::Enterprise => "Enterprise Repository",
- APTRepositoryHandle::NoSubscription => "No-Subscription Repository",
- APTRepositoryHandle::Test => "Test Repository",
- APTRepositoryHandle::CephPacific => "Ceph Pacific Repository",
- APTRepositoryHandle::CephPacificTest => "Ceph Pacific Test Repository",
- APTRepositoryHandle::CephOctopus => "Ceph Octopus Repository",
- APTRepositoryHandle::CephOctopusTest => "Ceph Octopus Test Repository",
+ APTRepositoryHandle::Enterprise => "Enterprise",
+ APTRepositoryHandle::NoSubscription => "No-Subscription",
+ APTRepositoryHandle::Test => "Test",
+ APTRepositoryHandle::CephPacific => "Ceph Pacific",
+ APTRepositoryHandle::CephPacificTest => "Ceph Pacific Test",
+ APTRepositoryHandle::CephOctopus => "Ceph Octopus",
+ APTRepositoryHandle::CephOctopusTest => "Ceph Octopus Test",
}
.to_string()
}
let read_dir = test_dir.join("sources.list.d");
let mut expected = vec![
- APTStandardRepository {
- handle: APTRepositoryHandle::Enterprise,
- status: None,
- name: APTRepositoryHandle::Enterprise.name(),
- },
- APTStandardRepository {
- handle: APTRepositoryHandle::NoSubscription,
- status: None,
- name: APTRepositoryHandle::NoSubscription.name(),
- },
- APTStandardRepository {
- handle: APTRepositoryHandle::Test,
- status: None,
- name: APTRepositoryHandle::Test.name(),
- },
- APTStandardRepository {
- handle: APTRepositoryHandle::CephPacific,
- status: None,
- name: APTRepositoryHandle::CephPacific.name(),
- },
- APTStandardRepository {
- handle: APTRepositoryHandle::CephPacificTest,
- status: None,
- name: APTRepositoryHandle::CephPacificTest.name(),
- },
- APTStandardRepository {
- handle: APTRepositoryHandle::CephOctopus,
- status: None,
- name: APTRepositoryHandle::CephOctopus.name(),
- },
- APTStandardRepository {
- handle: APTRepositoryHandle::CephOctopusTest,
- status: None,
- name: APTRepositoryHandle::CephOctopusTest.name(),
- },
+ APTStandardRepository::from(APTRepositoryHandle::Enterprise),
+ APTStandardRepository::from(APTRepositoryHandle::NoSubscription),
+ APTStandardRepository::from(APTRepositoryHandle::Test),
+ APTStandardRepository::from(APTRepositoryHandle::CephPacific),
+ APTStandardRepository::from(APTRepositoryHandle::CephPacificTest),
+ APTStandardRepository::from(APTRepositoryHandle::CephOctopus),
+ APTStandardRepository::from(APTRepositoryHandle::CephOctopusTest),
];
let absolute_suite_list = read_dir.join("absolute_suite.list");