]> review.fuel-infra Code Review - puppet-modules/puppetlabs-apt.git/commitdiff
Merge pull request #792 from eimlav/stringify
authorHelen <helen@puppetlabs.com>
Wed, 5 Sep 2018 10:10:57 +0000 (11:10 +0100)
committerGitHub <noreply@github.com>
Wed, 5 Sep 2018 10:10:57 +0000 (11:10 +0100)
(FM-7318) - Added Puppet Strings formatting to documentation

12 files changed:
1  2 
lib/puppet/provider/apt_key/apt_key.rb
lib/puppet/type/apt_key.rb
manifests/backports.pp
manifests/conf.pp
manifests/init.pp
manifests/key.pp
manifests/params.pp
manifests/pin.pp
manifests/ppa.pp
manifests/setting.pp
manifests/source.pp
spec/acceptance/apt_key_provider_spec.rb

index bcb0bb9730a608f95d093cb939665b64b6e80559,1e54f3ccb4531e3a9a09ee7de920a77419efe49a..fbf232a766b8f12caf22f8f3725af80bb44908ef
@@@ -11,6 -11,8 +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'
    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
            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
            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.') % { _name: resource[:name] }) # rubocop:disable Metrics/LineLength
          end
        else
          warning('/usr/bin/gpg cannot be found for verification of the id.')
        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
    end
  
    def read_only(_value)
 -    raise('This is a read-only property.')
 +    raise(_('This is a read-only property.'))
    end
  
    mk_resource_methods
index 4a9b241bd48fdf5604de1edae942a69f20128531,c44aca092c654bf378e09b1972c43c73e757adc7..10bffb46e65ae50239783558f81c404889d6ef32
@@@ -6,24 -6,27 +6,27 @@@ Puppet::Type.newtype(:apt_key) d
      by apt to perform package validation. Apt has it's own GPG keyring that can
      be manipulated through the `apt-key` command.
  
-     apt_key { '6F6B15509CF8E59E6E469F327F438280EF8D349F':
-       source => 'http://apt.puppetlabs.com/pubkey.gpg'
-     }
+     @example Basic usage
+       apt_key { '6F6B15509CF8E59E6E469F327F438280EF8D349F':
+         source => 'http://apt.puppetlabs.com/pubkey.gpg'
+       }
  
-     **Autorequires**:
+     **Autorequires**
  
      If Puppet is given the location of a key file which looks like an absolute
      path this type will autorequire that file.
+     @api private
    MANIFEST
  
    ensurable
  
    validate do
      if self[:content] && self[:source]
 -      raise('The properties content and source are mutually exclusive.')
 +      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.')
 +      warning(_('The id should be a full fingerprint (40 characters), see README.'))
      end
    end
  
diff --combined manifests/backports.pp
index 8555cb0f7a2c68455fbab71b18ee122f5a14bc67,a93e14f37eea07a2b64e4f123e168fe01a27e1c9..62927cdac7d1dada0a720dfac5b72a67a55a1e9e
@@@ -1,4 -1,50 +1,50 @@@
- # Defining backports for the apt class
+ # @summary Manages backports.
+ #
+ # @example Set up a backport for linuxmint qiana
+ #   apt::backports { 'qiana':
+ #     location => 'http://us.archive.ubuntu.com/ubuntu',
+ #     release  => 'trusty-backports',
+ #     repos    => 'main universe multiverse restricted',
+ #     key      => {
+ #       id     => '630239CC130E1A7FD81A27B140976EAF437D05B5',
+ #       server => 'hkps.pool.sks-keyservers.net',
+ #     },
+ #   }
+ #
+ # @param location
+ #   Specifies an Apt repository containing the backports to manage. Valid options: a string containing a URL. Default value for Debian and 
+ #   Ubuntu varies:
+ #
+ #   - Debian: 'http://deb.debian.org/debian'
+ #
+ #   - Ubuntu: 'http://archive.ubuntu.com/ubuntu'
+ #
+ # @param release
+ #   Specifies a distribution of the Apt repository containing the backports to manage. Used in populating the `source.list` configuration file. 
+ #   Default: on Debian and Ubuntu, '${lsbdistcodename}-backports'. We recommend keeping this default, except on other operating 
+ #   systems.
+ #
+ # @param repos
+ #   Specifies a component of the Apt repository containing the backports to manage. Used in populating the `source.list` configuration file. 
+ #   Default value for Debian and Ubuntu varies:
+ #   
+ #   - Debian: 'main contrib non-free'
+ #
+ #   - Ubuntu: 'main universe multiverse restricted'
+ #
+ # @param key
+ #   Specifies a key to authenticate the backports. Valid options: a string to be passed to the id parameter of the apt::key defined type, or a 
+ #   hash of parameter => value pairs to be passed to apt::key's id, server, content, source, and/or options parameters. Default value
+ #   for Debian and Ubuntu varies:
+ #
+ #   - Debian: 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553'
+ #
+ #   - Ubuntu: '630239CC130E1A7FD81A27B140976EAF437D05B5'
+ #
+ # @param pin
+ #   Specifies a pin priority for the backports. Valid options: a number or string to be passed to the `id` parameter of the `apt::pin` defined 
+ #   type, or a hash of `parameter => value` pairs to be passed to `apt::pin`'s corresponding parameters.
+ #
  class apt::backports (
    Optional[String] $location                    = undef,
    Optional[String] $release                     = undef,
@@@ -33,7 -79,7 +79,7 @@@
      }
    } else {
      unless $location and $release and $repos and $key {
 -      fail('If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key')
 +      fail(translate('If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key'))
      }
    }
  
@@@ -47,7 -93,7 +93,7 @@@
        'release'  => $_release,
      }
    } else {
 -    fail('pin must be either a string, number or hash')
 +    fail(translate('pin must be either a string, number or hash'))
    }
  
    apt::source { 'backports':
diff --combined manifests/conf.pp
index f41501b5d189a64830e7a4c0cbcd1729ca892e87,c27f0c1c0dcd683699caec9572739157468a57d7..9c1a59e81cffbfae1e64772853b0872f6da6a262
@@@ -1,4 -1,18 +1,18 @@@
- # Defining apt config
+ # @summary Specifies a custom Apt configuration file.
+ #
+ # @param content
+ #   Required unless `ensure` is set to 'absent'. Directly supplies content for the configuration file.
+ #
+ # @param ensure
+ #    Specifies whether the configuration file should exist. Valid options: 'present' and 'absent'. 
+ #
+ # @param priority
+ #   Determines the order in which Apt processes the configuration file. Files with lower priority numbers are loaded first. 
+ #   Valid options: a string containing an integer or an integer.
+ #
+ # @param notify_update
+ #   Specifies whether to trigger an `apt-get update` run.
+ #
  define apt::conf (
    Optional[String] $content          = undef,
    Enum['present', 'absent'] $ensure  = present,
@@@ -8,7 -22,7 +22,7 @@@
  
    unless $ensure == 'absent' {
      unless $content {
 -      fail('Need to pass in content parameter')
 +      fail(translate('Need to pass in content parameter'))
      }
    }
  
diff --combined manifests/init.pp
index 28c36353646cf57a4f0be314ec2af2d68d45e312,ff0d931acd4242e43c92c472b107df6fe1024ae6..f3472aca0097e6ce45505ca34587caf1327736ce
- # == Class: apt
+ # @summary Main class, includes all other classes.
  #
- # Manage APT (Advanced Packaging Tool)
+ # @see https://docs.puppetlabs.com/references/latest/function.html#createresources for the create resource function
+ #
+ # @param provider
+ #   Specifies the provider that should be used by apt::update.
+ #
+ # @param keyserver
+ #   Specifies a keyserver to provide the GPG key. Valid options: a string containing a domain name or a full URL (http://, https://, or 
+ #   hkp://).
+ #
+ # @param ppa_options
+ #   Supplies options to be passed to the `add-apt-repository` command. 
+ #
+ # @param ppa_package
+ #   Names the package that provides the `apt-add-repository` command.
+ #
+ # @param backports
+ #   Specifies some of the default parameters used by apt::backports. Valid options: a hash made up from the following keys:
+ #
+ # @option backports [String] :location 
+ #   See apt::backports for documentation.
+ #
+ # @option backports [String] :repos 
+ #   See apt::backports for documentation.
+ #
+ # @option backports [String] :key 
+ #   See apt::backports for documentation.
+ #
+ # @param confs
+ #   Creates new `apt::conf` resources. Valid options: a hash to be passed to the create_resources function linked above.
+ #
+ # @param update
+ #   Configures various update settings. Valid options: a hash made up from the following keys:
+ #
+ # @option update [String] :frequency
+ #   Specifies how often to run `apt-get update`. If the exec resource `apt_update` is notified, `apt-get update` runs regardless of this value. 
+ #   Valid options: 'always' (at every Puppet run); 'daily' (if the value of `apt_update_last_success` is less than current epoch time minus 86400); 
+ #   'weekly' (if the value of `apt_update_last_success` is less than current epoch time minus 604800); and 'reluctantly' (only if the exec resource 
+ #   `apt_update` is notified). Default: 'reluctantly'.
+ #
+ # @option update [Integer] :loglevel
+ #   Specifies the log level of logs outputted to the console. Default: undef.
+ #
+ # @option update [Integer] :timeout
+ #   Specifies how long to wait for the update to complete before canceling it. Valid options: an integer, in seconds. Default: undef.
+ #
+ # @option update [Integer] :tries
+ #    Specifies how many times to retry the update after receiving a DNS or HTTP error. Default: undef.
+ #
+ # @param purge
+ #   Specifies whether to purge any existing settings that aren't managed by Puppet. Valid options: a hash made up from the following keys:
+ #
+ # @option purge [Boolean] :sources.list
+ #   Specifies whether to purge any unmanaged entries from sources.list. Default false.
+ #
+ # @option purge [Boolean] :sources.list.d
+ #   Specifies whether to purge any unmanaged entries from sources.list.d. Default false.
+ #
+ # @option purge [Boolean] :preferences
+ #   Specifies whether to purge any unmanaged entries from preferences. Default false.
+ #
+ # @option purge [Boolean] :preferences.d.
+ #   Specifies whether to purge any unmanaged entries from preferences.d. Default false.
+ #
+ # @param proxy
+ #   Configures Apt to connect to a proxy server. Valid options: a hash matching the locally defined type apt::proxy.
+ #
+ # @param sources
+ #   Creates new `apt::source` resources. Valid options: a hash to be passed to the create_resources function linked above.
+ #
+ # @param keys
+ #   Creates new `apt::key` resources. Valid options: a hash to be passed to the create_resources function linked above.
+ #
+ # @param ppas
+ #   Creates new `apt::ppa` resources. Valid options: a hash to be passed to the create_resources function linked above.
+ #
+ # @param pins
+ #   Creates new `apt::pin` resources. Valid options: a hash to be passed to the create_resources function linked above.
+ #
+ # @param settings
+ #   Creates new `apt::setting` resources. Valid options: a hash to be passed to the create_resources function linked above.
+ #
+ # @param auth_conf_entries
+ #   An optional array of login configuration settings (hashes) that are recorded in the file /etc/apt/auth.conf. This file has a netrc-like 
+ #   format (similar to what curl uses) and contains the login configuration for APT sources and proxies that require authentication. See 
+ #   https://manpages.debian.org/testing/apt/apt_auth.conf.5.en.html for details. If specified each hash must contain the keys machine, login and 
+ #   password and no others.
+ #
+ # @param root
+ #   Specifies root directory of Apt executable.
+ #
+ # @param sources_list
+ #   Specifies the path of the sources_list file to use. 
+ #
+ # @param sources_list_d
+ #   Specifies the path of the sources_list.d file to use. 
+ #
+ # @param conf_d
+ #   Specifies the path of the conf.d file to use. 
+ #
+ # @param preferences
+ #   Specifies the path of the preferences file to use. 
+ #
+ # @param preferences_d
+ #   Specifies the path of the preferences.d file to use. 
+ #
+ # @param config_files
+ #   A hash made up of the various configuration files used by Apt.
  #
  class apt (
    Hash $update_defaults         = $apt::params::update_defaults,
    String $preferences           = $apt::params::preferences,
    String $preferences_d         = $apt::params::preferences_d,
    Hash $config_files            = $apt::params::config_files,
-   Hash $source_key_defaults     = $apt::params::source_key_defaults
+   Hash $source_key_defaults     = $apt::params::source_key_defaults,
  ) inherits apt::params {
  
    if $facts['osfamily'] != 'Debian' {
 -    fail('This module only works on Debian or derivatives like Ubuntu')
 +    fail(translate('This module only works on Debian or derivatives like Ubuntu'))
    }
  
    if $update['frequency'] {
diff --combined manifests/key.pp
index 4564c6fdf19074c456ecff2c8697bd1bd66d2ace,cb95b4d38cda8090410813d4917a69a693c8b779..93cc27dab0b9dd09b1075cde5a66cc556cc2d15a
@@@ -1,17 -1,64 +1,49 @@@
- # == Define: apt::key
+ # @summary Manages the GPG keys that Apt uses to authenticate packages. 
+ #
+ # @note 
+ #   The apt::key defined type makes use of the apt_key type, but includes extra functionality to help prevent duplicate keys.
+ #
+ # @example Declare Apt key for apt.puppetlabs.com source
+ #   apt::key { 'puppetlabs':
+ #     id      => '6F6B15509CF8E59E6E469F327F438280EF8D349F',
+ #     server  => 'hkps.pool.sks-keyservers.net',
+ #     options => 'http-proxy="http://proxyuser:proxypass@example.org:3128"',
+ #   }
+ #
+ # @param id
+ #   Specifies a GPG key to authenticate Apt package signatures. Valid options: a string containing a key ID (8 or 16 hexadecimal 
+ #   characters, optionally prefixed with "0x") or a full key fingerprint (40 hexadecimal characters).
+ #
+ # @param ensure
+ #   Specifies whether the key should exist. Valid options: 'present' and 'absent'.
+ #
+ # @param content
+ #   Supplies the entire GPG key. Useful in case the key can't be fetched from a remote location and using a file resource is inconvenient.
+ #
+ # @param source
+ #   Specifies the location of an existing GPG key file to copy. Valid options: a string containing a URL (ftp://, http://, or https://) or 
+ #   an absolute path.
+ #
+ # @param server
+ #   Specifies a keyserver to provide the GPG key. Valid options: a string containing a domain name or a full URL (http://, https://, or 
+ #   hkp://).
+ #
+ # @param options
+ #   Passes additional options to `apt-key adv --keyserver-options`.
+ #
  define apt::key (
 -    String $id                           = $title,
 -    Enum['present', 'absent'] $ensure    = present,
 -    Optional[String] $content            = undef,
 -    Optional[String] $source             = undef,
 -    String $server                       = $::apt::keyserver,
 -    Optional[String] $options            = undef,
 -    ) {
 -
 -  assert_type(
 -    Pattern[
 -      /\A(0x)?[0-9a-fA-F]{8}\Z/,
 -      /\A(0x)?[0-9a-fA-F]{16}\Z/,
 -      /\A(0x)?[0-9a-fA-F]{40}\Z/,
 -    ], $id)
 -
 -  if $source {
 -    assert_type(Pattern[/\Ahttps?:\/\//, /\Aftp:\/\//, /\A\/\w+/], $source)
 -  }
 -
 -  if $server {
 -    assert_type(Pattern[/\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$/], $server)
 -  }
 +  Pattern[/\A(0x)?[0-9a-fA-F]{8}\Z/, /\A(0x)?[0-9a-fA-F]{16}\Z/, /\A(0x)?[0-9a-fA-F]{40}\Z/] $id = $title,
 +  Enum['present', 'absent'] $ensure                                                              = present,
 +  Optional[String] $content                                                                      = undef,
 +  Optional[Pattern[/\Ahttps?:\/\//, /\Aftp:\/\//, /\A\/\w+/]] $source                            = undef,
 +  Pattern[/\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$/] $server  = $::apt::keyserver,
 +  Optional[String] $options                                                                      = undef,
 +  ) {
  
    case $ensure {
      present: {
        if defined(Anchor["apt_key ${id} absent"]){
 -        fail("key with id ${id} already ensured as absent")
 +        fail(translate('key with id %{_id} already ensured as absent'),{'_id' => id})
        }
  
        if !defined(Anchor["apt_key ${id} present"]) {
@@@ -44,7 -91,7 +76,7 @@@
  
      absent: {
        if defined(Anchor["apt_key ${id} present"]){
 -        fail("key with id ${id} already ensured as present")
 +        fail(translate('key with id %{_id} already ensured as present', {'_id' => id}))
        }
  
        if !defined(Anchor["apt_key ${id} absent"]){
      }
  
      default: {
 -      fail "Invalid 'ensure' value '${ensure}' for apt::key"
 +      fail translate('Invalid \'ensure\' value \'%{_ensure}\' for apt::key', {'_ensure' => ensure})
      }
    }
  }
diff --combined manifests/params.pp
index aeaf114dc7fe3ef1d13064e88429caf9b85912ef,196bb0ebf6274506427a7abc55557d5284676e30..ae26a7dfda57248a5a02b22fb0a7073b44e855d0
@@@ -1,8 -1,11 +1,11 @@@
- # Setting params for the module
+ # @summary Provides defaults for the Apt module parameters.
+ # 
+ # @api private
+ #
  class apt::params {
  
    if $::osfamily != 'Debian' {
 -    fail('This module only works on Debian or derivatives like Ubuntu')
 +    fail(translate('This module only works on Debian or derivatives like Ubuntu'))
    }
  
    $root           = '/etc/apt'
@@@ -94,7 -97,7 +97,7 @@@
        $ppa_package        = 'software-properties-common'
      }
      undef: {
 -      fail('Unable to determine value for fact os["name"]')
 +      fail(translate('Unable to determine value for fact os[\"name\"]'))
      }
      default: {
        $ppa_options = undef
diff --combined manifests/pin.pp
index 7e661f2172f9be2f25b4f48b5b72cb4a86c2f653,9310653b2d77ea4887a10a022531e8c7599cca2e..8145b7d4b6575c024c1435e803beb5ebda6ea334
@@@ -1,6 -1,38 +1,38 @@@
- # pin.pp
- # pin a release in apt, useful for unstable repositories
+ # @summary Manages Apt pins. Does not trigger an apt-get update run.
+ #
+ # @see http://linux.die.net/man/5/apt_preferences for context on these parameters
+ #
+ # @param ensure
+ #   Specifies whether the pin should exist. Valid options: 'file', 'present', and 'absent'.
+ #
+ # @param explanation
+ #   Supplies a comment to explain the pin. Default: "${caller_module_name}: ${name}".
+ #
+ # @param order
+ #   Determines the order in which Apt processes the pin file. Files with lower order numbers are loaded first.
+ #
+ # @param packages
+ #   Specifies which package(s) to pin.
+ #
+ # @param priority
+ #   Sets the priority of the package. If multiple versions of a given package are available, `apt-get` installs the one with the highest 
+ #   priority number (subject to dependency constraints). Valid options: an integer.
+ #
+ # @param release
+ #   Tells APT to prefer packages that support the specified release. Typical values include 'stable', 'testing', and 'unstable'.
+ #
+ # @param release_version
+ #   Tells APT to prefer packages that support the specified operating system release version (such as Debian release version 7).
+ #
+ # @param component
+ #   Names the licensing component associated with the packages in the directory tree of the Release file.
+ #
+ # @param originator
+ #   Names the originator of the packages in the directory tree of the Release file.
+ #
+ # @param label
+ #   Names the label of the packages in the directory tree of the Release file.
+ #
  define apt::pin(
    Optional[Enum['file', 'present', 'absent']] $ensure = present,
    Optional[String] $explanation                       = undef,
    if $packages_string != '*' { # specific form
      if ( $pin_release != '' and ( $origin != '' or $version != '' )) or
        ( $version != '' and ( $pin_release != '' or $origin != '' )) {
 -      fail('parameters release, origin, and version are mutually exclusive')
 +      fail(translate('parameters release, origin, and version are mutually exclusive'))
      }
    } else { # general form
      if $version != '' {
 -      fail('parameter version cannot be used in general form')
 +      fail(translate('parameter version cannot be used in general form'))
      }
      if ( $pin_release != '' and $origin != '' ) {
 -      fail('parameters release and origin are mutually exclusive')
 +      fail(translate('parameters release and origin are mutually exclusive'))
      }
    }
  
diff --combined manifests/ppa.pp
index 1559e00503980106c1d5fd0b4376c5111d8aef2a,bdc3593be845de50353198bc77cc0fc40a0d5b0b..402961a72a949631b9ba6ebaed7b104abefdefca
@@@ -1,4 -1,24 +1,24 @@@
- # ppa.pp
+ # @summary Manages PPA repositories using `add-apt-repository`. Not supported on Debian.
+ #
+ # @example Example declaration of an Apt PPA
+ #   apt::ppa{ 'ppa:openstack-ppa/bleeding-edge': }
+ #
+ # @param ensure
+ #   Specifies whether the PPA should exist. Valid options: 'present' and 'absent'. 
+ #
+ # @param options
+ #   Supplies options to be passed to the `add-apt-repository` command. Default: '-y'.
+ #
+ # @param release
+ #   Optional if lsb-release is installed (unless you're using a different release than indicated by lsb-release, e.g., Linux Mint). 
+ #   Specifies the operating system of your node. Valid options: a string containing a valid LSB distribution codename.
+ #
+ # @param package_name
+ #   Names the package that provides the `apt-add-repository` command. Default: 'software-properties-common'.
+ #
+ # @param package_manage
+ #   Specifies whether Puppet should manage the package that provides `apt-add-repository`.
+ #
  define apt::ppa(
    String $ensure                 = 'present',
    Optional[String] $options      = $::apt::ppa_options,
    Boolean $package_manage        = false,
  ) {
    unless $release {
 -    fail('lsbdistcodename fact not available: release parameter required')
 +    fail(translate('lsbdistcodename fact not available: release parameter required'))
    }
  
    if $facts['lsbdistid'] == 'Debian' {
 -    fail('apt::ppa is not currently supported on Debian.')
 +    fail(translate('apt::ppa is not currently supported on Debian.'))
    }
  
    if versioncmp($facts['lsbdistrelease'], '14.10') >= 0 {
diff --combined manifests/setting.pp
index dcf082e095609c7b902fb0c6d46e6acafc495e0c,e743a5c2de80b17202d8546d0d76f16a70535582..4729295d0d3e4fe84bef7667d1caa2bbf3c0108b
@@@ -1,4 -1,24 +1,24 @@@
- # Defining apt settings
+ # @summary Manages Apt configuration files.
+ #
+ # @see https://docs.puppetlabs.com/references/latest/type.html#file-attributes for more information on source and content parameters
+ #
+ # @param priority
+ #   Determines the order in which Apt processes the configuration file. Files with higher priority numbers are loaded first.
+ #
+ # @param ensure
+ #   Specifies whether the file should exist. Valid options: 'present', 'absent', and 'file'.
+ #
+ # @param source
+ #   Required, unless `content` is set. Specifies a source file to supply the content of the configuration file. Cannot be used in combination 
+ #   with `content`. Valid options: see link above for Puppet's native file type source attribute.
+ #
+ # @param content
+ #   Required, unless `source` is set. Directly supplies content for the configuration file. Cannot be used in combination with `source`. Valid 
+ #   options: see link above for Puppet's native file type content attribute.
+ #
+ # @param notify_update
+ #   Specifies whether to trigger an `apt-get update` run.
+ #
  define apt::setting (
    Variant[String, Integer, Array] $priority           = 50,
    Optional[Enum['file', 'present', 'absent']] $ensure = file,
  ) {
  
    if $content and $source {
 -    fail('apt::setting cannot have both content and source')
 +    fail(translate('apt::setting cannot have both content and source'))
    }
  
    if !$content and !$source {
 -    fail('apt::setting needs either of content or source')
 +    fail(translate('apt::setting needs either of content or source'))
    }
  
    $title_array = split($title, '-')
    $base_name = join(delete_at($title_array, 0), '-')
  
    assert_type(Pattern[/\Aconf\z/, /\Apref\z/, /\Alist\z/], $setting_type) |$a, $b| {
 -    fail("apt::setting resource name/title must start with either 'conf-', 'pref-' or 'list-'")
 +    fail(translate("apt::setting resource name/title must start with either 'conf-', 'pref-' or 'list-'"))
    }
  
    if $priority !~ Integer {
      # need this to allow zero-padded priority.
      assert_type(Pattern[/^\d+$/], $priority) |$a, $b| {
 -      fail('apt::setting priority must be an integer or a zero-padded integer')
 +      fail(translate('apt::setting priority must be an integer or a zero-padded integer'))
      }
    }
  
diff --combined manifests/source.pp
index 981933d0c21ce4d7b1b8664fa5f47b75d038c79f,9ccad35b119dcdaf27e6b3a13a7c43fdd9d857d2..cca03e97527ce921e93afc89db49d33c461a3580
@@@ -1,5 -1,59 +1,59 @@@
- # source.pp
- # add an apt source
+ # @summary Manages the Apt sources in /etc/apt/sources.list.d/.
+ #
+ # @example Install the puppetlabs apt source
+ #   apt::source { 'puppetlabs':
+ #     location => 'http://apt.puppetlabs.com',
+ #     repos    => 'main',
+ #     key      => {
+ #       id     => '6F6B15509CF8E59E6E469F327F438280EF8D349F',
+ #       server => 'hkps.pool.sks-keyservers.net',
+ #     },
+ #   }
+ #
+ # @param location
+ #   Required, unless ensure is set to 'absent'. Specifies an Apt repository. Valid options: a string containing a repository URL.
+ #
+ # @param comment
+ #   Supplies a comment for adding to the Apt source file.
+ #
+ # @param ensure
+ #   Specifies whether the Apt source file should exist. Valid options: 'present' and 'absent'.
+ #
+ # @param release
+ #   Specifies a distribution of the Apt repository.
+ #
+ # @param repos
+ #   Specifies a component of the Apt repository.
+ #
+ # @param include
+ #   Configures include options. Valid options: a hash of available keys.
+ # 
+ # @option include [Boolean] :deb
+ #   Specifies whether to request the distribution's compiled binaries. Default true.
+ #
+ # @option include [Boolean] :src
+ #   Specifies whether to request the distribution's uncompiled source code. Default false.
+ #
+ # @param key
+ #   Creates a declaration of the apt::key defined type. Valid options: a string to be passed to the `id` parameter of the `apt::key` 
+ #   defined type, or a hash of `parameter => value` pairs to be passed to `apt::key`'s `id`, `server`, `content`, `source`, and/or 
+ #   `options` parameters.
+ #
+ # @param pin
+ #   Creates a declaration of the apt::pin defined type. Valid options: a number or string to be passed to the `id` parameter of the 
+ #   `apt::pin` defined type, or a hash of `parameter => value` pairs to be passed to `apt::pin`'s corresponding parameters.
+ #
+ # @param architecture
+ #   Tells Apt to only download information for specified architectures. Valid options: a string containing one or more architecture names, 
+ #   separated by commas (e.g., 'i386' or 'i386,alpha,powerpc'). Default: undef (if unspecified, Apt downloads information for all architectures 
+ #   defined in the Apt::Architectures option).
+ #
+ # @param allow_unsigned
+ #   Specifies whether to authenticate packages from this release, even if the Release file is not signed or the signature can't be checked.
+ #
+ # @param notify_update
+ #   Specifies whether to trigger an `apt-get update` run.
+ #
  define apt::source(
    Optional[String] $location                    = undef,
    String $comment                               = $name,
@@@ -22,7 -76,7 +76,7 @@@
      if $facts['lsbdistcodename'] {
        $_release = $facts['lsbdistcodename']
      } else {
 -      fail('lsbdistcodename fact not available: release parameter required')
 +      fail(translate('lsbdistcodename fact not available: release parameter required'))
      }
    } else {
      $_release = $release
@@@ -30,7 -84,7 +84,7 @@@
  
    if $ensure == 'present' {
      if ! $location {
 -      fail('cannot create a source entry without specifying a location')
 +      fail(translate('cannot create a source entry without specifying a location'))
      }
      # Newer oses, do not need the package for HTTPS transport.
      $_transport_https_releases = [ 'wheezy', 'jessie', 'stretch', 'trusty', 'xenial' ]
@@@ -44,7 -98,7 +98,7 @@@
    if $key {
      if $key =~ Hash {
        unless $key['id'] {
 -        fail('key hash must contain at least an id entry')
 +        fail(translate('key hash must contain at least an id entry'))
        }
        $_key = merge($::apt::source_key_defaults, $key)
      } else {
          'origin'   => $host,
        }
      } else {
 -      fail('Received invalid value for pin parameter')
 +      fail(translate('Received invalid value for pin parameter'))
      }
      create_resources('apt::pin', { "${name}" => $_pin })
    }
index 912e35abcbf1001616e78b524515a07c10bfe677,de3be330219b70358aacf582b7598d09d9f6e78b..712fa5a8715bb52e518c401b84a7a86e942b94b3
@@@ -27,7 -27,7 +27,7 @@@ en
  
  def install_key(key)
    retry_on_error_matching do
-     shell("apt-key adv --keyserver hkps.pool.sks-keyservers.net --recv-keys #{key}")
+     shell("apt-key adv --keyserver pgp.mit.edu --recv-keys #{key}")
    end
  end
  
@@@ -384,7 -384,7 +384,7 @@@ hkps_pool_pp = <<-MANIFES
          apt_key { 'puppetlabs':
            id     => '#{PUPPETLABS_GPG_KEY_LONG_ID}',
            ensure => 'present',
-           server => 'hkps.pool.sks-keyservers.net',
+           server => 'pgp.mit.edu',
          }
    MANIFEST
  
@@@ -392,7 -392,7 +392,7 @@@ hkp_pool_pp = <<-MANIFES
          apt_key { 'puppetlabs':
            id     => '#{PUPPETLABS_GPG_KEY_FINGERPRINT}',
            ensure => 'present',
-           server => 'hkp://hkps.pool.sks-keyservers.net:80',
+           server => 'hkp://pgp.mit.edu:80',
          }
    MANIFEST
  
@@@ -653,7 -653,7 +653,7 @@@ describe 'apt_key' d
    end
  
    describe 'server =>' do
-     context 'with hkps.pool.sks-keyservers.net' do
+     context 'with pgp.mit.edu' do
        it 'works' do
          # Apply the manifest (Retry if timeout error is received from key pool)
          retry_on_error_matching do
        end
      end
  
-     context 'with hkp://hkps.pool.sks-keyservers.net:80' do
+     context 'with hkp://pgp.mit.edu:80' do
        it 'works' do
          retry_on_error_matching do
            apply_manifest(hkp_pool_pp, catch_failures: true)
            expect(r.stderr).to match(%r{could not resolve})
          end
        end
 +
 +      it 'fails with a socket error - i18n' do
 +        hosts.each do |host|
 +          on(host, "sed -i \"96i FastGettext.locale='ja'\" /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb")
 +          change_locale_on(host, 'ja_JP.utf-8')
 +        end
 +
 +        apply_manifest(socket_error_pp, expect_failures: true) do |r|
 +          expect(r.stderr).to match(%r{ƈǿŭŀḓ ƞǿŧ řḗşǿŀṽḗ})
 +        end
 +
 +        hosts.each do |host|
 +          on(host, 'sed -i "96d" /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb')
 +          change_locale_on(host, 'en_US')
 +        end
 +      end
      end
  
      # disabled when running in travis, security issues prevent FTP
            expect(r.stderr).to match(%r{could not resolve})
          end
        end
 +
 +      it 'fails with a socket error - i18n' do
 +        hosts.each do |host|
 +          on(host, "sed -i \"96i FastGettext.locale='ja'\" /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb")
 +          change_locale_on(host, 'ja_JP.utf-8')
 +        end
 +
 +        apply_manifest(ftp_socket_error_pp, expect_failures: true) do |r|
 +          expect(r.stderr).to match(%r{ƈǿŭŀḓ ƞǿŧ řḗşǿŀṽḗ})
 +        end
 +
 +        hosts.each do |host|
 +          on(host, 'sed -i "96d" /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb')
 +          change_locale_on(host, 'en_US')
 +        end
 +      end
      end
  
      context 'with https://' do
            expect(r.stderr).to match(%r{could not resolve})
          end
        end
 +
 +      it 'fails with a socket error - i18n' do
 +        hosts.each do |host|
 +          on(host, "sed -i \"96i FastGettext.locale='ja'\" /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb")
 +          change_locale_on(host, 'ja_JP.utf-8')
 +        end
 +
 +        apply_manifest(https_socket_error_pp, expect_failures: true) do |r|
 +          expect(r.stderr).to match(%r{ƈǿŭŀḓ ƞǿŧ řḗşǿŀṽḗ})
 +        end
 +
 +        hosts.each do |host|
 +          on(host, 'sed -i "96d" /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb')
 +          change_locale_on(host, 'en_US')
 +        end
 +      end
      end
  
      context 'with /path/that/exists' do