Skip to content

Commit

Permalink
(maint) Restore the ability to load a Puppetfile from a relative `bas…
Browse files Browse the repository at this point in the history
…edir`

This commit updates the `R10K::Puppetfile` class to pass just the Puppetfile
name to the module loader, rather than passing the whole path. Prior to this
change, if you used a relative `basedir`, we'd pass a relative Puppetfile path
to `R10K::ModuleLoader::Puppetfile`, which would then try to resolve the path
against the `basedir` again. This resulted in attempting to load the Puppetfile
from a path like `my/cool/basedir/my/cool/basedir/Puppetfile`, which doesn't
exist, so loading would fail.
  • Loading branch information
mwaggett committed Aug 11, 2021
1 parent 3a8c6e8 commit 9082511
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.mkd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Unreleased
- (CODEMGMT-1421) Add skeleton for deploy_spec option [#1189](https://github.com/puppetlabs/r10k/pull/1189)
- (RK-369) Make module deploys run the postrun command if any environments were updated. [#982](https://github.com/puppetlabs/r10k/issues/982)
- Add support for Github App auth token. This allows r10k to authenticate under strict SSO/2FA guidelines that cannot utilize machine users for code deployment. [#1180](https://github.com/puppetlabs/r10k/pull/1180)
- Restore the ability to load a Puppetfile from a relative `basedir`. [#1202](https://github.com/puppetlabs/r10k/pull/1202)

3.10.0
------
Expand Down
2 changes: 1 addition & 1 deletion lib/r10k/puppetfile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def initialize(basedir, options_or_moduledir = nil, deprecated_path_arg = nil, d
@loader = ::R10K::ModuleLoader::Puppetfile.new(
basedir: @basedir,
moduledir: @moduledir,
puppetfile: @puppetfile_path,
puppetfile: @puppetfile_name,
forge: @forge,
overrides: @overrides,
environment: @environment
Expand Down
11 changes: 11 additions & 0 deletions spec/unit/puppetfile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@
expect(has_some_data).to be true
end

it "handles a relative basedir" do
path = File.join('spec', 'fixtures', 'unit', 'puppetfile', 'valid-forge-with-version')
subject = described_class.new(path, {})

loaded_content = subject.load
expect(loaded_content).to be_an_instance_of(Hash)

has_some_data = loaded_content.values.none?(&:empty?)
expect(has_some_data).to be true
end

it "is idempotent" do
path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'valid-forge-with-version')
subject = described_class.new(path, {})
Expand Down

0 comments on commit 9082511

Please sign in to comment.