Skip to content

Commit c4b08b3

Browse files
committed
webhook-go: Implement repository support
1 parent f36fdc3 commit c4b08b3

File tree

3 files changed

+71
-4
lines changed

3 files changed

+71
-4
lines changed

manifests/webhook/package.pp

+31-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
$pkg_file = '/tmp/webhook-go.rpm'
1111
$package_url = "https://github.com/voxpupuli/webhook-go/releases/download/v${r10k::webhook::version}/webhook-go_${r10k::webhook::version}_linux_amd64.rpm"
1212
}
13-
'Debian', 'Ubuntu': {
13+
'Debian': {
1414
$provider = 'dpkg'
1515
$pkg_file = '/tmp/webhook-go.deb'
1616
$package_url = "https://github.com/voxpupuli/webhook-go/releases/download/v${r10k::webhook::version}/webhook-go_${r10k::webhook::version}_linux_amd64.deb"
@@ -33,7 +33,36 @@
3333
}
3434
}
3535
'repo': {
36-
warning('webhook-go: configuring a repo is not implemented yet')
36+
case $facts['os']['family'] {
37+
'RedHat': {
38+
yumrepo { 'voxpupuli-webhook-go':
39+
descr => 'A certifiably-awesome open-source package repository curated by Vox Pupuli, hosted by Cloudsmith.',
40+
baseurl => "https://dl.cloudsmith.io/public/voxpupuli/webhook-go/rpm/${facts['os']['name']}/\$releasever/\$basearch",
41+
gpgcheck => 1,
42+
repo_gpgcheck => 1,
43+
enabled => true,
44+
gpgkey => 'https://dl.cloudsmith.io/public/voxpupuli/webhook-go/gpg.FD229D5D47E6F534.key',
45+
}
46+
}
47+
'Debian': {
48+
include apt
49+
apt::source { 'voxpupuli-webhook-go':
50+
comment => 'A certifiably-awesome open-source package repository curated by Vox Pupuli, hosted by Cloudsmith.',
51+
location => "https://dl.cloudsmith.io/public/voxpupuli/webhook-go/deb/${facts['os']['name']}",
52+
repos => 'main',
53+
key => {
54+
'id' => 'FD229D5D47E6F534',
55+
'source' => 'https://dl.cloudsmith.io/public/voxpupuli/webhook-go/gpg.FD229D5D47E6F534.key',
56+
},
57+
}
58+
}
59+
default: {
60+
fail("Operating system ${facts['os']['name']} not supported for packages")
61+
}
62+
}
63+
package { 'webhook-go':
64+
ensure => 'installed',
65+
}
3766
}
3867
# none = people configure a repo on their own
3968
'none': {

spec/acceptance/r10k_webhook_spec.rb

+34
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,38 @@ class { 'r10k': }
3535
its(:stdout) { is_expected.to match(%r{webhook-go}) }
3636
end
3737
end
38+
39+
context 'with external repo' do
40+
it_behaves_like 'an idempotent resource' do
41+
let(:manifest) do
42+
<<-PUPPET
43+
class { 'r10k': }
44+
-> class { 'r10k::webhook':
45+
install_method => 'repo',
46+
}
47+
PUPPET
48+
end
49+
end
50+
describe package('webhook-go') do
51+
it { is_expected.to be_installed }
52+
end
53+
54+
describe file('/etc/voxpupuli/webhook.yml') do
55+
it 'exists and has content' do
56+
expect(subject).to exist
57+
expect(subject).to be_owned_by 'root'
58+
expect(subject).to be_grouped_into 'root'
59+
expect(subject).to contain "---\nserver:\n protected: true\n user: puppet\n password: puppet\n"
60+
end
61+
end
62+
63+
describe service('webhook-go') do
64+
it { is_expected.to be_enabled }
65+
it { is_expected.to be_running }
66+
end
67+
68+
describe command('systemctl cat webhook-go') do
69+
its(:stdout) { is_expected.to match(%r{webhook-go}) }
70+
end
71+
end
3872
end

spec/spec_helper_acceptance.rb

+6-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66
require 'voxpupuli/acceptance/spec_helper_acceptance'
77

8-
configure_beaker(modules: :metadata)
9-
8+
configure_beaker do |host|
9+
case fact('os.family')
10+
when 'Debian'
11+
install_puppet_module_via_pmt_on(host, 'puppetlabs-apt')
12+
end
13+
end
1014
Dir['./spec/support/acceptance/**/*.rb'].sort.each { |f| require f }

0 commit comments

Comments
 (0)