public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH v2 proxmox-backup 4/5] remote.cfg: rename userid to 'auth-id'
Date: Thu,  5 Nov 2020 12:12:25 +0100	[thread overview]
Message-ID: <20201105111226.4105475-5-f.gruenbichler@proxmox.com> (raw)
In-Reply-To: <20201105111226.4105475-1-f.gruenbichler@proxmox.com>

and fixup config file on upgrades accordingly

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
 debian/postinst            |  9 +++++++++
 src/api2/config/remote.rs  | 10 +++++-----
 src/api2/pull.rs           |  2 +-
 src/config/remote.rs       |  5 +++--
 www/config/RemoteView.js   |  6 +++---
 www/form/RemoteSelector.js |  4 ++--
 www/window/RemoteEdit.js   |  6 ++----
 7 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/debian/postinst b/debian/postinst
index af5ee097..6a0cf9fd 100644
--- a/debian/postinst
+++ b/debian/postinst
@@ -28,6 +28,15 @@ case "$1" in
 		if dpkg --compare-versions "$2" 'le' '0.9.5-1'; then
 			chown --quiet backup:backup /var/log/proxmox-backup/api/auth.log || true
 		fi
+		if dpkg --compare-versions "$2" 'le' '0.9.6-1'; then
+			if [ -e /etc/proxmox-backup/remote.cfg ]; then
+				echo "NOTE: Switching over remote.cfg to new field names.."
+				flock -w 30 /etc/proxmox-backup/.remote.lck \
+				    sed -i \
+				        -e 's/^\s\+userid /\tauth-id /g' \
+				        /etc/proxmox-backup/remote.cfg || true
+			fi
+		fi
 	fi
 	# FIXME: Remove in future version once we're sure no broken entries remain in anyone's files
 	if grep -q -e ':termproxy::[^@]\+: ' /var/log/proxmox-backup/tasks/active; then
diff --git a/src/api2/config/remote.rs b/src/api2/config/remote.rs
index f053ef36..29b14472 100644
--- a/src/api2/config/remote.rs
+++ b/src/api2/config/remote.rs
@@ -78,7 +78,7 @@ pub fn list_remotes(
                 optional: true,
                 default: 8007,
             },
-            userid: {
+            "auth-id": {
                 type: Authid,
             },
             password: {
@@ -178,7 +178,7 @@ pub enum DeletableProperty {
                 type: u16,
                 optional: true,
             },
-            userid: {
+            "auth-id": {
                 optional: true,
                 type: Authid,
             },
@@ -214,7 +214,7 @@ pub fn update_remote(
     comment: Option<String>,
     host: Option<String>,
     port: Option<u16>,
-    userid: Option<Authid>,
+    auth_id: Option<Authid>,
     password: Option<String>,
     fingerprint: Option<String>,
     delete: Option<Vec<DeletableProperty>>,
@@ -252,7 +252,7 @@ pub fn update_remote(
     }
     if let Some(host) = host { data.host = host; }
     if port.is_some() { data.port = port; }
-    if let Some(userid) = userid { data.userid = userid; }
+    if let Some(auth_id) = auth_id { data.auth_id = auth_id; }
     if let Some(password) = password { data.password = password; }
 
     if let Some(fingerprint) = fingerprint { data.fingerprint = Some(fingerprint); }
@@ -312,7 +312,7 @@ pub async fn remote_client(remote: remote::Remote) -> Result<HttpClient, Error>
     let client = HttpClient::new(
         &remote.host,
         remote.port.unwrap_or(8007),
-        &remote.userid,
+        &remote.auth_id,
         options)?;
     let _auth_info = client.login() // make sure we can auth
         .await
diff --git a/src/api2/pull.rs b/src/api2/pull.rs
index 87015c72..88ce750c 100644
--- a/src/api2/pull.rs
+++ b/src/api2/pull.rs
@@ -50,7 +50,7 @@ pub async fn get_pull_parameters(
     let (remote_config, _digest) = remote::config()?;
     let remote: remote::Remote = remote_config.lookup("remote", remote)?;
 
-    let src_repo = BackupRepository::new(Some(remote.userid.clone()), Some(remote.host.clone()), remote.port, remote_store.to_string());
+    let src_repo = BackupRepository::new(Some(remote.auth_id.clone()), Some(remote.host.clone()), remote.port, remote_store.to_string());
 
     let client = crate::api2::config::remote::remote_client(remote).await?;
 
diff --git a/src/config/remote.rs b/src/config/remote.rs
index 14c57c0e..20fd39d4 100644
--- a/src/config/remote.rs
+++ b/src/config/remote.rs
@@ -44,7 +44,7 @@ pub const REMOTE_PASSWORD_SCHEMA: Schema = StringSchema::new("Password or auth t
             description: "The (optional) port",
             type: u16,
         },
-        userid: {
+        "auth-id": {
             type: Authid,
         },
         password: {
@@ -57,6 +57,7 @@ pub const REMOTE_PASSWORD_SCHEMA: Schema = StringSchema::new("Password or auth t
     }
 )]
 #[derive(Serialize,Deserialize)]
+#[serde(rename_all = "kebab-case")]
 /// Remote properties.
 pub struct Remote {
     pub name: String,
@@ -65,7 +66,7 @@ pub struct Remote {
     pub host: String,
     #[serde(skip_serializing_if="Option::is_none")]
     pub port: Option<u16>,
-    pub userid: Authid,
+    pub auth_id: Authid,
     #[serde(skip_serializing_if="String::is_empty")]
     #[serde(with = "proxmox::tools::serde::string_as_base64")]
     pub password: String,
diff --git a/www/config/RemoteView.js b/www/config/RemoteView.js
index 685503fe..fa4c8825 100644
--- a/www/config/RemoteView.js
+++ b/www/config/RemoteView.js
@@ -1,6 +1,6 @@
 Ext.define('pmx-remotes', {
     extend: 'Ext.data.Model',
-    fields: ['name', 'host', 'port', 'userid', 'fingerprint', 'comment',
+    fields: ['name', 'host', 'port', 'auth-id', 'fingerprint', 'comment',
 	{
 	    name: 'server',
 	    calculate: function(data) {
@@ -127,11 +127,11 @@ Ext.define('PBS.config.RemoteView', {
 	    dataIndex: 'server',
 	},
 	{
-	    header: gettext('User name'),
+	    header: gettext('Auth ID'),
 	    width: 200,
 	    sortable: true,
 	    renderer: Ext.String.htmlEncode,
-	    dataIndex: 'userid',
+	    dataIndex: 'auth-id',
 	},
 	{
 	    header: gettext('Fingerprint'),
diff --git a/www/form/RemoteSelector.js b/www/form/RemoteSelector.js
index 3f55ef1f..8dae6682 100644
--- a/www/form/RemoteSelector.js
+++ b/www/form/RemoteSelector.js
@@ -29,9 +29,9 @@ Ext.define('PBS.form.RemoteSelector', {
 		flex: 1,
 	    },
 	    {
-		header: gettext('User name'),
+		header: gettext('Auth ID'),
 		sortable: true,
-		dataIndex: 'userid',
+		dataIndex: 'auth-id',
 		renderer: Ext.String.htmlEncode,
 		flex: 1,
 	    },
diff --git a/www/window/RemoteEdit.js b/www/window/RemoteEdit.js
index 56a248e0..4a4d8114 100644
--- a/www/window/RemoteEdit.js
+++ b/www/window/RemoteEdit.js
@@ -5,8 +5,6 @@ Ext.define('PBS.window.RemoteEdit', {
 
     onlineHelp: 'backup_remote',
 
-    userid: undefined,
-
     isAdd: true,
 
     subject: gettext('Remote'),
@@ -93,8 +91,8 @@ Ext.define('PBS.window.RemoteEdit', {
 	    {
 		xtype: 'proxmoxtextfield',
 		allowBlank: false,
-		name: 'userid',
-		fieldLabel: gettext('Userid'),
+		name: 'auth-id',
+		fieldLabel: gettext('Auth ID'),
 	    },
 	    {
 		xtype: 'textfield',
-- 
2.20.1





  parent reply	other threads:[~2020-11-05 11:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-05 11:12 [pbs-devel] [PATCH v2 proxmox-backup 0/5] remote scanning Fabian Grünbichler
2020-11-05 11:12 ` [pbs-devel] [PATCH v2 proxmox-backup 1/5] types: extract DataStoreListItem Fabian Grünbichler
2020-11-05 12:20   ` [pbs-devel] applied: " Thomas Lamprecht
2020-11-05 11:12 ` [pbs-devel] [PATCH v2 proxmox-backup 2/5] api: refactor remote client and add remote scan Fabian Grünbichler
2020-11-05 12:20   ` [pbs-devel] applied: " Thomas Lamprecht
2020-11-05 11:12 ` [pbs-devel] [PATCH v2 proxmox-backup 3/5] www: add remote store selector Fabian Grünbichler
2020-11-05 12:21   ` [pbs-devel] applied: " Thomas Lamprecht
2020-11-05 11:12 ` Fabian Grünbichler [this message]
2020-11-10 12:30   ` [pbs-devel] applied: [PATCH v2 proxmox-backup 4/5] remote.cfg: rename userid to 'auth-id' Thomas Lamprecht
2020-11-05 11:12 ` [pbs-devel] [RFC v2 proxmox-backup 5/5] remote.cfg: rename password to secret Fabian Grünbichler
2020-11-10 12:31   ` 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=20201105111226.4105475-5-f.gruenbichler@proxmox.com \
    --to=f.gruenbichler@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal