X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=lib%2Fpuppet%2Fprovider%2Fapt_key%2Fapt_key.rb;h=2646422a581d4e1bd3ae7f79a33f464f37978ab6;hb=7a52dc6237285c6d9d5e39a6f3f50ee8cba437b7;hp=49b1afdc3e0a975a7940ee269c29e506d7b75b7a;hpb=2b536b6a200e8f4f7f7ae37ec091abd06ca4cb70;p=puppet-modules%2Fpuppetlabs-apt.git diff --git a/lib/puppet/provider/apt_key/apt_key.rb b/lib/puppet/provider/apt_key/apt_key.rb index 49b1afd..2646422 100644 --- a/lib/puppet/provider/apt_key/apt_key.rb +++ b/lib/puppet/provider/apt_key/apt_key.rb @@ -11,6 +11,8 @@ if RUBY_VERSION == '1.8.7' end Puppet::Type.type(:apt_key).provide(:apt_key) do + desc 'apt-key provider for apt_key resource' + confine osfamily: :debian defaultfor osfamily: :debian commands apt_key: 'apt-key' @@ -72,7 +74,7 @@ Puppet::Type.type(:apt_key).provide(:apt_key) do def self.prefetch(resources) apt_keys = instances - resources.keys.each do |name| + resources.each_key do |name| if name.length == 40 provider = apt_keys.find { |key| key.fingerprint == name } resources[name].provider = provider if provider @@ -119,7 +121,7 @@ Puppet::Type.type(:apt_key).provide(:apt_key) do def source_to_file(value) parsed_value = URI.parse(value) if parsed_value.scheme.nil? - raise("The file #{value} does not exist") unless File.exist?(value) + raise(_('The file %{_value} does not exist') % { _value: value }) unless File.exist?(value) # Because the tempfile method has to return a live object to prevent GC # of the underlying file from occuring too early, we also have to return # a file object here. The caller can still call the #path method on the @@ -139,9 +141,9 @@ Puppet::Type.type(:apt_key).provide(:apt_key) do key = open(parsed_value, http_basic_authentication: user_pass).read end rescue OpenURI::HTTPError, Net::FTPPermError => e - raise("#{e.message} for #{resource[:source]}") + raise(_('%{_e} for %{_resource}') % { _e: e.message, _resource: resource[:source] }) rescue SocketError - raise("could not resolve #{resource[:source]}") + raise(_('could not resolve %{_resource}') % { _resource: resource[:source] }) else tempfile(key) end @@ -168,7 +170,7 @@ Puppet::Type.type(:apt_key).provide(:apt_key) do end end unless found_match - raise("The id in your manifest #{resource[:name]} and the fingerprint from content/source don't match. Check for an error in the id and content/source is legitimate.") + raise(_('The id in your manifest %{_resource} and the fingerprint from content/source don\'t match. Check for an error in the id and content/source is legitimate.') % { _resource: resource[:name] }) # rubocop:disable Metrics/LineLength end else warning('/usr/bin/gpg cannot be found for verification of the id.') @@ -199,7 +201,7 @@ Puppet::Type.type(:apt_key).provide(:apt_key) do command.push('add', key_file.path) # In case we really screwed up, better safe than sorry. else - raise("an unexpected condition occurred while trying to add the key: #{resource[:id]}") + raise(_('an unexpected condition occurred while trying to add the key: %{_resource}') % { _resource: resource[:id] }) end apt_key(command) @property_hash[:ensure] = :present @@ -215,7 +217,7 @@ Puppet::Type.type(:apt_key).provide(:apt_key) do end def read_only(_value) - raise('This is a read-only property.') + raise(_('This is a read-only property.')) end mk_resource_methods