]> review.fuel-infra Code Review - puppet-modules/puppetlabs-apt.git/commitdiff
Merge pull request #673 from hunner/secondRelease
authorEric Putnam <putnam.eric@gmail.com>
Mon, 24 Apr 2017 18:29:50 +0000 (11:29 -0700)
committerGitHub <noreply@github.com>
Mon, 24 Apr 2017 18:29:50 +0000 (11:29 -0700)
Rebase of #668

16 files changed:
manifests/backports.pp
manifests/conf.pp
manifests/init.pp
manifests/key.pp
manifests/pin.pp
manifests/ppa.pp
manifests/setting.pp
manifests/source.pp
metadata.json
spec/acceptance/apt_spec.rb
spec/classes/apt_backports_spec.rb
spec/defines/key_compat_spec.rb
spec/defines/key_spec.rb
spec/defines/pin_spec.rb
spec/defines/source_compat_spec.rb
spec/defines/source_spec.rb

index 06165b6c2210433522beb0804378861630bfd902..4faad6157a7f31664555471071c211e177e56ce2 100644 (file)
@@ -1,26 +1,20 @@
 class apt::backports (
-  Optional[Variant[String, Stdlib::Compat::String]] $location = undef,
-  Optional[Variant[String, Stdlib::Compat::String]] $release = undef,
-  Optional[Variant[String, Stdlib::Compat::String]] $repos = undef,
-  Optional[Variant[String, Stdlib::Compat::String, Hash, Stdlib::Compat::Hash]] $key = undef,
-  Optional[Variant[Integer, Stdlib::Compat::Integer, String, Stdlib::Compat::String, Hash, Stdlib::Compat::Hash]] $pin  = 200,
+  Optional[String] $location                    = undef,
+  Optional[String] $release                     = undef,
+  Optional[String] $repos                       = undef,
+  Optional[Variant[String, Hash]] $key          = undef,
+  Optional[Variant[Integer, String, Hash]] $pin = 200,
 ){
   if $location {
-    validate_legacy(String, 'validate_string', $location)
     $_location = $location
   }
   if $release {
-    validate_legacy(String, 'validate_string', $release)
     $_release = $release
   }
   if $repos {
-    validate_legacy(String, 'validate_string', $repos)
     $_repos = $repos
   }
   if $key {
-    unless is_hash($key) {
-      validate_legacy(String, 'validate_string', $key)
-    }
     $_key = $key
   }
   if ($facts['lsbdistid'] == 'Debian' or $facts['lsbdistid'] == 'Ubuntu') {
index 364cae383ce346a86d00524763a5a09c1caa35b0..eea06861d9e3793e807a9e77d5388d0897941d3c 100644 (file)
@@ -1,8 +1,8 @@
 define apt::conf (
-  Optional[Variant[String, Stdlib::Compat::String]] $content                          = undef,
-  Enum['present', 'absent'] $ensure                                                   = present,
-  Variant[String, Stdlib::Compat::String, Integer, Stdlib::Compat::Integer] $priority = 50,
-  Optional[Boolean] $notify_update                                                    = undef,
+  Optional[String] $content          = undef,
+  Enum['present', 'absent'] $ensure  = present,
+  Variant[String, Integer] $priority = 50,
+  Optional[Boolean] $notify_update   = undef,
 ) {
 
   unless $ensure == 'absent' {
index 40a40aff07650e457eabd3d56d1960f33176607a..5654b3c6261f058d54172fe224cc515c8d491f7f 100644 (file)
@@ -3,32 +3,32 @@
 # Manage APT (Advanced Packaging Tool)
 #
 class apt (
-  Variant[Hash, Stdlib::Compat::Hash] $update_defaults,
-  Variant[Hash, Stdlib::Compat::Hash] $purge_defaults,
-  Variant[Hash, Stdlib::Compat::Hash] $proxy_defaults,
-  Variant[Hash, Stdlib::Compat::Hash] $include_defaults,
-  Variant[String, Stdlib::Compat::String] $provider,
-  Variant[String, Stdlib::Compat::String] $keyserver,
-  Optional[Variant[String, Stdlib::Compat::String]] $ppa_options,
-  Optional[Variant[String, Stdlib::Compat::String]] $ppa_package,
-  Optional[Variant[Hash, Stdlib::Compat::Hash]] $backports,
-  Variant[Hash, Stdlib::Compat::Hash] $confs                = {},
-  Variant[Hash, Stdlib::Compat::Hash] $update               = {},
-  Variant[Hash, Stdlib::Compat::Hash] $purge                = {},
-  Variant[Hash, Stdlib::Compat::Hash] $proxy                = {},
-  Variant[Hash, Stdlib::Compat::Hash] $sources              = {},
-  Variant[Hash, Stdlib::Compat::Hash] $keys                 = {},
-  Variant[Hash, Stdlib::Compat::Hash] $ppas                 = {},
-  Variant[Hash, Stdlib::Compat::Hash] $pins                 = {},
-  Variant[Hash, Stdlib::Compat::Hash] $settings             = {},
-  Variant[String, Stdlib::Compat::String] $root             = '/etc/apt',
-  Variant[String, Stdlib::Compat::String] $sources_list     = "${root}/sources.list",
-  Variant[String, Stdlib::Compat::String] $sources_list_d   = "${root}/sources.list.d",
-  Variant[String, Stdlib::Compat::String] $conf_d           = "${root}/apt.conf.d",
-  Variant[String, Stdlib::Compat::String] $preferences      = "${root}/preferences",
-  Variant[String, Stdlib::Compat::String] $preferences_d    = "${root}/preferences.d",
-  Variant[Hash, Stdlib::Compat::Hash] $config_files         = { conf => { path => $conf_d, ext => '' }, pref => { path => $preferences_d, ext => '.pref' }, list => { path => $sources_list_d, ext => '.list' } },
-  Variant[Hash, Stdlib::Compat::Hash] $source_key_defaults  = { 'server' => $keyserver, 'options' => undef, 'content' => undef, 'source' => undef },
+  Hash $update_defaults,
+  Hash $purge_defaults,
+  Hash $proxy_defaults,
+  Hash $include_defaults,
+  String $provider,
+  String $keyserver,
+  Optional[String] $ppa_options,
+  Optional[String] $ppa_package,
+  Optional[Hash] $backports,
+  Hash $confs               = {},
+  Hash $update              = {},
+  Hash $purge               = {},
+  Hash $proxy               = {},
+  Hash $sources             = {},
+  Hash $keys                = {},
+  Hash $ppas                = {},
+  Hash $pins                = {},
+  Hash $settings            = {},
+  String $root              = '/etc/apt',
+  String $sources_list      = "${root}/sources.list",
+  String $sources_list_d    = "${root}/sources.list.d",
+  String $conf_d            = "${root}/apt.conf.d",
+  String $preferences       = "${root}/preferences",
+  String $preferences_d     = "${root}/preferences.d",
+  Hash $config_files        = { conf => { path => $conf_d, ext => '' }, pref => { path => $preferences_d, ext => '.pref' }, list => { path => $sources_list_d, ext => '.list' } },
+  Hash $source_key_defaults = { 'server' => $keyserver, 'options' => undef, 'content' => undef, 'source' => undef },
 ) {
 
   if $facts['osfamily'] != 'Debian' {
@@ -36,65 +36,50 @@ class apt (
   }
 
   $frequency_options = ['always','daily','weekly','reluctantly']
-  validate_legacy(Hash, 'validate_hash', $update)
+
   if $update['frequency'] {
     validate_re($update['frequency'], $frequency_options)
   }
   if $update['timeout'] {
-    unless is_integer($update['timeout']) {
-      fail('timeout value for update must be an integer')
-    }
+    assert_type(Integer, $update['timeout'])
   }
   if $update['tries'] {
-    unless is_integer($update['tries']) {
-      fail('tries value for update must be an integer')
-    }
+    assert_type(Integer, $update['tries'])
   }
 
   $_update = merge($::apt::update_defaults, $update)
   include ::apt::update
 
-  validate_legacy(Hash, 'validate_hash', $purge)
   if $purge['sources.list'] {
-    validate_legacy(Boolean, 'validate_bool', $purge['sources.list'])
+    assert_type(Boolean, $purge['sources.list'])
   }
   if $purge['sources.list.d'] {
-    validate_legacy(Boolean, 'validate_bool', $purge['sources.list.d'])
+    assert_type(Boolean, $purge['sources.list.d'])
   }
   if $purge['preferences'] {
-    validate_legacy(Boolean, 'validate_bool', $purge['preferences'])
+    assert_type(Boolean, $purge['preferences'])
   }
   if $purge['preferences.d'] {
-    validate_legacy(Boolean, 'validate_bool', $purge['preferences.d'])
+    assert_type(Boolean, $purge['preferences.d'])
   }
 
   $_purge = merge($::apt::purge_defaults, $purge)
 
-  validate_hash($proxy)
   if $proxy['ensure'] {
     validate_re($proxy['ensure'], ['file', 'present', 'absent'])
   }
   if $proxy['host'] {
-    validate_legacy(String, 'validate_string', $proxy['host'])
+    assert_type(String, $proxy['host'])
   }
   if $proxy['port'] {
-    unless is_integer($proxy['port']) {
-      fail('$proxy port must be an integer')
-    }
+    assert_type(Integer, $proxy['port'])
   }
-  if $proxy['https'] {
-    validate_legacy(Boolean, 'validate_bool', $proxy['https'])
+  if $proxy['https']{
+    assert_type(Boolean, $proxy['https'])
   }
 
   $_proxy = merge($apt::proxy_defaults, $proxy)
 
-  validate_legacy(Hash, 'validate_hash', $confs)
-  validate_legacy(Hash, 'validate_hash', $sources)
-  validate_legacy(Hash, 'validate_hash', $keys)
-  validate_legacy(Hash, 'validate_hash', $settings)
-  validate_legacy(Hash, 'validate_hash', $ppas)
-  validate_legacy(Hash, 'validate_hash', $pins)
-
   $confheadertmp = epp('apt/_conf_header.epp')
   $proxytmp = epp('apt/proxy.epp', {'proxies' => $_proxy})
   $updatestamptmp = epp('apt/15update-stamp.epp')
index 9a244b5065ac049c58722fb8e56e8fb6258f1669..dfa1daf2b61935886b79cf22b5876511807397c4 100644 (file)
 # == Define: apt::key
 define apt::key (
-    Variant[String, Stdlib::Compat::String] $id                                         = $title,
-    Enum['present', 'absent'] $ensure                                                   = present,
-    Optional[Variant[String, Stdlib::Compat::String]] $content                          = undef,
-    Optional[Variant[String, Stdlib::Compat::String]] $source                           = undef,
-    Variant[String, Stdlib::Compat::String] $server                                     = $::apt::keyserver,
-    Optional[Variant[String, Stdlib::Compat::String]] $options                          = undef,
-    Optional[Variant[String, Stdlib::Compat::String, Hash, Stdlib::Compat::Hash]] $key  = undef,
-    Optional[Variant[String, Stdlib::Compat::String]] $key_content                      = undef,
-    Optional[Variant[String, Stdlib::Compat::String]] $key_source                       = undef,
-    Optional[Variant[String, Stdlib::Compat::String]] $key_server                       = undef,
-    Optional[Variant[String, Stdlib::Compat::String]] $key_options                      = undef,
+    String $id                           = $title,
+    Enum['present', 'absent'] $ensure    = present,
+    Optional[String] $content            = undef,
+    Optional[String] $source             = undef,
+    String $server                       = $::apt::keyserver,
+    Optional[String] $options            = undef,
     ) {
 
-  if $key != undef {
-    deprecation('apt $key', '$key is deprecated and will be removed in the next major release. Please use $id instead.')
-    $_id = $key
-  } else {
-    $_id = $id
-  }
-
-  if $key_content != undef {
-    deprecation('apt $key_content', '$key_content is deprecated and will be removed in the next major release. Please use $content instead.')
-    $_content = $key_content
-  } else {
-    $_content = $content
-  }
-
-  if $key_source != undef {
-    deprecation('apt $key_source', '$key_source is deprecated and will be removed in the next major release. Please use $source instead.')
-    $_source = $key_source
-  } else {
-    $_source = $source
-  }
-
-  if $key_server != undef {
-    deprecation('apt $key_server', '$key_server is deprecated and will be removed in the next major release. Please use $server instead.')
-    $_server = $key_server
-  } else {
-    $_server = $server
-  }
-
-  if $key_options != undef {
-    deprecation('apt $key_options', '$key_options is deprecated and will be removed in the next major release. Please use $options instead.')
-    $_options = $key_options
-  } else {
-    $_options = $options
-  }
-
-  validate_re($_id, ['\A(0x)?[0-9a-fA-F]{8}\Z', '\A(0x)?[0-9a-fA-F]{16}\Z', '\A(0x)?[0-9a-fA-F]{40}\Z'])
-  validate_re($ensure, ['\A(absent|present)\Z',])
-
-  if $_content {
-    validate_legacy(String, 'validate_string', $_content)
-  }
-
-  if $_source {
-    validate_re($_source, ['\Ahttps?:\/\/', '\Aftp:\/\/', '\A\/\w+'])
-  }
+  validate_re($id, ['\A(0x)?[0-9a-fA-F]{8}\Z', '\A(0x)?[0-9a-fA-F]{16}\Z', '\A(0x)?[0-9a-fA-F]{40}\Z'])
 
-  if $_server {
-    validate_re($_server,['\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$'])
+  if $source {
+    validate_re($source, ['\Ahttps?:\/\/', '\Aftp:\/\/', '\A\/\w+'])
   }
 
-  if $_options {
-    validate_legacy(String, 'validate_string', $_options)
+  if $server {
+    validate_re($server,['\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$'])
   }
 
   case $ensure {
     present: {
-      if defined(Anchor["apt_key ${_id} absent"]){
-        fail("key with id ${_id} already ensured as absent")
+      if defined(Anchor["apt_key ${id} absent"]){
+        fail("key with id ${id} already ensured as absent")
       }
 
-      if !defined(Anchor["apt_key ${_id} present"]) {
+      if !defined(Anchor["apt_key ${id} present"]) {
         apt_key { $title:
           ensure  => $ensure,
-          id      => $_id,
-          source  => $_source,
-          content => $_content,
-          server  => $_server,
-          options => $_options,
-        } -> anchor { "apt_key ${_id} present": }
+          id      => $id,
+          source  => $source,
+          content => $content,
+          server  => $server,
+          options => $options,
+        } -> anchor { "apt_key ${id} present": }
       }
     }
 
     absent: {
-      if defined(Anchor["apt_key ${_id} present"]){
-        fail("key with id ${_id} already ensured as present")
+      if defined(Anchor["apt_key ${id} present"]){
+        fail("key with id ${id} already ensured as present")
       }
 
-      if !defined(Anchor["apt_key ${_id} absent"]){
+      if !defined(Anchor["apt_key ${id} absent"]){
         apt_key { $title:
           ensure  => $ensure,
-          id      => $_id,
-          source  => $_source,
-          content => $_content,
-          server  => $_server,
-          options => $_options,
-        } -> anchor { "apt_key ${_id} absent": }
+          id      => $id,
+          source  => $source,
+          content => $content,
+          server  => $server,
+          options => $options,
+        } -> anchor { "apt_key ${id} absent": }
       }
     }
 
index 5b9dc1d408e2daf8068c70a046c5e9d0074f5f9e..ee32de4694a5a50c7dda1cd48f89c8c1de214da7 100644 (file)
@@ -2,19 +2,19 @@
 # pin a release in apt, useful for unstable repositories
 
 define apt::pin(
-  Optional[Enum['file', 'present', 'absent']] $ensure                             = present,
-  Optional[Variant[String, Stdlib::Compat::String]] $explanation                  = undef,
-  Variant[Integer,  Stdlib::Compat::Integer] $order                               = 50,
-  Variant[String, Stdlib::Compat::String, Stdlib::Compat::Array, Array] $packages = '*',
-  Variant[Numeric, String, Stdlib::Compat::String] $priority                      = 0,
-  Optional[Variant[String, Stdlib::Compat::String]] $release                      = '', # a=
-  Optional[Variant[String, Stdlib::Compat::String]] $origin                       = '',
-  Optional[Variant[String, Stdlib::Compat::String]] $version                      = '',
-  Optional[Variant[String, Stdlib::Compat::String]] $codename                     = '', # n=
-  Optional[Variant[String, Stdlib::Compat::String]] $release_version              = '', # v=
-  Optional[Variant[String, Stdlib::Compat::String]] $component                    = '', # c=
-  Optional[Variant[String, Stdlib::Compat::String]] $originator                   = '', # o=
-  Optional[Variant[String, Stdlib::Compat::String]] $label                        = '',  # l=
+  Optional[Enum['file', 'present', 'absent']] $ensure = present,
+  Optional[String] $explanation                       = undef,
+  Variant[Integer] $order                             = 50,
+  Variant[String, Array] $packages                    = '*',
+  Variant[Numeric, String] $priority                  = 0,
+  Optional[String] $release                           = '', # a=
+  Optional[String] $origin                            = '',
+  Optional[String] $version                           = '',
+  Optional[String] $codename                          = '', # n=
+  Optional[String] $release_version                   = '', # v=
+  Optional[String] $component                         = '', # c=
+  Optional[String] $originator                        = '', # o=
+  Optional[String] $label                             = '',  # l=
 ) {
 
   if $explanation {
index adce47cae0645fdc4e7ef87ed88740a96bae8c27..a67e1a19457e204ce7e5cfb1237115b0081bbc0d 100644 (file)
@@ -1,10 +1,10 @@
 # ppa.pp
 define apt::ppa(
-  Variant[String, Stdlib::Compat::String] $ensure                 = 'present',
-  Optional[Variant[String, Stdlib::Compat::String]] $options      = $::apt::ppa_options,
-  Optional[Variant[String, Stdlib::Compat::String]] $release      = $facts['lsbdistcodename'],
-  Optional[Variant[String, Stdlib::Compat::String]] $package_name = $::apt::ppa_package,
-  Boolean $package_manage                                         = false,
+  String $ensure                 = 'present',
+  Optional[String] $options      = $::apt::ppa_options,
+  Optional[String] $release      = $facts['lsbdistcodename'],
+  Optional[String] $package_name = $::apt::ppa_package,
+  Boolean $package_manage        = false,
 ) {
   unless $release {
     fail('lsbdistcodename fact not available: release parameter required')
index 123bb2f70e29e9c2c559c1c3fd455e252b39863b..507ec9495d66ac2e6d305f71596996d34e7e1973 100644 (file)
@@ -1,10 +1,9 @@
 define apt::setting (
-  Variant[String, Stdlib::Compat::String, Integer, Stdlib::Compat::Integer, Array, Stdlib::Compat::Array] $priority = 50,
-  Optional[Enum['file', 'present', 'absent']] $ensure                                                               = file,
-  Optional[Variant[String, Stdlib::Compat::String]] $source                                                         = undef,
-  Optional[Variant[String, Stdlib::Compat::String]] $content                                                        = undef,
-  Optional[Boolean] $notify_update                                                                                  = true,
-
+  Variant[String, Integer, Array] $priority           = 50,
+  Optional[Enum['file', 'present', 'absent']] $ensure = file,
+  Optional[String] $source                            = undef,
+  Optional[String] $content                           = undef,
+  Boolean $notify_update                              = true,
 ) {
 
   if $content and $source {
@@ -15,10 +14,6 @@ define apt::setting (
     fail('apt::setting needs either of content or source')
   }
 
-  if $notify_update {
-    validate_legacy(Boolean, 'validate_bool', $notify_update)
-  }
-
   $title_array = split($title, '-')
   $setting_type = $title_array[0]
   $base_name = join(delete_at($title_array, 0), '-')
@@ -30,14 +25,6 @@ define apt::setting (
     validate_re($priority, '^\d+$', 'apt::setting priority must be an integer or a zero-padded integer')
   }
 
-  if $source {
-    validate_legacy(String, 'validate_string', $source)
-  }
-
-  if $content {
-    validate_legacy(String, 'validate_string', $content)
-  }
-
   if ($setting_type == 'list') or ($setting_type == 'pref') {
     $_priority = ''
   } else {
index 8db3b28ef12457c501f498017372fe4cd6720458..ad80977c68cda73576dbf30b30c06bcd00bbcd54 100644 (file)
@@ -1,54 +1,24 @@
 # source.pp
 # add an apt source
 define apt::source(
-  Optional[Variant[String, Stdlib::Compat::String]] $location                         = undef,
-  Variant[String, Stdlib::Compat::String] $comment                                    = $name,
-  Variant[String, Stdlib::Compat::String] $ensure                                     = present,
-  Optional[Variant[String, Stdlib::Compat::String]] $release                          = undef,
-  Variant[String, Stdlib::Compat::String] $repos                                      = 'main',
-  Optional[Variant[Hash, Stdlib::Compat::Hash]] $include                              = {},
-  Optional[Variant[String, Stdlib::Compat::String, Hash, Stdlib::Compat::Hash]] $key  = undef,
-  $pin                                                                                = undef,
-  Optional[Variant[String, Stdlib::Compat::String]] $architecture                     = undef,
-  Boolean $allow_unsigned                                                             = false,
-  Boolean $notify_update                                                              = true,
-  Optional[Variant[String, Stdlib::Compat::String]] $key_server                       = undef,
-  Optional[Variant[String, Stdlib::Compat::String]] $key_content                      = undef,
-  Optional[Variant[String, Stdlib::Compat::String]] $key_source                       = undef,
-  Optional[Boolean] $include_src                                                      = undef,
-  Optional[Boolean] $include_deb                                                      = undef,
-  $required_packages                                                                  = undef,
-  $trusted_source                                                                     = undef,
+  Optional[String] $location           = undef,
+  String $comment                      = $name,
+  String $ensure                       = present,
+  Optional[String] $release            = undef,
+  String $repos                        = 'main',
+  Optional[Variant[Hash]] $include     = {},
+  Optional[Variant[String, Hash]] $key = undef,
+  $pin                                 = undef,
+  Optional[String] $architecture       = undef,
+  Boolean $allow_unsigned              = false,
+  Boolean $notify_update               = true,
 ) {
 
-  validate_legacy(String, 'validate_string', $architecture, $comment, $location, $repos)
-  validate_legacy(Boolean, 'validate_bool', $allow_unsigned)
-  validate_legacy(Hash, 'validate_hash', $include)
-
   # This is needed for compat with 1.8.x
   include ::apt
 
   $_before = Apt::Setting["list-${title}"]
 
-  if $required_packages != undef {
-    deprecation('apt $required_packages', '$required_packages is deprecated and will be removed in the next major release, please use package resources instead.')
-    exec { "Required packages: '${required_packages}' for ${name}":
-      command     => "${::apt::provider} -y install ${required_packages}",
-      logoutput   => 'on_failure',
-      refreshonly => true,
-      tries       => 3,
-      try_sleep   => 1,
-      before      => $_before,
-    }
-  }
-
-  if $trusted_source != undef {
-    deprecation('apt $trusted_source', '$trusted_source is deprecated and will be removed in the next major release, please use $allow_unsigned instead.')
-    $_allow_unsigned = $trusted_source
-  } else {
-    $_allow_unsigned = $allow_unsigned
-  }
-
   if ! $release {
     if $facts['lsbdistcodename'] {
       $_release = $facts['lsbdistcodename']
@@ -63,36 +33,17 @@ define apt::source(
     fail('cannot create a source entry without specifying a location')
   }
 
-  if $include_src != undef and $include_deb != undef {
-    $_deprecated_include = {
-      'src' => $include_src,
-      'deb' => $include_deb,
-    }
-  } elsif $include_src != undef {
-    $_deprecated_include = { 'src' => $include_src }
-  } elsif $include_deb != undef {
-    $_deprecated_include = { 'deb' => $include_deb }
-  } else {
-    $_deprecated_include = {}
-  }
-
-  $includes = merge($::apt::include_defaults, $_deprecated_include, $include)
-
-  $_deprecated_key = {
-    'key_server'  => $key_server,
-    'key_content' => $key_content,
-    'key_source'  => $key_source,
-  }
+  $includes = merge($::apt::include_defaults, $include)
 
   if $key {
     if is_hash($key) {
       unless $key['id'] {
         fail('key hash must contain at least an id entry')
       }
-      $_key = merge($::apt::source_key_defaults, $_deprecated_key, $key)
+      $_key = merge($::apt::source_key_defaults, $key)
     } else {
       validate_legacy(String, 'validate_string', $key)
-      $_key = merge( { 'id' => $key }, $_deprecated_key)
+      $_key = { 'id' => $key }
     }
   }
 
@@ -102,7 +53,7 @@ define apt::source(
     'comment'        => $comment,
     'includes'       => $includes,
     'architecture'   => $architecture,
-    'allow_unsigned' => $_allow_unsigned,
+    'allow_unsigned' => $allow_unsigned,
     'location'       => $location,
     'release'        => $_release,
     'repos'          => $repos,
@@ -136,16 +87,13 @@ define apt::source(
   if $key and ($ensure == 'present') {
     if is_hash($_key) {
       apt::key { "Add key: ${$_key['id']} from Apt::Source ${title}":
-        ensure      => present,
-        id          => $_key['id'],
-        server      => $_key['server'],
-        content     => $_key['content'],
-        source      => $_key['source'],
-        options     => $_key['options'],
-        key_server  => $_key['key_server'],
-        key_content => $_key['key_content'],
-        key_source  => $_key['key_source'],
-        before      => $_before,
+        ensure  => present,
+        id      => $_key['id'],
+        server  => $_key['server'],
+        content => $_key['content'],
+        source  => $_key['source'],
+        options => $_key['options'],
+        before  => $_before,
       }
     }
   }
index c4f9bb7cf9708488c3a7750ef0537b5172e2cf6d..f4fadeb4c4844651262333f10ec90a2dfacb472f 100644 (file)
@@ -1,6 +1,6 @@
 {
   "name": "puppetlabs-apt",
-  "version": "3.0.0",
+  "version": "4.0.0",
   "author": "Puppet Labs",
   "summary": "Provides an interface for managing Apt source, key, and definitions with Puppet",
   "license": "Apache-2.0",
index 52415f5afaecb4e0cfe28fbe2af689c3ffad3f77..df312a756041025184ffd2c8d21f5f0de5b7d601 100644 (file)
@@ -33,8 +33,8 @@ describe 'apt class' do
       class { 'apt':
         update => {
           'frequency' => 'always',
-          'timeout'   => '400',
-          'tries'     => '3',
+          'timeout'   => 400,
+          'tries'     => 3,
         },
         purge => {
           'sources.list'   => true,
index 2e8a9b4b09e65c90f45652d0db50e282342d5924..aae4bb0cc150d3c5c977d427c4e1573ed13a525c 100644 (file)
@@ -224,7 +224,7 @@ describe 'apt::backports', :type => :class do
       it do
         expect {
           subject.call
-        }.to raise_error(Puppet::Error, /expects a String value/)
+        }.to raise_error(Puppet::Error, /expects a value of type Undef or String/)
       end
     end
     context 'invalid release' do
@@ -236,7 +236,7 @@ describe 'apt::backports', :type => :class do
       it do
         expect {
           subject.call
-        }.to raise_error(Puppet::Error, /expects a String value/)
+        }.to raise_error(Puppet::Error, /expects a value of type Undef or String/)
       end
     end
     context 'invalid repos' do
@@ -248,7 +248,7 @@ describe 'apt::backports', :type => :class do
       it do
         expect {
           subject.call
-        }.to raise_error(Puppet::Error, /expects a String value/)
+        }.to raise_error(Puppet::Error, /expects a value of type Undef or String/)
       end
     end
     context 'invalid key' do
@@ -260,7 +260,7 @@ describe 'apt::backports', :type => :class do
       it do
         expect {
           subject.call
-        }.to raise_error(Puppet::Error, /expects a value of type String, Hash,/)
+        }.to raise_error(Puppet::Error, /expects a value of type Undef, String, or Hash, got Boolean/)
       end
     end
     context 'invalid pin' do
@@ -272,7 +272,7 @@ describe 'apt::backports', :type => :class do
       it do
         expect {
           subject.call
-        }.to raise_error(Puppet::Error, /parameter 'pin' expects a value of type Integer, Pattern/)
+        }.to raise_error(Puppet::Error, /expects a value of type Undef, Integer, String, or Hash, got Boolean/)
       end
     end
   end
index b298f8cfbcb96362bad05213871fdf8f92aaa88d..66e9f7fe90713b179dae0cac9b15ea54cc797c5d 100644 (file)
@@ -26,7 +26,6 @@ describe 'apt::key', :type => :define do
           :source            => nil,
           :server            => 'keyserver.ubuntu.com',
           :content           => nil,
-          :keyserver_options => nil,
         })
       }
       it 'contains the apt_key present anchor' do
@@ -40,7 +39,7 @@ describe 'apt::key', :type => :define do
       end
 
       let :params do {
-        :key => GPG_KEY_ID,
+        :id => GPG_KEY_ID,
       } end
 
       it 'contains the apt_key' do
@@ -50,7 +49,6 @@ describe 'apt::key', :type => :define do
           :source            => nil,
           :server            => 'keyserver.ubuntu.com',
           :content           => nil,
-          :keyserver_options => nil,
         })
       end
       it 'contains the apt_key present anchor' do
@@ -70,7 +68,6 @@ describe 'apt::key', :type => :define do
           :source            => nil,
           :server            => 'keyserver.ubuntu.com',
           :content           => nil,
-          :keyserver_options => nil,
         })
       end
       it 'contains the apt_key absent anchor' do
@@ -80,10 +77,10 @@ describe 'apt::key', :type => :define do
 
     describe 'set a bunch of things!' do
       let :params do {
-        :key_content => 'GPG key content',
-        :key_source => 'http://apt.puppetlabs.com/pubkey.gpg',
-        :key_server => 'pgp.mit.edu',
-        :key_options => 'debug',
+        :content => 'GPG key content',
+        :source => 'http://apt.puppetlabs.com/pubkey.gpg',
+        :server => 'pgp.mit.edu',
+        :options => 'debug',
       } end
 
       it 'contains the apt_key' do
@@ -92,7 +89,7 @@ describe 'apt::key', :type => :define do
           :ensure  => 'present',
           :source  => 'http://apt.puppetlabs.com/pubkey.gpg',
           :server  => 'pgp.mit.edu',
-          :content => params[:key_content],
+          :content => params[:content],
           :options => 'debug',
         })
       end
@@ -103,7 +100,7 @@ describe 'apt::key', :type => :define do
 
     context "domain with dash" do
       let(:params) do{
-        :key_server => 'p-gp.m-it.edu',
+        :server => 'p-gp.m-it.edu',
       } end
       it 'contains the apt_key' do
         is_expected.to contain_apt_key(title).with({
@@ -116,7 +113,7 @@ describe 'apt::key', :type => :define do
     context "url" do
       let :params do
         {
-          :key_server => 'hkp://pgp.mit.edu',
+          :server => 'hkp://pgp.mit.edu',
         }
       end
       it 'contains the apt_key' do
@@ -129,7 +126,7 @@ describe 'apt::key', :type => :define do
     context "url with port number" do
       let :params do
         {
-          :key_server => 'hkp://pgp.mit.edu:80',
+          :server => 'hkp://pgp.mit.edu:80',
         }
       end
       it 'contains the apt_key' do
@@ -144,7 +141,7 @@ describe 'apt::key', :type => :define do
   describe 'validation' do
     context "domain begin with dash" do
       let(:params) do{
-        :key_server => '-pgp.mit.edu',
+        :server => '-pgp.mit.edu',
       } end
       it 'fails' do
         expect { subject.call } .to raise_error(/does not match/)
@@ -153,7 +150,7 @@ describe 'apt::key', :type => :define do
 
     context "domain begin with dot" do
       let(:params) do{
-        :key_server => '.pgp.mit.edu',
+        :server => '.pgp.mit.edu',
       } end
       it 'fails' do
         expect { subject.call } .to raise_error(/does not match/)
@@ -162,7 +159,7 @@ describe 'apt::key', :type => :define do
 
     context "domain end with dot" do
       let(:params) do{
-        :key_server => "pgp.mit.edu.",
+        :server => "pgp.mit.edu.",
       } end
       it 'fails' do
         expect { subject.call } .to raise_error(/does not match/)
@@ -171,7 +168,7 @@ describe 'apt::key', :type => :define do
     context "exceed character url" do
       let :params do
         {
-          :key_server => 'hkp://pgpiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.mit.edu'
+          :server => 'hkp://pgpiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.mit.edu'
         }
       end
       it 'fails' do
@@ -181,7 +178,7 @@ describe 'apt::key', :type => :define do
     context "incorrect port number url" do
       let :params do
         {
-          :key_server => 'hkp://pgp.mit.edu:8008080'
+          :server => 'hkp://pgp.mit.edu:8008080'
         }
       end
       it 'fails' do
@@ -191,7 +188,7 @@ describe 'apt::key', :type => :define do
     context "incorrect protocol for  url" do
       let :params do
         {
-          :key_server => 'abc://pgp.mit.edu:80'
+          :server => 'abc://pgp.mit.edu:80'
         }
       end
       it 'fails' do
@@ -201,7 +198,7 @@ describe 'apt::key', :type => :define do
     context "missing port number url" do
       let :params do
         {
-          :key_server => 'hkp://pgp.mit.edu:'
+          :server => 'hkp://pgp.mit.edu:'
         }
       end
       it 'fails' do
@@ -211,7 +208,7 @@ describe 'apt::key', :type => :define do
     context "url ending with a dot" do
       let :params do
         {
-          :key_server => 'hkp://pgp.mit.edu.'
+          :server => 'hkp://pgp.mit.edu.'
         }
       end
       it 'fails' do
@@ -220,7 +217,7 @@ describe 'apt::key', :type => :define do
     end
     context "url begin with a dash" do
       let(:params) do{
-        :key_server => "hkp://-pgp.mit.edu",
+        :server => "hkp://-pgp.mit.edu",
       } end
       it 'fails' do
         expect { subject.call }.to raise_error(/does not match/)
@@ -237,7 +234,7 @@ describe 'apt::key', :type => :define do
 
     context 'invalid source' do
       let :params do {
-        :key_source => 'afp://puppetlabs.com/key.gpg',
+        :source => 'afp://puppetlabs.com/key.gpg',
       } end
       it 'fails' do
         expect { subject.call }.to raise_error(/does not match/)
@@ -246,16 +243,16 @@ describe 'apt::key', :type => :define do
 
     context 'invalid content' do
       let :params do {
-        :key_content => [],
+        :content => [],
       } end
       it 'fails' do
-        expect { subject.call }.to raise_error(/expects a String value/)
+        expect { subject.call }.to raise_error(/expects a value of type Undef or String/)
       end
     end
 
     context 'invalid server' do
       let :params do {
-        :key_server => 'two bottles of rum',
+        :server => 'two bottles of rum',
       } end
       it 'fails' do
         expect { subject.call }.to raise_error(/does not match/)
@@ -264,10 +261,10 @@ describe 'apt::key', :type => :define do
 
     context 'invalid keyserver_options' do
       let :params do {
-        :key_options => {},
+        :options => {},
       } end
       it 'fails' do
-        expect { subject.call }.to raise_error(/expects a String value/)
+        expect { subject.call }.to raise_error(/expects a value of type Undef or String/)
       end
     end
 
@@ -285,12 +282,12 @@ describe 'apt::key', :type => :define do
     describe 'duplication' do
       context 'two apt::key resources for same key, different titles' do
         let :pre_condition do
-          "#{super()}\napt::key { 'duplicate': key => '#{title}', }"
+          "#{super()}\napt::key { 'duplicate': id => '#{title}', }"
         end
 
         it 'contains the duplicate apt::key resource' do
           is_expected.to contain_apt__key('duplicate').with({
-            :key    => title,
+            :id    => title,
             :ensure => 'present',
           })
         end
@@ -320,7 +317,7 @@ describe 'apt::key', :type => :define do
 
       context 'two apt::key resources, different ensure' do
         let :pre_condition do
-          "#{super()}\napt::key { 'duplicate': key => '#{title}', ensure => 'absent', }"
+          "#{super()}\napt::key { 'duplicate': id => '#{title}', ensure => 'absent', }"
         end
         it 'informs the user of the impossibility' do
           expect { subject.call }.to raise_error(/already ensured as absent/)
index 1f878c3e8c65fafc5f78200e1c93da282bed0e2d..13616d97acc14f73c8d6dd84c5fb6b2402fb39a6 100644 (file)
@@ -251,7 +251,7 @@ describe 'apt::key' do
         :content => [],
       } end
       it 'fails' do
-        expect { subject.call }.to raise_error(/expects a String value/)
+        expect { subject.call }.to raise_error(/expects a value of type Undef or String/)
       end
     end
 
@@ -269,7 +269,7 @@ describe 'apt::key' do
         :options => {},
       } end
       it 'fails' do
-        expect { subject.call }.to raise_error(/expects a String value/)
+        expect { subject.call }.to raise_error(/expects a value of type Undef or String/)
       end
     end
 
index 4f51cf3d715c181bb41b7ebc274faa937fc8376c..50890fcf6b8be39d4fa8991dbe8285be2e2bd561 100644 (file)
@@ -84,7 +84,7 @@ describe 'apt::pin', :type => :define do
       it do
         expect {
           subject.call
-        }.to raise_error(Puppet::Error, /expects a value of type Integer/)
+        }.to raise_error(Puppet::Error, /expects an Integer value, got String/)
       end
     end
 
index a3849077288ddbd39ac96c9817c567be77fdfcdc..88cd625e1a5bcad94b9d5ce9c21517130698b044 100644 (file)
@@ -20,8 +20,7 @@ describe 'apt::source', :type => :define do
 
     let :params do
       {
-        'include_deb' => false,
-        'include_src' => true,
+        'include' => { 'deb' => false, 'src' => true },
         'location'    => 'http://debian.mirror.iweb.ca/debian/',
       }
     end
@@ -42,19 +41,15 @@ describe 'apt::source', :type => :define do
     end
     let :params do
       {
-        'comment'           => 'foo',
-        'location'          => 'http://debian.mirror.iweb.ca/debian/',
-        'release'           => 'sid',
-        'repos'             => 'testing',
-        'include_src'       => false,
-        'required_packages' => 'vim',
-        'key'               => GPG_KEY_ID,
-        'key_server'        => 'pgp.mit.edu',
-        'key_content'       => 'GPG key content',
-        'key_source'        => 'http://apt.puppetlabs.com/pubkey.gpg',
-        'pin'               => '10',
-        'architecture'      => 'x86_64',
-        'trusted_source'    => true,
+        'comment'        => 'foo',
+        'location'       => 'http://debian.mirror.iweb.ca/debian/',
+        'release'        => 'sid',
+        'repos'          => 'testing',
+        'include'        => { 'src' => false },
+        'key'            => GPG_KEY_ID,
+        'pin'            => '10',
+        'architecture'   => 'x86_64',
+        'allow_unsigned' => true,
       }
     end
 
@@ -68,26 +63,14 @@ describe 'apt::source', :type => :define do
     })
     }
 
-    it { is_expected.to contain_exec("Required packages: 'vim' for my_source").that_comes_before('Apt::Setting[list-my_source]').with({
-      'command'     => '/usr/bin/apt-get -y install vim',
-      'logoutput'   => 'on_failure',
-      'refreshonly' => true,
-      'tries'       => '3',
-      'try_sleep'   => '1',
-    })
-    }
-
     it { is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with({
       'ensure' => 'present',
       'id'  => GPG_KEY_ID,
-      'key_server' => 'pgp.mit.edu',
-      'key_content' => 'GPG key content',
-      'key_source' => 'http://apt.puppetlabs.com/pubkey.gpg',
     })
     }
   end
 
-  context 'trusted_source true' do
+  context 'allow_unsigned true' do
     let :facts do
       {
         :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
@@ -99,9 +82,9 @@ describe 'apt::source', :type => :define do
     end
     let :params do
       {
-        'include_src'    => false,
+        'include'        => {'src' => false},
         'location'       => 'http://debian.mirror.iweb.ca/debian/',
-        'trusted_source' => true,
+        'allow_unsigned' => true,
       }
     end
 
index 0972512699d917132ac1d6e3d8c134e7c6b51120..5b37446f27095a737ce5420e4aeb0a9ef1ffc3ed 100644 (file)
@@ -226,7 +226,7 @@ describe 'apt::source' do
     let :params do
       {
         :location     => 'hello.there',
-        :include      => {'deb' => false, 'src' => true,},
+        :include      => {'deb' => false, 'src' => true},
         :architecture => 'x86_64',
       }
     end
@@ -250,7 +250,7 @@ describe 'apt::source' do
     let :params do
       {
         :location    => 'hello.there',
-        :include_src => true,
+        :include     => {'src' => true},
       }
     end
 
@@ -260,7 +260,7 @@ describe 'apt::source' do
     }
   end
 
-  context 'include_deb => false' do
+  context 'include deb => false' do
     let :facts do
       {
         :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
@@ -272,8 +272,8 @@ describe 'apt::source' do
     end
     let :params do
       {
+        :include => { 'deb' => false },
         :location    => 'hello.there',
-        :include_deb => false,
       }
     end
 
@@ -284,7 +284,7 @@ describe 'apt::source' do
     it { is_expected.to contain_apt__setting('list-my_source').without_content(/deb hello.there wheezy main\n/) }
   end
 
-  context 'include_src => true and include_deb => false' do
+  context 'include src => true and include deb => false' do
     let :facts do
       {
         :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
@@ -296,35 +296,8 @@ describe 'apt::source' do
     end
     let :params do
       {
+        :include => { 'deb' => false, 'src' => true },
         :location    => 'hello.there',
-        :include_deb => false,
-        :include_src => true,
-      }
-    end
-
-    it { is_expected.to contain_apt__setting('list-my_source').with({
-      :ensure => 'present',
-    }).with_content(/deb-src hello.there wheezy main\n/)
-    }
-    it { is_expected.to contain_apt__setting('list-my_source').without_content(/deb hello.there wheezy main\n/) }
-  end
-
-  context 'include precedence' do
-    let :facts do
-      {
-        :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
-        :lsbdistid       => 'debian',
-        :lsbdistcodename => 'wheezy',
-        :osfamily        => 'debian',
-        :puppetversion   => Puppet.version,
-      }
-    end
-    let :params do
-      {
-        :location    => 'hello.there',
-        :include_deb => true,
-        :include_src => false,
-        :include     => { 'deb' => false, 'src' => true },
       }
     end