X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=lib%2Fpuppet%2Ftype%2Fapt_key.rb;h=faa430be4263132488fd3448f27733b0990b8a2a;hb=c1c27ebcfc249caf858eda1765ccd68832437865;hp=7c275efa075465c718b115853dff01b62f3724a7;hpb=bea6af8fc69bceb7b1f9f0e3e01e3dc29336bf79;p=puppet-modules%2Fpuppetlabs-apt.git diff --git a/lib/puppet/type/apt_key.rb b/lib/puppet/type/apt_key.rb index 7c275ef..faa430b 100644 --- a/lib/puppet/type/apt_key.rb +++ b/lib/puppet/type/apt_key.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'pathname' require 'puppet/parameter/boolean' @@ -23,15 +25,10 @@ Puppet::Type.newtype(:apt_key) do ensurable validate do - if self[:refresh] == true && self[:ensure] == :absent - raise(_('ensure => absent and refresh => true are mutually exclusive')) - end - if self[:content] && self[:source] - raise(_('The properties content and source are mutually exclusive.')) - end - if self[:id].length < 40 - warning(_('The id should be a full fingerprint (40 characters), see README.')) - end + raise(_('ensure => absent and refresh => true are mutually exclusive')) if self[:refresh] == true && self[:ensure] == :absent + raise(_('The properties content and source are mutually exclusive.')) if self[:content] && self[:source] + + warning(_('The id should be a full fingerprint (40 characters), see README.')) if self[:id].length < 40 end newparam(:id, namevar: true) do @@ -59,16 +56,14 @@ Puppet::Type.newtype(:apt_key) do end autorequire(:file) do - if self[:source] && Pathname.new(self[:source]).absolute? - self[:source] - end + self[:source] if self[:source] && Pathname.new(self[:source]).absolute? end newparam(:server) do desc 'The key server to fetch the key from based on the ID. It can either be a domain name or url.' defaultto :'keyserver.ubuntu.com' - newvalues(%r{\A((hkp|hkps|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?(\/[a-zA-Z\d\-_.]+)*\/?$}) + newvalues(%r{\A((hkp|hkps|http|https)://)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?(/[a-zA-Z\d\-_.]+)*/?$}) end newparam(:options) do @@ -81,7 +76,7 @@ Puppet::Type.newtype(:apt_key) do end newparam(:weak_ssl, boolean: true, parent: Puppet::Parameter::Boolean) do - desc 'When true and source uses https, accepts download of keys without SSL verfication' + desc 'When true and source uses https, accepts download of keys without SSL verification' defaultto false end