From 061bc49463f66b3c9d7fb07386d662e50b7fe29a Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Sun, 1 Mar 2015 14:18:48 +0100 Subject: [PATCH] apt::key: Rename $key to $id to match apt_key. --- manifests/key.pp | 26 +++++++++++++------------- spec/defines/key_spec.rb | 10 +++++----- spec/defines/source_spec.rb | 4 ++-- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/manifests/key.pp b/manifests/key.pp index 0f0572e..05bda97 100644 --- a/manifests/key.pp +++ b/manifests/key.pp @@ -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": } } } diff --git a/spec/defines/key_spec.rb b/spec/defines/key_spec.rb index 3d82df0..31248cc 100644 --- a/spec/defines/key_spec.rb +++ b/spec/defines/key_spec.rb @@ -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/) diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 06363e6..7dc03e4 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -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',