public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox 1/2] section-config: make ReST dump reproducible
@ 2022-12-13 13:37 Fabian Grünbichler
  2022-12-13 13:37 ` [pbs-devel] [PATCH proxmox 2/2] section-config: silence clippy Fabian Grünbichler
  2022-12-13 13:53 ` [pbs-devel] applied-series: [PATCH proxmox 1/2] section-config: make ReST dump reproducible Wolfgang Bumiller
  0 siblings, 2 replies; 3+ messages in thread
From: Fabian Grünbichler @ 2022-12-13 13:37 UTC (permalink / raw)
  To: pbs-devel

HashMaps are not ordered, so each package build containing a section config
dump would have the documentation ordered randomly.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
tested PBS build with the resulting proxmox-section-config crate, the -docs
package is now reproducible ;)

 proxmox-section-config/src/lib.rs | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/proxmox-section-config/src/lib.rs b/proxmox-section-config/src/lib.rs
index 1706718..51f6770 100644
--- a/proxmox-section-config/src/lib.rs
+++ b/proxmox-section-config/src/lib.rs
@@ -1110,10 +1110,13 @@ token: asdf@pbs!asdftoken
 pub fn dump_section_config(config: &SectionConfig) -> String {
     let mut res = String::new();
 
+    let mut plugins: Vec<&String> = config.plugins().keys().collect();
+    plugins.sort_unstable();
+
     let plugin_count = config.plugins().len();
 
-    for plugin in config.plugins().values() {
-        let name = plugin.type_name();
+    for name in plugins {
+        let plugin = config.plugins().get(name).unwrap();
         let properties = plugin.properties();
         let skip = match plugin.id_property() {
             Some(id) => vec![id],
-- 
2.30.2





^ permalink raw reply	[flat|nested] 3+ messages in thread

* [pbs-devel] [PATCH proxmox 2/2] section-config: silence clippy
  2022-12-13 13:37 [pbs-devel] [PATCH proxmox 1/2] section-config: make ReST dump reproducible Fabian Grünbichler
@ 2022-12-13 13:37 ` Fabian Grünbichler
  2022-12-13 13:53 ` [pbs-devel] applied-series: [PATCH proxmox 1/2] section-config: make ReST dump reproducible Wolfgang Bumiller
  1 sibling, 0 replies; 3+ messages in thread
From: Fabian Grünbichler @ 2022-12-13 13:37 UTC (permalink / raw)
  To: pbs-devel

these two functions don't actually use the `type_name` parameter, but the
interface including custom formatters require it.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
 proxmox-section-config/src/lib.rs | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/proxmox-section-config/src/lib.rs b/proxmox-section-config/src/lib.rs
index 51f6770..ed00159 100644
--- a/proxmox-section-config/src/lib.rs
+++ b/proxmox-section-config/src/lib.rs
@@ -577,7 +577,7 @@ impl SectionConfig {
     }
 
     fn default_format_section_content(
-        type_name: &str,
+        _type_name: &str,
         section_id: &str,
         key: &str,
         value: &Value,
@@ -585,7 +585,7 @@ impl SectionConfig {
         if let Value::Array(array) = value {
             let mut list = String::new();
             for item in array {
-                let line = Self::default_format_section_content(type_name, section_id, key, item)?;
+                let line = Self::default_format_section_content(_type_name, section_id, key, item)?;
                 if !line.is_empty() {
                     list.push_str(&line);
                 }
@@ -691,7 +691,7 @@ impl SectionConfig {
     }
 
     fn systemd_format_section_content(
-        type_name: &str,
+        _type_name: &str,
         section_id: &str,
         key: &str,
         value: &Value,
@@ -699,7 +699,7 @@ impl SectionConfig {
         if let Value::Array(array) = value {
             let mut list = String::new();
             for item in array {
-                let line = Self::systemd_format_section_content(type_name, section_id, key, item)?;
+                let line = Self::systemd_format_section_content(_type_name, section_id, key, item)?;
                 if !line.is_empty() {
                     list.push_str(&line);
                 }
-- 
2.30.2





^ permalink raw reply	[flat|nested] 3+ messages in thread

* [pbs-devel] applied-series: [PATCH proxmox 1/2] section-config: make ReST dump reproducible
  2022-12-13 13:37 [pbs-devel] [PATCH proxmox 1/2] section-config: make ReST dump reproducible Fabian Grünbichler
  2022-12-13 13:37 ` [pbs-devel] [PATCH proxmox 2/2] section-config: silence clippy Fabian Grünbichler
@ 2022-12-13 13:53 ` Wolfgang Bumiller
  1 sibling, 0 replies; 3+ messages in thread
From: Wolfgang Bumiller @ 2022-12-13 13:53 UTC (permalink / raw)
  To: Fabian Grünbichler; +Cc: pbs-devel

applied both patches, thanks

On Tue, Dec 13, 2022 at 02:37:54PM +0100, Fabian Grünbichler wrote:
> HashMaps are not ordered, so each package build containing a section config
> dump would have the documentation ordered randomly.
> 
> Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
> ---
> tested PBS build with the resulting proxmox-section-config crate, the -docs
> package is now reproducible ;)
> 
>  proxmox-section-config/src/lib.rs | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/proxmox-section-config/src/lib.rs b/proxmox-section-config/src/lib.rs
> index 1706718..51f6770 100644
> --- a/proxmox-section-config/src/lib.rs
> +++ b/proxmox-section-config/src/lib.rs
> @@ -1110,10 +1110,13 @@ token: asdf@pbs!asdftoken
>  pub fn dump_section_config(config: &SectionConfig) -> String {
>      let mut res = String::new();
>  
> +    let mut plugins: Vec<&String> = config.plugins().keys().collect();
> +    plugins.sort_unstable();
> +
>      let plugin_count = config.plugins().len();
>  
> -    for plugin in config.plugins().values() {
> -        let name = plugin.type_name();
> +    for name in plugins {
> +        let plugin = config.plugins().get(name).unwrap();
>          let properties = plugin.properties();
>          let skip = match plugin.id_property() {
>              Some(id) => vec![id],
> -- 
> 2.30.2




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-12-13 13:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-13 13:37 [pbs-devel] [PATCH proxmox 1/2] section-config: make ReST dump reproducible Fabian Grünbichler
2022-12-13 13:37 ` [pbs-devel] [PATCH proxmox 2/2] section-config: silence clippy Fabian Grünbichler
2022-12-13 13:53 ` [pbs-devel] applied-series: [PATCH proxmox 1/2] section-config: make ReST dump reproducible Wolfgang Bumiller

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