From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 96A9F1FF16F for ; Tue, 22 Jul 2025 18:35:12 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id C3AE2E8A2; Tue, 22 Jul 2025 18:36:24 +0200 (CEST) From: Christian Ebner To: pbs-devel@lists.proxmox.com Date: Tue, 22 Jul 2025 18:36:01 +0200 Message-ID: <20250722163603.1520687-2-c.ebner@proxmox.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250722163603.1520687-1-c.ebner@proxmox.com> References: <20250722163603.1520687-1-c.ebner@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1753202170830 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.044 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. [client.rs] Subject: [pbs-devel] [PATCH proxmox 1/1] s3 client: split config api type into 3 config structs X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" 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 --- 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, /// 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, @@ -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