X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=lib%2Fpuppet%2Ftype%2Fapt_key.rb;h=a9273e26acd5222d5ea3e5520e93d8cec190a23b;hb=f610bedc5f33db5fdee2ad49eeda95268ab0b9a5;hp=72f3c87c5b35705ae963e39244f7e4b44d9f661a;hpb=85884d05e8e2d351b955c1d0bb990aa4c5196a63;p=puppet-modules%2Fpuppetlabs-apt.git diff --git a/lib/puppet/type/apt_key.rb b/lib/puppet/type/apt_key.rb index 72f3c87..a9273e2 100644 --- a/lib/puppet/type/apt_key.rb +++ b/lib/puppet/type/apt_key.rb @@ -1,7 +1,6 @@ require 'pathname' Puppet::Type.newtype(:apt_key) do - @doc = <<-EOS This type provides Puppet with the capabilities to manage GPG keys needed by apt to perform package validation. Apt has it's own GPG keyring that can @@ -20,25 +19,25 @@ Puppet::Type.newtype(:apt_key) do ensurable validate do - if self[:content] and self[:source] - fail('The properties content and source are mutually exclusive.') + if self[:content] && self[:source] + raise('The properties content and source are mutually exclusive.') end - if self[:id].length < 40 + if self[:id].length < 40 warning('The id should be a full fingerprint (40 characters), see README.') - end + end end - newparam(:id, :namevar => true) do + newparam(:id, namevar: true) do desc 'The ID of the key you want to manage.' # GPG key ID's should be either 32-bit (short) or 64-bit (long) key ID's # and may start with the optional 0x, or they can be 40-digit key fingerprints - newvalues(/\A(0x)?[0-9a-fA-F]{8}\Z/, /\A(0x)?[0-9a-fA-F]{16}\Z/, /\A(0x)?[0-9a-fA-F]{40}\Z/) + newvalues(%r{\A(0x)?[0-9a-fA-F]{8}\Z}, %r{\A(0x)?[0-9a-fA-F]{16}\Z}, %r{\A(0x)?[0-9a-fA-F]{40}\Z}) munge do |value| - if value.start_with?('0x') - id = value.partition('0x').last.upcase - else - id = value.upcase - end + id = if value.start_with?('0x') + value.partition('0x').last.upcase + else + value.upcase + end id end end @@ -49,11 +48,11 @@ Puppet::Type.newtype(:apt_key) do newparam(:source) do desc 'Location of a GPG key file, /path/to/file, ftp://, http:// or https://' - newvalues(/\Ahttps?:\/\//, /\Aftp:\/\//, /\A\/\w+/) + newvalues(%r{\Ahttps?://}, %r{\Aftp://}, %r{\A/\w+}) end autorequire(:file) do - if self[:source] and Pathname.new(self[:source]).absolute? + if self[:source] && Pathname.new(self[:source]).absolute? self[:source] end end @@ -62,7 +61,7 @@ Puppet::Type.newtype(:apt_key) 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(/\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$/) + newvalues(%r{\A((hkp|http|https)://)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$}) end newparam(:options) do