apt:🔑 Rename $key to $id to match apt_key.

This commit is contained in:
Daniele Sluijters 2015-03-01 14:18:48 +01:00
parent ea4f615735
commit 061bc49463
3 changed files with 20 additions and 20 deletions

View 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": }
}
}

View 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/)

View 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',