From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pdm-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9])
	by lore.proxmox.com (Postfix) with ESMTPS id E6D501FF15C
	for <inbox@lore.proxmox.com>; Fri, 16 May 2025 15:35:53 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id C0E46D8B3;
	Fri, 16 May 2025 15:36:14 +0200 (CEST)
From: Dominik Csapak <d.csapak@proxmox.com>
To: pdm-devel@lists.proxmox.com
Date: Fri, 16 May 2025 15:35:52 +0200
Message-Id: <20250516133611.3499075-3-d.csapak@proxmox.com>
X-Mailer: git-send-email 2.39.5
In-Reply-To: <20250516133611.3499075-1-d.csapak@proxmox.com>
References: <20250516133611.3499075-1-d.csapak@proxmox.com>
MIME-Version: 1.0
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.021 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DMARC_MISSING             0.1 Missing DMARC policy
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See
 http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more
 information. [connection.rs, remotes.rs]
Subject: [pdm-devel] [PATCH datacenter-manager 02/21] api types: RemoteType:
 put default port info to the type
X-BeenThere: pdm-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox Datacenter Manager development discussion
 <pdm-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pdm-devel>, 
 <mailto:pdm-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pdm-devel/>
List-Post: <mailto:pdm-devel@lists.proxmox.com>
List-Help: <mailto:pdm-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel>, 
 <mailto:pdm-devel-request@lists.proxmox.com?subject=subscribe>
Reply-To: Proxmox Datacenter Manager development discussion
 <pdm-devel@lists.proxmox.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: pdm-devel-bounces@lists.proxmox.com
Sender: "pdm-devel" <pdm-devel-bounces@lists.proxmox.com>

so we can access that info from a central point instead of having to
duplicate it

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 lib/pdm-api-types/src/remotes.rs | 9 +++++++++
 server/src/connection.rs         | 8 ++++----
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/lib/pdm-api-types/src/remotes.rs b/lib/pdm-api-types/src/remotes.rs
index 65d1081..dca2fa0 100644
--- a/lib/pdm-api-types/src/remotes.rs
+++ b/lib/pdm-api-types/src/remotes.rs
@@ -48,6 +48,15 @@ pub enum RemoteType {
     Pbs,
 }
 
+impl RemoteType {
+    pub fn default_port(&self) -> u16 {
+        match self {
+            RemoteType::Pve => 8006,
+            RemoteType::Pbs => 8007,
+        }
+    }
+}
+
 serde_plain::derive_display_from_serialize!(RemoteType);
 serde_plain::derive_fromstr_from_deserialize!(RemoteType);
 
diff --git a/server/src/connection.rs b/server/src/connection.rs
index 201d65b..0be9033 100644
--- a/server/src/connection.rs
+++ b/server/src/connection.rs
@@ -36,16 +36,16 @@ struct ConnectInfo {
 
 impl ConnectInfo {
     fn for_remote(remote: &Remote) -> Self {
-        let (default_port, prefix, perl_compat, pve_compat) = match remote.ty {
-            RemoteType::Pve => (8006, "PVEAPIToken".to_string(), true, true),
-            RemoteType::Pbs => (8007, "PBSAPIToken".to_string(), false, false),
+        let (prefix, perl_compat, pve_compat) = match remote.ty {
+            RemoteType::Pve => ("PVEAPIToken".to_string(), true, true),
+            RemoteType::Pbs => ("PBSAPIToken".to_string(), false, false),
         };
 
         ConnectInfo {
             prefix,
             perl_compat,
             pve_compat,
-            default_port,
+            default_port: remote.ty.default_port(),
         }
     }
 }
-- 
2.39.5



_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel