summaryrefslogtreecommitdiffstats
path: root/lib/puppet/application.rb
diff options
context:
space:
mode:
authorMax Martin <max@puppetlabs.com>2011-04-13 17:30:44 -0700
committerMax Martin <max@puppetlabs.com>2011-04-13 17:30:44 -0700
commit3dde838ac992571e13262ea29ba3a0eb8152e753 (patch)
tree90520cf62bfa2f1bb9c992bbfe1bc47ae10471f2 /lib/puppet/application.rb
parentfe45c2417af580597cd39adec96a30a05a7cd66a (diff)
parent3ab44c7ce01ab86a995deb66228f5be95239c92a (diff)
Merge branch 'next'
* next: (204 commits) Revert "(#6928) Removed --ignoreimport" Updated CHANGELOG for 2.6.8rc1 (#6928) Removed --ignoreimport (#6928) Remove --parseonly (#6928) Add a Parser face with Validate action (#6830) Fix sha1 to digest/sha1 require issue for Ruby 1.9 (#6830) Fix UTF-8 encoding issue for Ruby 1.9 (#6830) Fix string method sub call on a symbol for Ruby 1.9 (#2331) Remove darwinports pkg provider, replace with rewritten macports provider (#7059) handle inherited action binding scope maint: ensure we handle '-foo=' options correctly in faces. (#2150) Fix File const lookup when configuring routes Fixed #7082 - Added system support for groups maint: install erb templates under lib/ maint: clean up the spec test headers in bulk. (#7056) Use 'face' rather than 'faces' in the production code. maint: eliminate deprecated since 2008 code from Puppet. (#6117) Add POST support to indirector requests (#6962) Move option handling into #parse_options, not #preinit. maint: whitespace cleanup for puppet/util/command_line. ...
Diffstat (limited to 'lib/puppet/application.rb')
-rw-r--r--lib/puppet/application.rb34
1 files changed, 20 insertions, 14 deletions
diff --git a/lib/puppet/application.rb b/lib/puppet/application.rb
index 57bd88877..374dc850b 100644
--- a/lib/puppet/application.rb
+++ b/lib/puppet/application.rb
@@ -299,11 +299,12 @@ class Application
# This is the main application entry point
def run
- exit_on_fail("initialize") { hook('preinit') { preinit } }
- exit_on_fail("parse options") { hook('parse_options') { parse_options } }
- exit_on_fail("parse configuration file") { Puppet.settings.parse } if should_parse_config?
- exit_on_fail("prepare for execution") { hook('setup') { setup } }
- exit_on_fail("run") { hook('run_command') { run_command } }
+ exit_on_fail("initialize") { hook('preinit') { preinit } }
+ exit_on_fail("parse options") { hook('parse_options') { parse_options } }
+ exit_on_fail("parse configuration file") { Puppet.settings.parse } if should_parse_config?
+ exit_on_fail("prepare for execution") { hook('setup') { setup } }
+ exit_on_fail("configure routes from #{Puppet[:route_file]}") { configure_indirector_routes }
+ exit_on_fail("run") { hook('run_command') { run_command } }
end
def main
@@ -328,6 +329,15 @@ class Application
Puppet::Util::Log.newdestination(:syslog) unless options[:setdest]
end
+ def configure_indirector_routes
+ route_file = Puppet[:route_file]
+ if ::File.exists?(route_file)
+ routes = YAML.load_file(route_file)
+ application_routes = routes[name.to_s]
+ Puppet::Indirector.configure_routes(application_routes) if application_routes
+ end
+ end
+
def parse_options
# Create an option parser
option_parser = OptionParser.new(self.class.banner)
@@ -349,14 +359,10 @@ class Application
end
end
- # scan command line.
- begin
- option_parser.parse!(self.command_line.args)
- rescue OptionParser::ParseError => detail
- $stderr.puts detail
- $stderr.puts "Try 'puppet #{command_line.subcommand_name} --help'"
- exit(1)
- end
+ # Scan command line. We just hand any exceptions to our upper levels,
+ # rather than printing help and exiting, so that we can meaningfully
+ # respond with context-sensitive help if we want to. --daniel 2011-04-12
+ option_parser.parse!(self.command_line.args)
end
def handlearg(opt, arg)
@@ -394,7 +400,7 @@ class Application
def exit_on_fail(message, code = 1)
yield
- rescue RuntimeError, NotImplementedError => detail
+ rescue ArgumentError, RuntimeError, NotImplementedError => detail
puts detail.backtrace if Puppet[:trace]
$stderr.puts "Could not #{message}: #{detail}"
exit(code)