all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Christian Ebner <c.ebner@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox 1/1] s3 client: split config api type into 3 config structs
Date: Tue, 22 Jul 2025 18:36:01 +0200	[thread overview]
Message-ID: <20250722163603.1520687-2-c.ebner@proxmox.com> (raw)
In-Reply-To: <20250722163603.1520687-1-c.ebner@proxmox.com>

Splitting the config into 3 structs allows to use them once with
the full config, once without the password and once to only
serialize/deserialize when writing the config.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---
 proxmox-s3-client/src/api_types.rs | 62 ++++++++++++++++++++++++------
 proxmox-s3-client/src/client.rs    |  3 +-
 2 files changed, 52 insertions(+), 13 deletions(-)

diff --git a/proxmox-s3-client/src/api_types.rs b/proxmox-s3-client/src/api_types.rs
index 51f71d84..e05ad0f9 100644
--- a/proxmox-s3-client/src/api_types.rs
+++ b/proxmox-s3-client/src/api_types.rs
@@ -82,9 +82,6 @@ pub const S3_BUCKET_NAME_SCHEMA: Schema = StringSchema::new("Bucket name for S3
 
 #[api(
     properties: {
-        id: {
-            schema: S3_CLIENT_ID_SCHEMA,
-        },
         endpoint: {
             schema: S3_ENDPOINT_SCHEMA,
         },
@@ -103,9 +100,6 @@ pub const S3_BUCKET_NAME_SCHEMA: Schema = StringSchema::new("Bucket name for S3
         "access-key": {
             type: String,
         },
-        "secret-key": {
-            type: String,
-        },
         "path-style": {
             type: bool,
             optional: true,
@@ -115,15 +109,12 @@ pub const S3_BUCKET_NAME_SCHEMA: Schema = StringSchema::new("Bucket name for S3
             type: u64,
             optional: true,
         },
-    }
+    },
 )]
 #[derive(Serialize, Deserialize, Updater, Clone, PartialEq)]
 #[serde(rename_all = "kebab-case")]
 /// S3 client configuration properties.
 pub struct S3ClientConfig {
-    /// ID to identify s3 client config.
-    #[updater(skip)]
-    pub id: String,
     /// Endpoint to access S3 object store.
     pub endpoint: String,
     /// Port to access S3 object store.
@@ -137,8 +128,6 @@ pub struct S3ClientConfig {
     pub fingerprint: Option<String>,
     /// Access key for S3 object store.
     pub access_key: String,
-    /// Secret key for S3 object store.
-    pub secret_key: String,
     /// Use path style bucket addressing over vhost style.
     #[serde(skip_serializing_if = "Option::is_none")]
     pub path_style: Option<bool>,
@@ -154,3 +143,52 @@ impl S3ClientConfig {
         Vec::new()
     }
 }
+
+#[api(
+    properties: {
+        id: {
+            schema: S3_CLIENT_ID_SCHEMA,
+        },
+        config: {
+            type: S3ClientConfig,
+        },
+        "secret-key": {
+            type: String,
+        },
+    },
+)]
+#[derive(Serialize, Deserialize, Updater, Clone, PartialEq)]
+#[serde(rename_all = "kebab-case")]
+/// S3 client configuration.
+pub struct S3ClientConf {
+    /// ID to identify s3 client config.
+    #[updater(skip)]
+    pub id: String,
+    /// S3 client config.
+    #[serde(flatten)]
+    pub config: S3ClientConfig,
+    /// Secret key for S3 object store.
+    pub secret_key: String,
+}
+
+
+#[api(
+    properties: {
+        id: {
+            schema: S3_CLIENT_ID_SCHEMA,
+        },
+        config: {
+            type: S3ClientConfig,
+        },
+    },
+)]
+#[derive(Serialize, Deserialize, Clone, PartialEq)]
+#[serde(rename_all = "kebab-case")]
+/// S3 client configuration properties without secret.
+pub struct S3ClientConfigWithoutSecret {
+    /// ID to identify s3 client config.
+    pub id: String,
+    /// S3 client config.
+    #[serde(flatten)]
+    pub config: S3ClientConfig,
+}
diff --git a/proxmox-s3-client/src/client.rs b/proxmox-s3-client/src/client.rs
index f418ee39..eb5fc7d9 100644
--- a/proxmox-s3-client/src/client.rs
+++ b/proxmox-s3-client/src/client.rs
@@ -75,6 +75,7 @@ impl S3ClientOptions {
     /// Construct options for the S3 client give the provided configuration parameters.
     pub fn from_config(
         config: S3ClientConfig,
+        secret_key: String,
         bucket: String,
         common_prefix: String,
     ) -> Self {
@@ -87,7 +88,7 @@ impl S3ClientOptions {
             region: config.region.unwrap_or("us-west-1".to_string()),
             fingerprint: config.fingerprint,
             access_key: config.access_key,
-            secret_key: config.secret_key,
+            secret_key,
             put_rate_limit: config.put_rate_limit,
         }
     }
-- 
2.47.2



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


  reply	other threads:[~2025-07-22 16:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-22 16:36 [pbs-devel] [PATCH proxmox{, -backup} 0/3] followups for PBS s3 backend Christian Ebner
2025-07-22 16:36 ` Christian Ebner [this message]
2025-07-22 16:36 ` [pbs-devel] [PATCH proxmox-backup 1/2] config: s3: adapt to new config struct layouts Christian Ebner
2025-07-22 16:36 ` [pbs-devel] [PATCH proxmox-backup 2/2] datastore: check s3 bucket access before create datastore task Christian Ebner
2025-07-22 20:25 ` [pbs-devel] applied: [PATCH proxmox{, -backup} 0/3] followups for PBS s3 backend 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=20250722163603.1520687-2-c.ebner@proxmox.com \
    --to=c.ebner@proxmox.com \
    --cc=pbs-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