all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH proxmox-apt 3/5] check repos: have caller specify the current suite
Date: Thu, 29 Jul 2021 14:25:50 +0200	[thread overview]
Message-ID: <20210729122554.148980-4-f.ebner@proxmox.com> (raw)
In-Reply-To: <20210729122554.148980-1-f.ebner@proxmox.com>

Like that, a potential error is further up the stack, and it's more
consistent with what the standard_repository functions do.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
 src/repositories/file.rs | 6 ++----
 src/repositories/mod.rs  | 7 +++++--
 tests/repositories.rs    | 6 +++---
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/src/repositories/file.rs b/src/repositories/file.rs
index 49cc358..254af4d 100644
--- a/src/repositories/file.rs
+++ b/src/repositories/file.rs
@@ -5,7 +5,7 @@ use std::path::{Path, PathBuf};
 use anyhow::{bail, format_err, Error};
 use serde::{Deserialize, Serialize};
 
-use crate::repositories::release::{get_current_release_codename, DEBIAN_SUITES};
+use crate::repositories::release::DEBIAN_SUITES;
 use crate::repositories::repository::{
     APTRepository, APTRepositoryFileType, APTRepositoryPackageType,
 };
@@ -300,7 +300,7 @@ impl APTRepositoryFile {
 
     /// Checks if old or unstable suites are configured and also that the
     /// `stable` keyword is not used.
-    pub fn check_suites(&self) -> Result<Vec<APTRepositoryInfo>, Error> {
+    pub fn check_suites(&self, current_suite: &str) -> Result<Vec<APTRepositoryInfo>, Error> {
         let mut infos = vec![];
 
         for (n, repo) in self.repositories.iter().enumerate() {
@@ -318,8 +318,6 @@ impl APTRepositoryFile {
                 })
             };
 
-            let current_suite = get_current_release_codename()?;
-
             let current_index = match DEBIAN_SUITES
                 .iter()
                 .position(|&suite| suite == current_suite)
diff --git a/src/repositories/mod.rs b/src/repositories/mod.rs
index 8637851..8f5500e 100644
--- a/src/repositories/mod.rs
+++ b/src/repositories/mod.rs
@@ -49,11 +49,14 @@ fn common_digest(files: &[APTRepositoryFile]) -> [u8; 32] {
 /// `warnings` for bad suites.
 /// `ignore-pre-upgrade-warning` when the next stable suite is configured.
 /// `badge` for official URIs.
-pub fn check_repositories(files: &[APTRepositoryFile]) -> Result<Vec<APTRepositoryInfo>, Error> {
+pub fn check_repositories(
+    files: &[APTRepositoryFile],
+    current_suite: &str,
+) -> Result<Vec<APTRepositoryInfo>, Error> {
     let mut infos = vec![];
 
     for file in files.iter() {
-        infos.append(&mut file.check_suites()?);
+        infos.append(&mut file.check_suites(current_suite)?);
         infos.append(&mut file.check_uris());
     }
 
diff --git a/tests/repositories.rs b/tests/repositories.rs
index 4cbde60..a9a7b96 100644
--- a/tests/repositories.rs
+++ b/tests/repositories.rs
@@ -187,7 +187,7 @@ fn test_check_repositories() -> Result<(), Error> {
     let mut file = APTRepositoryFile::new(&absolute_suite_list)?.unwrap();
     file.parse()?;
 
-    let infos = check_repositories(&vec![file])?;
+    let infos = check_repositories(&vec![file], "bullseye")?;
 
     assert_eq!(infos.is_empty(), true);
     let pve_list = read_dir.join("pve.list");
@@ -212,7 +212,7 @@ fn test_check_repositories() -> Result<(), Error> {
     }
     expected_infos.sort();
 
-    let mut infos = check_repositories(&vec![file])?;
+    let mut infos = check_repositories(&vec![file], "bullseye")?;
     infos.sort();
 
     assert_eq!(infos, expected_infos);
@@ -278,7 +278,7 @@ fn test_check_repositories() -> Result<(), Error> {
     }
     expected_infos.sort();
 
-    let mut infos = check_repositories(&vec![file])?;
+    let mut infos = check_repositories(&vec![file], "bullseye")?;
     infos.sort();
 
     assert_eq!(infos, expected_infos);
-- 
2.30.2





  parent reply	other threads:[~2021-07-29 12:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-29 12:25 [pve-devel] [PATCH-SERIES proxmox-apt/pve-rs] better detection of standard repositories Fabian Ebner
2021-07-29 12:25 ` [pve-devel] [PATCH proxmox-apt 1/5] standard repos: add suite parameter for stricter detection Fabian Ebner
2021-07-29 12:25 ` [pve-devel] [PATCH proxmox-apt 2/5] repo: make suite_variant helper more general Fabian Ebner
2021-07-29 12:25 ` Fabian Ebner [this message]
2021-07-29 12:25 ` [pve-devel] [PATCH proxmox-apt 4/5] repo: remove has_suite_variant helper Fabian Ebner
2021-07-29 12:25 ` [pve-devel] [PATCH proxmox-apt 5/5] add type DebianCodename Fabian Ebner
2021-07-29 12:25 ` [pve-devel] [PATCH pve-rs 1/2] apt: repos: adapt to back-end changes Fabian Ebner
2021-07-29 12:25 ` [pve-devel] [PATCH pve-rs 2/2] apt: repos: adapt to further " Fabian Ebner
2021-07-30  8:47 ` [pve-devel] applied-series: Re: [PATCH-SERIES proxmox-apt/pve-rs] better detection of standard repositories Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210729122554.148980-4-f.ebner@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal