]> review.fuel-infra Code Review - puppet-modules/puppetlabs-apt.git/commitdiff
apt::key: Rename $key to $id to match apt_key.
authorDaniele Sluijters <daenney@users.noreply.github.com>
Sun, 1 Mar 2015 13:18:48 +0000 (14:18 +0100)
committerDaniele Sluijters <daenney@users.noreply.github.com>
Sun, 1 Mar 2015 13:40:17 +0000 (14:40 +0100)
manifests/key.pp
spec/defines/key_spec.rb
spec/defines/source_spec.rb

index 0f0572ed5f160c7483e3fd199c2fa9fedb087e05..05bda975b097a99b9b70659d292ed4d6f750d64e 100644 (file)
@@ -7,7 +7,7 @@
 #
 # === Parameters
 #
-# [*key*]
+# [*id*]
 #   _default_: +$title+, the title/name of the resource
 #
 #   Is a GPG key ID or full key fingerprint. This value is validated with
@@ -51,7 +51,7 @@
 #
 #   Additional options to pass on to `apt-key adv --keyserver-options`.
 define apt::key (
-  $key     = $title,
+  $id      = $title,
   $ensure  = present,
   $content = undef,
   $source  = undef,
@@ -59,7 +59,7 @@ define apt::key (
   $options = undef,
 ) {
 
-  validate_re($key, ['\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($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, ['\Aabsent|present\Z',])
 
   if $content {
@@ -80,38 +80,38 @@ define apt::key (
 
   case $ensure {
     present: {
-      if defined(Anchor["apt_key ${key} absent"]){
-        fail("key with id ${key} 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 ${key} present"]) {
+      if !defined(Anchor["apt_key ${id} present"]) {
         apt_key { $title:
           ensure  => $ensure,
-          id      => $key,
+          id      => $id,
           source  => $source,
           content => $content,
           server  => $server,
           options => $options,
         } ->
-        anchor { "apt_key ${key} present": }
+        anchor { "apt_key ${id} present": }
       }
     }
 
     absent: {
-      if defined(Anchor["apt_key ${key} present"]){
-        fail("key with id ${key} 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 ${key} absent"]){
+      if !defined(Anchor["apt_key ${id} absent"]){
         apt_key { $title:
           ensure  => $ensure,
-          id      => $key,
+          id      => $id,
           source  => $source,
           content => $content,
           server  => $server,
           options => $options,
         } ->
-        anchor { "apt_key ${key} absent": }
+        anchor { "apt_key ${id} absent": }
       }
     }
 
index 3d82df0e4ff4ca33bca36b83a8ddb84fb31f2b6c..31248cc78a5f1bd94b485fbf3ce8fa0b7d55d088 100644 (file)
@@ -31,7 +31,7 @@ describe 'apt::key' do
       end
 
       let :params do {
-        :key => GPG_KEY_ID,
+        :id => GPG_KEY_ID,
       } end
 
       it 'contains the apt_key' do
@@ -276,16 +276,16 @@ describe 'apt::key' do
     describe 'duplication' do
       context 'two apt::key resources for same key, different titles' do
         let :pre_condition do
-          "apt::key { 'duplicate': key => '#{title}', }"
+          "apt::key { 'duplicate': id => '#{title}', }"
         end
 
         it 'contains two apt::key resources' do
           is_expected.to contain_apt__key('duplicate').with({
-            :key    => title,
+            :id     => title,
             :ensure => 'present',
           })
           is_expected.to contain_apt__key(title).with({
-            :key    => title,
+            :id     => title,
             :ensure => 'present',
           })
         end
@@ -305,7 +305,7 @@ describe 'apt::key' do
 
       context 'two apt::key resources, different ensure' do
         let :pre_condition do
-          "apt::key { 'duplicate': key => '#{title}', ensure => 'absent', }"
+          "apt::key { 'duplicate': id => '#{title}', ensure => 'absent', }"
         end
         it 'informs the user of the impossibility' do
           expect { subject }.to raise_error(/already ensured as absent/)
index 06363e608cc7d409f1f7802b22bbb20ae9dc737d..7dc03e459377b543a52de1df68867862f5453aa0 100644 (file)
@@ -71,7 +71,7 @@ describe 'apt::source' do
 
       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',
-        :key     => GPG_KEY_ID,
+        :id      => GPG_KEY_ID,
       })
       }
     end
@@ -107,7 +107,7 @@ describe 'apt::source' do
 
       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',
-        :key     => GPG_KEY_ID,
+        :id      => GPG_KEY_ID,
         :server  => 'pgp.mit.edu',
         :content => 'GPG key content',
         :source  => 'http://apt.puppetlabs.com/pubkey.gpg',