voxpupuli / puppet-unattended_upgrades

Unattended-upgrades for APT
https://forge.puppet.com/puppet/unattended_upgrades
Apache License 2.0
34 stars 75 forks source link

buildin function merge got deprecated in puppet 8 #228

Closed suchAdemon closed 1 year ago

suchAdemon commented 1 year ago

Affected Puppet, Ruby, OS and module versions/distributions

How to reproduce (e.g Puppet code you use)

Just perform a run with puppet 8

What are you seeing

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Function Call, deprecation. merge. This function is deprecated, please use stdlib::merge instead. at ["<..>/modules/unattended_upgrades/manifests/init.pp", 35] (file: "<..>/modules/unattended_upgrades/manifests/init.pp, line: 35, column: 11) on node <..>

Possible solution

using puppet internal function

diff --git a/manifests/init.pp b/manifests/init.pp
index a4e4b98..5b7af1e 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -32,19 +32,19 @@ class unattended_upgrades (
   # apt::conf settings require the apt class to work
   include apt

-  $_age = merge($unattended_upgrades::default_age, $age)
+  $_age = $unattended_upgrades::default_age + $age
   assert_type(Unattended_upgrades::Age, $_age)

-  $_auto = merge($unattended_upgrades::default_auto, $auto)
+  $_auto = $unattended_upgrades::default_auto + $auto
   assert_type(Unattended_upgrades::Auto, $_auto)

-  $_backup = merge($unattended_upgrades::default_backup, $backup)
+  $_backup = $unattended_upgrades::default_backup + $backup
   assert_type(Unattended_upgrades::Backup, $_backup)

-  $_mail = merge($unattended_upgrades::default_mail, $mail)
+  $_mail = $unattended_upgrades::default_mail + $mail
   assert_type(Unattended_upgrades::Mail, $_mail)

-  $_upgradeable_packages = merge($unattended_upgrades::default_upgradeable_packages, $upgradeable_packages)
+  $_upgradeable_packages = $unattended_upgrades::default_upgradeable_packages + $upgradeable_packages
   assert_type(Unattended_upgrades::Upgradeable_packages, $_upgradeable_packages)

   package { 'unattended-upgrades':
smortex commented 1 year ago

It's not a builtin function, it is part of stdlib and we started to namespace functions to avoid name collisions, see:

https://github.com/puppetlabs/puppetlabs-stdlib/commit/04d1f0c5cccb93d0bc928c7623c4b0c0ebda5b6b

Also, Puppet 8 by default fail on warning. This can be tuned to not raise an error.

A long-term fix is to add support for the latest release of stdlib and for Puppet 8 to this module (which currently says it does not support them).

suchAdemon commented 1 year ago

Hello, yea true merge is not the build in function, was still thinking about the code snippet I posted, if it could break something. I guess then there will be no interim commit to sort it out, so that the main branch could continue updates and being used on the latest main commit/or similar? If not, then I will keep my local changes till the long-term fix got merged.

Btw, cool thing that you started to namespace functions.

kenyon commented 1 year ago

Fixed in #231.