MODULES-10956 remove redundant code in provider apt_key
authorMoritz Kraus <moritz.kraus@makandra.de>
Wed, 24 Feb 2021 14:29:19 +0000 (15:29 +0100)
committerMoritz Kraus <moritz.kraus@makandra.de>
Wed, 24 Feb 2021 15:08:11 +0000 (16:08 +0100)
The code in function `update_expired_key` is redundant to the logic in
the function `create`. The call to function `exist` will mark the key as
absent, in case it has expired and refres is set to true.

I debugged for hours why my keys weren't updated until I realized, that
the functionality is elsewhere.

lib/puppet/provider/apt_key/apt_key.rb

index e9e377b4120920c51490938eaf48ca76f5f5272a..56f9a072e518b25c83f06c4a5c846dc7492dbbfe 100644 (file)
@@ -177,29 +177,7 @@ Puppet::Type.type(:apt_key).provide(:apt_key) do
     file
   end
 
-  # Update a key if it is expired
-  def update_expired_key
-    # Return without doing anything if refresh or expired is false
-    return unless resource[:refresh] == true && resource[:expired] == true
-
-    # Execute command to update key
-    command = []
-
-    unless resource[:source].nil? && resource[:content].nil?
-      raise(_('an unexpected condition occurred while trying to add the key: %{_resource}') % { _resource: resource[:id] })
-    end
-
-    # Breaking up the command like this is needed because it blows up
-    # if --recv-keys isn't the last argument.
-    command.push('adv', '--no-tty', '--keyserver', resource[:server])
-    unless resource[:options].nil?
-      command.push('--keyserver-options', resource[:options])
-    end
-    command.push('--recv-keys', resource[:id])
-  end
-
   def exists?
-    update_expired_key
     # report expired keys as non-existing when refresh => true
     @property_hash[:ensure] == :present && !(resource[:refresh] && @property_hash[:expired])
   end