diff options
author | Andrew Parker <andy@puppetlabs.com> | 2014-10-10 11:13:31 -0700 |
---|---|---|
committer | Andrew Parker <andy@puppetlabs.com> | 2014-10-10 11:13:31 -0700 |
commit | a7faa5f492a3827f9f4458b071380d49b223783b (patch) | |
tree | 1368fd9ad89b1dff30b683e483a520fd54b1bb45 | |
parent | 19832b23f18216cfd557ac9b26a3fbc886b94147 (diff) | |
download | puppet-a7faa5f492a3827f9f4458b071380d49b223783b.tar.gz |
(maint) Modify other uses of get() to get!()
There were several uses of get() that either immediately checked for nil
and raised the UnknownEnvironmentError or assumed non-nil and continued.
This changes all of those cases to use the new get!() method and so be
explicit that they require an environment. There are a couple uses that
still don't require the environment to exist.
-rw-r--r-- | lib/puppet/application.rb | 5 | ||||
-rw-r--r-- | lib/puppet/indirector/request.rb | 3 | ||||
-rw-r--r-- | lib/puppet/module.rb | 2 | ||||
-rw-r--r-- | lib/puppet/module_tool.rb | 2 | ||||
-rw-r--r-- | lib/puppet/node.rb | 2 | ||||
-rw-r--r-- | lib/puppet/parser/type_loader.rb | 2 | ||||
-rw-r--r-- | lib/puppet/util/autoload.rb | 2 |
7 files changed, 7 insertions, 11 deletions
diff --git a/lib/puppet/application.rb b/lib/puppet/application.rb index 1d9611093..0e98d8adb 100644 --- a/lib/puppet/application.rb +++ b/lib/puppet/application.rb @@ -360,10 +360,7 @@ class Application # configured_environment_name = Puppet[:environment] if self.class.run_mode.name != :agent - configured_environment = Puppet.lookup(:environments).get(configured_environment_name) - if configured_environment.nil? - fail(Puppet::Environments::EnvironmentNotFound, configured_environment_name) - end + configured_environment = Puppet.lookup(:environments).get!(configured_environment_name) else configured_environment = Puppet::Node::Environment.remote(configured_environment_name) end diff --git a/lib/puppet/indirector/request.rb b/lib/puppet/indirector/request.rb index 04c55f9a3..a156f9de5 100644 --- a/lib/puppet/indirector/request.rb +++ b/lib/puppet/indirector/request.rb @@ -95,8 +95,7 @@ class Puppet::Indirector::Request elsif (current_environment = Puppet.lookup(:current_environment)).name == env current_environment else - Puppet.lookup(:environments).get(env) || - raise(Puppet::Environments::EnvironmentNotFound, env) + Puppet.lookup(:environments).get!(env) end end diff --git a/lib/puppet/module.rb b/lib/puppet/module.rb index 3a3435c35..deecfd45b 100644 --- a/lib/puppet/module.rb +++ b/lib/puppet/module.rb @@ -29,7 +29,7 @@ class Puppet::Module def self.find(modname, environment = nil) return nil unless modname # Unless a specific environment is given, use the current environment - env = environment ? Puppet.lookup(:environments).get(environment) : Puppet.lookup(:current_environment) + env = environment ? Puppet.lookup(:environments).get!(environment) : Puppet.lookup(:current_environment) env.module(modname) end diff --git a/lib/puppet/module_tool.rb b/lib/puppet/module_tool.rb index 8f462f6d8..984947d33 100644 --- a/lib/puppet/module_tool.rb +++ b/lib/puppet/module_tool.rb @@ -151,7 +151,7 @@ module Puppet elsif options[:environment] # This use of looking up an environment is correct since it honours # a reguest to get a particular environment via environment name. - Puppet.lookup(:environments).get(options[:environment]) + Puppet.lookup(:environments).get!(options[:environment]) else Puppet.lookup(:current_environment) end diff --git a/lib/puppet/node.rb b/lib/puppet/node.rb index 6f0d89dba..32f11168c 100644 --- a/lib/puppet/node.rb +++ b/lib/puppet/node.rb @@ -67,7 +67,7 @@ class Puppet::Node # for a node when it has not specified its environment # Tt will be used to establish what the current environment is. # - self.environment = Puppet.lookup(:environments).get(Puppet[:environment]) + self.environment = Puppet.lookup(:environments).get!(Puppet[:environment]) end @environment diff --git a/lib/puppet/parser/type_loader.rb b/lib/puppet/parser/type_loader.rb index 1357f948d..2f6c77257 100644 --- a/lib/puppet/parser/type_loader.rb +++ b/lib/puppet/parser/type_loader.rb @@ -55,7 +55,7 @@ class Puppet::Parser::TypeLoader def environment=(env) if env.is_a?(String) or env.is_a?(Symbol) - @environment = Puppet.lookup(:environments).get(env) + @environment = Puppet.lookup(:environments).get!(env) else @environment = env end diff --git a/lib/puppet/util/autoload.rb b/lib/puppet/util/autoload.rb index 51ff94e1c..ddc62734c 100644 --- a/lib/puppet/util/autoload.rb +++ b/lib/puppet/util/autoload.rb @@ -128,7 +128,7 @@ class Puppet::Util::Autoload # "app_defaults_initialized?" method on the main puppet Settings object. # --cprice 2012-03-16 if Puppet.settings.app_defaults_initialized? && - env ||= Puppet.lookup(:environments).get(Puppet[:environment]) + env ||= Puppet.lookup(:environments).get!(Puppet[:environment]) # if the app defaults have been initialized then it should be safe to access the module path setting. $env_module_directories[env] ||= env.modulepath.collect do |dir| |