Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webhook-go: Implement repository support #633

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }
Loading