From: david22swan Date: Fri, 21 Apr 2023 12:42:23 +0000 (+0100) Subject: (CONT-773) Rubocop Auto Fixes 1-5 X-Git-Tag: v9.1.0~9^2~12 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;ds=sidebyside;h=a4609826c3dc663c2ebb5402ffe7b8a1ea1ecd4f;p=puppet-modules%2Fpuppetlabs-apt.git (CONT-773) Rubocop Auto Fixes 1-5 - Layout/ClosingHeredocIndentation - Layout/EmptyLineAfterGuardClause - Layout/HashAlignment - Layout/HeredocIndentation - Layout/SpaceAroundMethodCallOperator --- diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 8aff459..31aae81 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -6,56 +6,6 @@ # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 32 -# This cop supports safe autocorrection (--autocorrect). -Layout/ClosingHeredocIndentation: - Exclude: - - 'spec/acceptance/apt_key_provider_spec.rb' - - 'spec/acceptance/apt_spec.rb' - - 'spec/spec_helper_acceptance_local.rb' - - 'spec/unit/puppet/provider/apt_key_spec.rb' - -# Offense count: 5 -# This cop supports safe autocorrection (--autocorrect). -Layout/EmptyLineAfterGuardClause: - Exclude: - - 'lib/facter/apt_updates.rb' - - 'lib/puppet/provider/apt_key/apt_key.rb' - - 'lib/puppet/type/apt_key.rb' - - 'spec/spec_helper_acceptance_local.rb' - - 'tasks/init.rb' - -# Offense count: 57 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. -# SupportedHashRocketStyles: key, separator, table -# SupportedColonStyles: key, separator, table -# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit -Layout/HashAlignment: - Exclude: - - 'spec/classes/apt_spec.rb' - - 'spec/classes/apt_update_spec.rb' - - 'spec/defines/conf_spec.rb' - - 'spec/defines/pin_spec.rb' - - 'spec/defines/source_compat_spec.rb' - - 'spec/defines/source_spec.rb' - - 'spec/unit/puppet/provider/apt_key_spec.rb' - - 'spec/unit/puppet/type/apt_key_spec.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -Layout/HeredocIndentation: - Exclude: - - 'spec/spec_helper_acceptance_local.rb' - - 'spec/unit/puppet/provider/apt_key_spec.rb' - -# Offense count: 6 -# This cop supports safe autocorrection (--autocorrect). -Layout/SpaceAroundMethodCallOperator: - Exclude: - - 'spec/defines/key_compat_spec.rb' - - 'spec/defines/key_spec.rb' - # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). Lint/BooleanSymbol: diff --git a/lib/facter/apt_updates.rb b/lib/facter/apt_updates.rb index f261d2c..3b46e2d 100644 --- a/lib/facter/apt_updates.rb +++ b/lib/facter/apt_updates.rb @@ -14,6 +14,7 @@ def get_updates(upgrade_option) apt_updates = [[], []] apt_get_result.each_line do |line| next unless %r{^Inst\s}.match?(line) + package = line.gsub(%r{^Inst\s([^\s]+)\s.*}, '\1').strip apt_updates[0].push(package) security_matches = [ diff --git a/lib/puppet/provider/apt_key/apt_key.rb b/lib/puppet/provider/apt_key/apt_key.rb index 115ed31..9f461cc 100644 --- a/lib/puppet/provider/apt_key/apt_key.rb +++ b/lib/puppet/provider/apt_key/apt_key.rb @@ -120,6 +120,7 @@ Puppet::Type.type(:apt_key).provide(:apt_key) do parsed_value = URI.parse(value) if parsed_value.scheme.nil? raise(_('The file %{_value} does not exist') % { _value: value }) unless File.exist?(value) + # Because the tempfile method has to return a live object to prevent GC # of the underlying file from occuring too early, we also have to return # a file object here. The caller can still call the #path method on the diff --git a/lib/puppet/type/apt_key.rb b/lib/puppet/type/apt_key.rb index c78ba8f..99be930 100644 --- a/lib/puppet/type/apt_key.rb +++ b/lib/puppet/type/apt_key.rb @@ -31,6 +31,7 @@ Puppet::Type.newtype(:apt_key) do if self[:content] && self[:source] raise(_('The properties content and source are mutually exclusive.')) end + if self[:id].length < 40 warning(_('The id should be a full fingerprint (40 characters), see README.')) end diff --git a/spec/acceptance/apt_key_provider_spec.rb b/spec/acceptance/apt_key_provider_spec.rb index ee4a4c8..aa76340 100644 --- a/spec/acceptance/apt_key_provider_spec.rb +++ b/spec/acceptance/apt_key_provider_spec.rb @@ -111,7 +111,7 @@ refresh_pp = <<-MANIFEST =cXcR -----END PGP PUBLIC KEY BLOCK-----' } - MANIFEST +MANIFEST gpg_key_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -170,7 +170,7 @@ gpg_key_pp = <<-MANIFEST =mMjt -----END PGP PUBLIC KEY BLOCK-----", } - MANIFEST +MANIFEST multiple_keys_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -423,7 +423,7 @@ multiple_keys_pp = <<-MANIFEST =TREp -----END PGP PUBLIC KEY BLOCK----- ", } - MANIFEST +MANIFEST bogus_key_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -431,7 +431,7 @@ bogus_key_pp = <<-MANIFEST ensure => 'present', content => 'For posterity: such content, much bogus, wow', } - MANIFEST +MANIFEST hkp_pool_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -439,7 +439,7 @@ hkp_pool_pp = <<-MANIFEST ensure => 'present', server => 'hkp://keyserver.ubuntu.com:80', } - MANIFEST +MANIFEST hkps_protocol_supported = host_inventory['facter']['os']['family'] =~ %r{Ubuntu}i && \ host_inventory['facter']['os']['release']['major'] =~ %r{^18\.04} @@ -451,7 +451,7 @@ if hkps_protocol_supported ensure => 'present', server => 'hkps://keyserver.ubuntu.com', } - MANIFEST + MANIFEST end nonexistant_key_server_pp = <<-MANIFEST @@ -460,7 +460,7 @@ nonexistant_key_server_pp = <<-MANIFEST ensure => 'present', server => 'nonexistant.key.server', } - MANIFEST +MANIFEST dot_server_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -468,7 +468,7 @@ dot_server_pp = <<-MANIFEST ensure => 'present', server => '.pgp.key.server', } - MANIFEST +MANIFEST http_works_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -476,7 +476,7 @@ http_works_pp = <<-MANIFEST ensure => 'present', source => 'http://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', } - MANIFEST +MANIFEST http_works_userinfo_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -484,7 +484,7 @@ http_works_userinfo_pp = <<-MANIFEST ensure => 'present', source => 'http://dummyuser:dummypassword@#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', } - MANIFEST +MANIFEST four_oh_four_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -492,7 +492,7 @@ four_oh_four_pp = <<-MANIFEST ensure => 'present', source => 'http://#{PUPPETLABS_APT_URL}/herpderp.gpg', } - MANIFEST +MANIFEST socket_error_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -500,7 +500,7 @@ socket_error_pp = <<-MANIFEST ensure => 'present', source => 'http://apt.puppetlabss.com/herpderp.gpg', } - MANIFEST +MANIFEST ftp_works_pp = <<-MANIFEST apt_key { 'CentOS 6': @@ -508,7 +508,7 @@ ftp_works_pp = <<-MANIFEST ensure => 'present', source => 'ftp://#{CENTOS_REPO_URL}/#{CENTOS_GPG_KEY_FILE}', } - MANIFEST +MANIFEST ftp_550_pp = <<-MANIFEST apt_key { 'CentOS 6': @@ -516,7 +516,7 @@ ftp_550_pp = <<-MANIFEST ensure => 'present', source => 'ftp://#{CENTOS_REPO_URL}/herpderp.gpg', } - MANIFEST +MANIFEST ftp_socket_error_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -524,7 +524,7 @@ ftp_socket_error_pp = <<-MANIFEST ensure => 'present', source => 'ftp://apt.puppetlabss.com/herpderp.gpg', } - MANIFEST +MANIFEST https_works_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -532,7 +532,7 @@ https_works_pp = <<-MANIFEST ensure => 'present', source => 'https://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', } - MANIFEST +MANIFEST https_with_weak_ssl_works_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -541,7 +541,7 @@ https_with_weak_ssl_works_pp = <<-MANIFEST source => 'https://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', weak_ssl => true, } - MANIFEST +MANIFEST https_userinfo_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -549,7 +549,7 @@ https_userinfo_pp = <<-MANIFEST ensure => 'present', source => 'https://dummyuser:dummypassword@#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', } - MANIFEST +MANIFEST https_404_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -557,7 +557,7 @@ https_404_pp = <<-MANIFEST ensure => 'present', source => 'https://#{PUPPETLABS_APT_URL}/herpderp.gpg', } - MANIFEST +MANIFEST https_socket_error_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -565,7 +565,7 @@ https_socket_error_pp = <<-MANIFEST ensure => 'present', source => 'https://apt.puppetlabss.com/herpderp.gpg', } - MANIFEST +MANIFEST path_exists_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -573,7 +573,7 @@ path_exists_pp = <<-MANIFEST ensure => 'present', source => '/tmp/puppetlabs-pubkey.gpg', } - MANIFEST +MANIFEST path_does_not_exist_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -581,7 +581,7 @@ path_does_not_exist_pp = <<-MANIFEST ensure => 'present', source => '/tmp/totally_bogus.file', } - MANIFEST +MANIFEST path_bogus_content_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -589,7 +589,7 @@ path_bogus_content_pp = <<-MANIFEST ensure => 'present', source => '/tmp/fake-key.gpg', } - MANIFEST +MANIFEST debug_works_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -597,7 +597,7 @@ debug_works_pp = <<-MANIFEST ensure => 'present', options => 'debug', } - MANIFEST +MANIFEST fingerprint_match_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -605,7 +605,7 @@ fingerprint_match_pp = <<-MANIFEST ensure => 'present', source => 'https://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', } - MANIFEST +MANIFEST fingerprint_does_not_match_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -613,7 +613,7 @@ fingerprint_does_not_match_pp = <<-MANIFEST ensure => 'present', source => 'https://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', } - MANIFEST +MANIFEST refresh_true_pp = <<-MANIFEST apt_key { '#{PUPPETLABS_EXP_KEY_LONG_ID}': @@ -621,7 +621,7 @@ refresh_true_pp = <<-MANIFEST ensure => 'present', refresh => true, } - MANIFEST +MANIFEST refresh_false_pp = <<-MANIFEST apt_key { '#{PUPPETLABS_EXP_KEY_LONG_ID}': @@ -657,14 +657,14 @@ describe 'apt_key' do id => '#{CENTOS_GPG_KEY_LONG_ID}', ensure => 'present', } - MANIFEST + MANIFEST ensure_absent_pp = <<-MANIFEST apt_key { 'centos': id => '#{CENTOS_GPG_KEY_LONG_ID}', ensure => 'absent', } - MANIFEST + MANIFEST it 'add an apt_key resource' do apply_manifest_twice(ensure_present_pp) diff --git a/spec/acceptance/apt_spec.rb b/spec/acceptance/apt_spec.rb index 7e4fe37..35277bb 100644 --- a/spec/acceptance/apt_spec.rb +++ b/spec/acceptance/apt_spec.rb @@ -29,7 +29,7 @@ everything_everything_pp = <<-MANIFEST }, sources => $sources, } - MANIFEST +MANIFEST describe 'apt class' do context 'with reset' do diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 1a7513c..b7ef6b5 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -482,17 +482,17 @@ machine apt.example.com login aptlogin password supersecret let(:params) do { sources: { 'debian_unstable' => { - 'location' => 'http://debian.mirror.iweb.ca/debian/', - 'release' => 'unstable', - 'repos' => 'main contrib non-free', - 'key' => { 'id' => '150C8614919D8446E01E83AF9AA38DCD55BE302B', 'server' => 'subkeys.pgp.net' }, - 'pin' => '-10', - 'include' => { 'src' => true }, + 'location' => 'http://debian.mirror.iweb.ca/debian/', + 'release' => 'unstable', + 'repos' => 'main contrib non-free', + 'key' => { 'id' => '150C8614919D8446E01E83AF9AA38DCD55BE302B', 'server' => 'subkeys.pgp.net' }, + 'pin' => '-10', + 'include' => { 'src' => true }, }, 'puppetlabs' => { 'location' => 'http://apt.puppetlabs.com', - 'repos' => 'main', - 'key' => { 'id' => '6F6B15509CF8E59E6E469F327F438280EF8D349F', 'server' => 'pgp.mit.edu' }, + 'repos' => 'main', + 'key' => { 'id' => '6F6B15509CF8E59E6E469F327F438280EF8D349F', 'server' => 'pgp.mit.edu' }, }, } } end @@ -661,7 +661,7 @@ machine apt.example.com login aptlogin password supersecret let(:params) do { pins: { 'stable' => { 'priority' => 600, 'order' => 50 }, - 'testing' => { 'priority' => 700, 'order' => 100 }, + 'testing' => { 'priority' => 700, 'order' => 100 }, } } end diff --git a/spec/classes/apt_update_spec.rb b/spec/classes/apt_update_spec.rb index 7177455..6ab9534 100644 --- a/spec/classes/apt_update_spec.rb +++ b/spec/classes/apt_update_spec.rb @@ -5,8 +5,8 @@ require 'spec_helper' describe 'apt::update', type: :class do context "when apt::update['frequency']='always'" do { - 'a recent run' => Time.now.to_i, - 'we are due for a run' => 1_406_660_561, + 'a recent run' => Time.now.to_i, + 'we are due for a run' => 1_406_660_561, 'the update-success-stamp file does not exist' => -1, }.each_pair do |desc, factval| context "when $apt_update_last_success indicates #{desc}" do @@ -94,8 +94,8 @@ describe 'apt::update', type: :class do end context "when apt::update['frequency']='reluctantly'" do { - 'a recent run' => Time.now.to_i, - 'we are due for a run' => 1_406_660_561, + 'a recent run' => Time.now.to_i, + 'we are due for a run' => 1_406_660_561, 'the update-success-stamp file does not exist' => -1, }.each_pair do |desc, factval| context "when $apt_update_last_success indicates #{desc}" do diff --git a/spec/defines/conf_spec.rb b/spec/defines/conf_spec.rb index f1e42b5..04551b8 100644 --- a/spec/defines/conf_spec.rb +++ b/spec/defines/conf_spec.rb @@ -42,9 +42,9 @@ describe 'apt::conf', type: :define do it { is_expected.to contain_file(filename).with('ensure' => 'present', - 'content' => %r{Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;}, - 'owner' => 'root', - 'group' => 'root') + 'content' => %r{Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;}, + 'owner' => 'root', + 'group' => 'root') } context 'with notify_update = true (default)' do @@ -90,8 +90,8 @@ describe 'apt::conf', type: :define do it { is_expected.to contain_file(filename).with('ensure' => 'absent', - 'owner' => 'root', - 'group' => 'root') + 'owner' => 'root', + 'group' => 'root') } end end diff --git a/spec/defines/key_compat_spec.rb b/spec/defines/key_compat_spec.rb index d477937..2fb7e65 100644 --- a/spec/defines/key_compat_spec.rb +++ b/spec/defines/key_compat_spec.rb @@ -170,7 +170,7 @@ describe 'apt::key', type: :define do end it 'fails' do - is_expected .to raise_error(%r{expects a match}) + is_expected.to raise_error(%r{expects a match}) end end @@ -182,7 +182,7 @@ describe 'apt::key', type: :define do end it 'fails' do - is_expected .to raise_error(%r{expects a match}) + is_expected.to raise_error(%r{expects a match}) end end @@ -194,7 +194,7 @@ describe 'apt::key', type: :define do end it 'fails' do - is_expected .to raise_error(%r{expects a match}) + is_expected.to raise_error(%r{expects a match}) end end context 'when url character limit is exceeded' do diff --git a/spec/defines/key_spec.rb b/spec/defines/key_spec.rb index fd63965..8c8d503 100644 --- a/spec/defines/key_spec.rb +++ b/spec/defines/key_spec.rb @@ -190,7 +190,7 @@ describe 'apt::key' do end it 'fails' do - is_expected .to raise_error(%r{expects a match}) + is_expected.to raise_error(%r{expects a match}) end end @@ -202,7 +202,7 @@ describe 'apt::key' do end it 'fails' do - is_expected .to raise_error(%r{expects a match}) + is_expected.to raise_error(%r{expects a match}) end end @@ -214,7 +214,7 @@ describe 'apt::key' do end it 'fails' do - is_expected .to raise_error(%r{expects a match}) + is_expected.to raise_error(%r{expects a match}) end end context 'when character url exceeded' do diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb index 5edc79c..f22d92a 100644 --- a/spec/defines/pin_spec.rb +++ b/spec/defines/pin_spec.rb @@ -31,7 +31,7 @@ describe 'apt::pin', type: :define do let :params do { 'packages' => 'vim', - 'version' => '1', + 'version' => '1', } end @@ -42,7 +42,7 @@ describe 'apt::pin', type: :define do let :params do { 'packages' => 'vim', - 'origin' => 'test', + 'origin' => 'test', } end @@ -52,15 +52,15 @@ describe 'apt::pin', type: :define do context 'without defaults' do let :params do { - 'explanation' => 'foo', - 'order' => 99, - 'release' => '1', - 'codename' => 'bar', + 'explanation' => 'foo', + 'order' => 99, + 'release' => '1', + 'codename' => 'bar', 'release_version' => '2', - 'component' => 'baz', - 'originator' => 'foobar', - 'label' => 'foobaz', - 'priority' => 10, + 'component' => 'baz', + 'originator' => 'foobar', + 'label' => 'foobaz', + 'priority' => 10, } end @@ -116,7 +116,7 @@ describe 'apt::pin', type: :define do context 'with packages == * and release and origin' do let :params do { - 'origin' => 'test', + 'origin' => 'test', 'release' => 'foo', } end @@ -129,8 +129,8 @@ describe 'apt::pin', type: :define do context 'with specific release and origin' do let :params do { - 'release' => 'foo', - 'origin' => 'test', + 'release' => 'foo', + 'origin' => 'test', 'packages' => 'vim', } end @@ -143,8 +143,8 @@ describe 'apt::pin', type: :define do context 'with specific version and origin' do let :params do { - 'version' => '1', - 'origin' => 'test', + 'version' => '1', + 'origin' => 'test', 'packages' => 'vim', } end diff --git a/spec/defines/source_compat_spec.rb b/spec/defines/source_compat_spec.rb index d7dfb78..7eef4fd 100644 --- a/spec/defines/source_compat_spec.rb +++ b/spec/defines/source_compat_spec.rb @@ -42,14 +42,14 @@ describe 'apt::source', type: :define do context 'with no defaults' do let :params do { - 'comment' => 'foo', - 'location' => 'http://debian.mirror.iweb.ca/debian/', - 'release' => 'sid', - 'repos' => 'testing', - 'include' => { 'src' => false }, - 'key' => GPG_KEY_ID, - 'pin' => '10', - 'architecture' => 'x86_64', + 'comment' => 'foo', + 'location' => 'http://debian.mirror.iweb.ca/debian/', + 'release' => 'sid', + 'repos' => 'testing', + 'include' => { 'src' => false }, + 'key' => GPG_KEY_ID, + 'pin' => '10', + 'architecture' => 'x86_64', 'allow_unsigned' => true, } end @@ -62,7 +62,7 @@ describe 'apt::source', type: :define do it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with('ensure' => 'present', 'priority' => '10', - 'origin' => 'debian.mirror.iweb.ca') + 'origin' => 'debian.mirror.iweb.ca') } it { @@ -74,8 +74,8 @@ describe 'apt::source', type: :define do context 'when allow_insecure true' do let :params do { - 'include' => { 'src' => false }, - 'location' => 'http://debian.mirror.iweb.ca/debian/', + 'include' => { 'src' => false }, + 'location' => 'http://debian.mirror.iweb.ca/debian/', 'allow_insecure' => true, } end @@ -86,8 +86,8 @@ describe 'apt::source', type: :define do context 'when allow_unsigned true' do let :params do { - 'include' => { 'src' => false }, - 'location' => 'http://debian.mirror.iweb.ca/debian/', + 'include' => { 'src' => false }, + 'location' => 'http://debian.mirror.iweb.ca/debian/', 'allow_unsigned' => true, } end @@ -98,7 +98,7 @@ describe 'apt::source', type: :define do context 'with architecture equals x86_64' do let :params do { - 'location' => 'http://debian.mirror.iweb.ca/debian/', + 'location' => 'http://debian.mirror.iweb.ca/debian/', 'architecture' => 'x86_64', } end diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 6410895..e5df79f 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -53,7 +53,7 @@ describe 'apt::source' do location: 'hello.there', pin: { 'release' => 'wishwash', 'explanation' => 'wishwash', - 'priority' => 1001 }, + 'priority' => 1001 }, } end @@ -114,7 +114,7 @@ describe 'apt::source' do 'id' => GPG_KEY_ID, 'server' => 'pgp.mit.edu', 'content' => 'GPG key content', - 'source' => 'http://apt.puppetlabs.com/pubkey.gpg', + 'source' => 'http://apt.puppetlabs.com/pubkey.gpg', 'weak_ssl' => true, }, pin: '10', diff --git a/spec/spec_helper_acceptance_local.rb b/spec/spec_helper_acceptance_local.rb index 9f0cd18..b0e6728 100644 --- a/spec/spec_helper_acceptance_local.rb +++ b/spec/spec_helper_acceptance_local.rb @@ -9,11 +9,11 @@ RSpec.configure do |c| c.before :suite do # lsb-release is needed for facter 3 (puppet 6) to resolve os.distro facts. Not needed with facter # 4 (puppet 7). - lsb_package = <<-MANIFEST -package { 'lsb-release': - ensure => installed, -} -MANIFEST + lsb_package = <<~MANIFEST + package { 'lsb-release': + ensure => installed, + } + MANIFEST include PuppetLitmus extend PuppetLitmus apply_manifest(lsb_package) @@ -40,6 +40,7 @@ def retry_on_error_matching(max_retry_count = MAX_RETRY_COUNT, retry_wait_interv yield rescue StandardError => e raise('Attempted this %{value0} times. Raising %{value1}' % { value0: max_retry_count, value1: e }) unless try < max_retry_count && (error_matcher.nil? || e.message =~ error_matcher) + sleep retry_wait_interval_secs retry end diff --git a/spec/unit/puppet/provider/apt_key_spec.rb b/spec/unit/puppet/provider/apt_key_spec.rb index 970f7e1..d2fa8b2 100644 --- a/spec/unit/puppet/provider/apt_key_spec.rb +++ b/spec/unit/puppet/provider/apt_key_spec.rb @@ -29,16 +29,16 @@ describe Puppet::Type.type(:apt_key).provider(:apt_key) do context 'self.instances multiple keys' do before :each do - command_output = <<-OUTPUT -Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.DU0GdRxjmE --no-auto-check-trustdb --trust-model always --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyring /etc/apt/trusted.gpg.d/puppetlabs-pc1-keyring.gpg --no-tty --list-keys --with-colons --fingerprint --fixed-list-mode -tru:t:1:1549900774:0:3:1:5 -pub:-:1024:17:40976EAF437D05B5:1095016255:::-:::scESC: -fpr:::::::::630239CC130E1A7FD81A27B140976EAF437D05B5: -uid:-::::1095016255::B84AE656F4F5A826C273A458512EF8E282754CE1::Ubuntu Archive Automatic Signing Key : -sub:-:2048:16:251BEFF479164387:1095016263::::::e: -pub:-:1024:17:46181433FBB75451:1104433784:::-:::scSC: -fpr:::::::::C5986B4F1257FFA86632CBA746181433FBB75451: -OUTPUT + command_output = <<~OUTPUT + Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.DU0GdRxjmE --no-auto-check-trustdb --trust-model always --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyring /etc/apt/trusted.gpg.d/puppetlabs-pc1-keyring.gpg --no-tty --list-keys --with-colons --fingerprint --fixed-list-mode + tru:t:1:1549900774:0:3:1:5 + pub:-:1024:17:40976EAF437D05B5:1095016255:::-:::scESC: + fpr:::::::::630239CC130E1A7FD81A27B140976EAF437D05B5: + uid:-::::1095016255::B84AE656F4F5A826C273A458512EF8E282754CE1::Ubuntu Archive Automatic Signing Key : + sub:-:2048:16:251BEFF479164387:1095016263::::::e: + pub:-:1024:17:46181433FBB75451:1104433784:::-:::scSC: + fpr:::::::::C5986B4F1257FFA86632CBA746181433FBB75451: + OUTPUT allow(described_class).to receive(:apt_key).with( ['adv', '--no-tty', '--list-keys', '--with-colons', '--fingerprint', '--fixed-list-mode'], ).and_return(command_output) @@ -136,11 +136,11 @@ OUTPUT '32bit key id' => 'EF8D349F', '64bit key id' => '7F438280EF8D349F', '160bit key fingerprint' => '6F6B15509CF8E59E6E469F327F438280EF8D349F', - '32bit key id lowercase' => 'EF8D349F'.downcase, - '64bit key id lowercase' => '7F438280EF8D349F'.downcase, + '32bit key id lowercase' => 'EF8D349F'.downcase, + '64bit key id lowercase' => '7F438280EF8D349F'.downcase, '160bit key fingerprint lowercase' => '6F6B15509CF8E59E6E469F327F438280EF8D349F'.downcase, - '32bit key id 0x formatted' => '0xEF8D349F', - '64bit key id 0x formatted' => '0x7F438280EF8D349F', + '32bit key id 0x formatted' => '0xEF8D349F', + '64bit key id 0x formatted' => '0x7F438280EF8D349F', '160bit key fingerprint 0x formatted' => '0x6F6B15509CF8E59E6E469F327F438280EF8D349F', } hash_of_keys.each do |key_type, value| diff --git a/spec/unit/puppet/type/apt_key_spec.rb b/spec/unit/puppet/type/apt_key_spec.rb index b20a09a..a23aa90 100644 --- a/spec/unit/puppet/type/apt_key_spec.rb +++ b/spec/unit/puppet/type/apt_key_spec.rb @@ -164,10 +164,10 @@ describe Puppet::Type.type(:apt_key) do it 'raises an error if refresh => true and ensure => absent' do expect { - Puppet::Type.type(:apt_key).new(id: 'EF8D349F', - source: 'http://apt.puppetlabs.com/pubkey.gpg', - ensure: :absent, - refresh: :true) + Puppet::Type.type(:apt_key).new(id: 'EF8D349F', + source: 'http://apt.puppetlabs.com/pubkey.gpg', + ensure: :absent, + refresh: :true) }.to raise_error(%r{ensure => absent and refresh => true are mutually exclusive}) end diff --git a/tasks/init.rb b/tasks/init.rb index 86367d9..132699a 100755 --- a/tasks/init.rb +++ b/tasks/init.rb @@ -17,6 +17,7 @@ def apt_get(action) end stdout, stderr, status = Open3.capture3(*cmd) raise Puppet::Error, stderr if status != 0 + { status: stdout.strip } end