Skip to content

Commit

Permalink
Merge pull request #1177 from Magisus/missing-mod-version
Browse files Browse the repository at this point in the history
(RK-135) Improve error message when no published mod versions exist
  • Loading branch information
justinstoller authored Jul 2, 2021
2 parents 709e040 + fec4b31 commit 4c4b74d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.mkd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ CHANGELOG

Unreleased

- Attempting to download the latest version for a module that has no Forge releases will now issue a meaningful error.
- Added an interface to R10K::Source::Base named `reload!` for updating the environments list for a given deployment; `reload!` is called before deployment purges to make r10k deploy pools more threadsafe. [#1172](https://github.com/puppetlabs/r10k/pull/1172)
----------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
r10k_fqp = get_r10k_fqp(master)

#Verification
error_notification_regex = /Does 'puppetlabs-regret' have at least one published release?/
error_notification_regex = /The module puppetlabs-regret does not appear to have any published releases/

#File
puppet_file = <<-PUPPETFILE
Expand Down Expand Up @@ -40,12 +40,6 @@

#Tests
step "Deploy production environment via r10k with specified module deleted"
on(master, "#{r10k_fqp} deploy environment -p -v", :acceptable_exit_codes => 1) do |result|
if get_puppet_version(master) < 4.0
assert_match(error_notification_regex, result.stderr, 'Unexpected error was detected!')
else
expect_failure('expected to fail due to RK-135') do
assert_match(error_notification_regex, result.stderr, 'Unexpected error was detected!')
end
end
on(master, "#{r10k_fqp} deploy environment -p -v --trace", :acceptable_exit_codes => 1) do |result|
assert_match(error_notification_regex, result.stderr, 'Unexpected error was detected!')
end
6 changes: 5 additions & 1 deletion lib/r10k/module/forge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ def properties
def expected_version
if @expected_version == :latest
begin
@expected_version = @v3_module.current_release.version
if @v3_module.current_release
@expected_version = @v3_module.current_release.version
else
raise PuppetForge::ReleaseNotFound, _("The module %{title} does not appear to have any published releases, cannot determine latest version.") % { title: @title }
end
rescue Faraday::ResourceNotFound => e
raise PuppetForge::ReleaseNotFound, _("The module %{title} does not exist on %{url}.") % {title: @title, url: PuppetForge::V3::Release.conn.url_prefix}, e.backtrace
end
Expand Down
9 changes: 8 additions & 1 deletion spec/unit/module/forge_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,16 @@

it "uses the latest version from the forge when the version is :latest" do
subject = described_class.new('branan/eight_hundred', fixture_modulepath, { version: :latest })
expect(subject.v3_module).to receive_message_chain(:current_release, :version).and_return('8.8.8')
release = double("Module Release", version: '8.8.8')
expect(subject.v3_module).to receive(:current_release).and_return(release).twice
expect(subject.expected_version).to eq '8.8.8'
end

it "throws when there are no available versions" do
subject = described_class.new('branan/eight_hundred', fixture_modulepath, { version: :latest })
expect(subject.v3_module).to receive(:current_release).and_return(nil)
expect { subject.expected_version }.to raise_error(PuppetForge::ReleaseNotFound)
end
end

describe "determining the status" do
Expand Down

0 comments on commit 4c4b74d

Please sign in to comment.