Skip to content

Commit

Permalink
webhook-go: Implement repository support
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed Sep 18, 2023
1 parent d3e0850 commit 1ed5b63
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 4 deletions.
33 changes: 31 additions & 2 deletions manifests/webhook/package.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
$pkg_file = '/tmp/webhook-go.rpm'
$package_url = "https://github.com/voxpupuli/webhook-go/releases/download/v${r10k::webhook::version}/webhook-go_${r10k::webhook::version}_linux_amd64.rpm"
}
'Debian', 'Ubuntu': {
'Debian': {
$provider = 'dpkg'
$pkg_file = '/tmp/webhook-go.deb'
$package_url = "https://github.com/voxpupuli/webhook-go/releases/download/v${r10k::webhook::version}/webhook-go_${r10k::webhook::version}_linux_amd64.deb"
Expand All @@ -33,7 +33,36 @@
}
}
'repo': {
warning('webhook-go: configuring a repo is not implemented yet')
case $facts['os']['family'] {
'RedHat': {
yumrepo { 'voxpupuli-webhook-go':
descr => 'A certifiably-awesome open-source package repository curated by Vox Pupuli, hosted by Cloudsmith.',
baseurl => "https://dl.cloudsmith.io/public/voxpupuli/webhook-go/rpm/${facts['os']['name']}/\$releasever/\$basearch",
gpgcheck => 1,
repo_gpgcheck => 1,
enabled => true,
gpgkey => 'https://dl.cloudsmith.io/public/voxpupuli/webhook-go/gpg.FD229D5D47E6F534.key',
}
}
'Debian': {
include apt
apt::source { 'voxpupuli-webhook-go':
comment => 'A certifiably-awesome open-source package repository curated by Vox Pupuli, hosted by Cloudsmith.',
location => "https://dl.cloudsmith.io/public/voxpupuli/webhook-go/deb/${facts['os']['name']}",
repos => 'main',
key => {
'id' => 'FD229D5D47E6F534',
'source' => 'https://dl.cloudsmith.io/public/voxpupuli/webhook-go/gpg.FD229D5D47E6F534.key',
},
}
}
default: {
fail("Operating system ${facts['os']['name']} not supported for packages")
}
}
package { 'webhook-go':
ensure => 'installed',
}
}
# none = people configure a repo on their own
'none': {
Expand Down
34 changes: 34 additions & 0 deletions spec/acceptance/r10k_webhook_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,38 @@ class { 'r10k': }
its(:stdout) { is_expected.to match(%r{webhook-go}) }
end
end

context 'with external repo' do
it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
class { 'r10k': }
-> class { 'r10k::webhook':
install_method => 'repo',
}
PUPPET
end
end
describe package('webhook-go') do
it { is_expected.to be_installed }
end

describe file('/etc/voxpupuli/webhook.yml') do
it 'exists and has content' do
expect(subject).to exist
expect(subject).to be_owned_by 'root'
expect(subject).to be_grouped_into 'root'
expect(subject).to contain "---\nserver:\n protected: true\n user: puppet\n password: puppet\n"
end
end

describe service('webhook-go') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe command('systemctl cat webhook-go') do
its(:stdout) { is_expected.to match(%r{webhook-go}) }
end
end
end
8 changes: 6 additions & 2 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

require 'voxpupuli/acceptance/spec_helper_acceptance'

configure_beaker(modules: :metadata)

configure_beaker do |host|
case fact('os.family')
when 'Debian'
install_puppet_module_via_pmt_on(host, 'puppetlabs-apt')
end
end
Dir['./spec/support/acceptance/**/*.rb'].sort.each { |f| require f }

0 comments on commit 1ed5b63

Please sign in to comment.