Skip to content

Commit

Permalink
(PUP-2014) Make module use current_environment
Browse files Browse the repository at this point in the history
Module now uses current environment instead of configured
environment when being asked for a module and not supplying
an explicit environment name. It used to lookup to configured
environment giving invoking logic no chance to modify the
default without modifying the setting.
  • Loading branch information
hlindberg committed May 9, 2014
1 parent adc9000 commit b6fc631
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 2 additions & 1 deletion lib/puppet/module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class InvalidFilePattern < Error; end
# of +path+, return +nil+
def self.find(modname, environment = nil)
return nil unless modname
env = Puppet.lookup(:environments).get(environment || Puppet[:environment])
# Unless a specific environment is given, use the current environment
env = environment ? Puppet.lookup(:environments).get(environment) : Puppet.lookup(:current_environment)
env.module(modname)
end

Expand Down
8 changes: 3 additions & 5 deletions spec/unit/face/parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,9 @@
it "parses supplied manifest files in the context of a directory environment" do
manifest = file_containing('test.pp', "{ invalid =>")

env_loader = Puppet::Environments::Static.new(
Puppet::Node::Environment.create(:special, [])
)
Puppet.override(:environments => env_loader) do
Puppet[:environment] = 'special'
env = Puppet::Node::Environment.create(:special, [])
env_loader = Puppet::Environments::Static.new(env)
Puppet.override({:environments => env_loader, :current_environment => env}) do
expect { parser.validate(manifest) }.to exit_with(1)
end

Expand Down

0 comments on commit b6fc631

Please sign in to comment.