Skip to content

Commit

Permalink
(maint) Define statically_defined_version for local modules
Browse files Browse the repository at this point in the history
This commit adds a `statically_defined_version` method to the
`R10K::Module::Local` class. This method is called when instantiating a new
module definition, so previously, Puppetfiles that defined local modules could
not be evaluated because the method was missing.
  • Loading branch information
mwaggett committed Sep 17, 2021
1 parent f582999 commit cbcabdb
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.mkd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ CHANGELOG
Unreleased
----------

- Fix evaluation of Puppetfiles that include local modules. [#1224](https://github.com/puppetlabs/r10k/pull/1224)

3.12.0
------

Expand Down
6 changes: 5 additions & 1 deletion lib/r10k/module/local.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ def self.implement?(name, args)
args.is_a?(Hash) && (args[:local] || args[:type].to_s == 'local')
end

def version
def self.statically_defined_version(name, args)
"0.0.0"
end

def version
self.class.statically_defined_version(self.name, nil)
end

def properties
{
:expected => "0.0.0 (local)",
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/unit/puppetfile/various-modules/Puppetfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ mod 'bar', git: 'this/remote', tag: 'v1.2.3'
mod 'baz', git: 'this/remote', commit: '123abc456'
mod 'fizz', git: 'this/remote', ref: '1234567890abcdef1234567890abcdef12345678'
mod 'buzz', git: 'this/remote', ref: 'refs/heads/main'
mod 'canary', local: true
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ mod 'bar', git: 'this/remote', tag: 'v1.2.3'
mod 'baz', git: 'this/remote', commit: '123abc456'
mod 'fizz', git: 'this/remote', ref: '1234567890abcdef1234567890abcdef12345678'
mod 'buzz', git: 'this/remote', ref: 'refs/heads/main'
mod 'canary', local: true
2 changes: 2 additions & 0 deletions spec/unit/module_loader/puppetfile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ def expect_wrapped_error(error, pf_path, error_type)
expect(metadata['baz']).to eq('123abc456')
expect(metadata['fizz']).to eq('1234567890abcdef1234567890abcdef12345678')
expect(metadata['buzz']).to eq(nil)
expect(metadata['canary']).to eq('0.0.0')
end

it 'does not load module implementations for static versioned' do
Expand All @@ -381,6 +382,7 @@ def expect_wrapped_error(error, pf_path, error_type)
expect(modules['baz']).to be_a_kind_of(R10K::Module::Definition)
expect(modules['fizz']).to be_a_kind_of(R10K::Module::Definition)
expect(modules['buzz']).to be_a_kind_of(R10K::Module::Git)
expect(modules['canary']).to be_a_kind_of(R10K::Module::Definition)
end

it 'loads module implementations whose static versions are different' do
Expand Down

0 comments on commit cbcabdb

Please sign in to comment.