[pve-devel] [PATCH v4 pve-storage 12/16] cephconfig: remove leading whitespace on write to Ceph config

Max Carrara m.carrara at proxmox.com
Tue Mar 5 16:07:54 CET 2024


Because continued lines (lines following lines that end with '\')
preserve whitespace, this commit removes any leading whitespace that
is added by our config writer.

This is done in order to make continued lines look less "awkward" when
manually changing values in 'ceph.conf' after the file has been
modified by our tooling. Before this commit, continued lines would
have to be added as follows:

[some_section]
	 some_key = Lorem ipsum dolor sit amet, consectetur \
adipiscing elit, sed do eiusmod tempor incididunt ut labore et \
dolore magna aliqua.

Due to whitespace being preserved, continued lines cannot be on the
same indentation level as `some_key`. Furthermore, the indentation
level might lead some users to mistakenly believe that leading
whitespace is ignored.

Thus, this commit removes the leading whitespace that is added by our
config writer.

Signed-off-by: Max Carrara <m.carrara at proxmox.com>
---
Changes v2 --> v3:
  * new
Changes v3 --> v4:
  * rebased due to previous changes

Note: This patch may be dropped if not desired.

 src/PVE/CephConfig.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/PVE/CephConfig.pm b/src/PVE/CephConfig.pm
index c84b78f..888be08 100644
--- a/src/PVE/CephConfig.pm
+++ b/src/PVE/CephConfig.pm
@@ -108,7 +108,7 @@ sub write_ceph_config {
 		# escape comment literals
 		$value =~ s/(#|;)/\\$1/g;
 
-		$out .= "\t $key = $value\n";
+		$out .= "$key = $value\n";
 	    }
 	    $out .= "\n";
 
-- 
2.39.2





More information about the pve-devel mailing list