diff options
author | Max Martin <max@puppetlabs.com> | 2011-04-07 12:22:30 -0700 |
---|---|---|
committer | Max Martin <max@puppetlabs.com> | 2011-04-07 12:22:30 -0700 |
commit | fe45c2417af580597cd39adec96a30a05a7cd66a (patch) | |
tree | 38191b4766c8e2354c27c0868c12e0e254b4389f /lib/puppet/application.rb | |
parent | 9c06fbd762cddcc41a7185a36f2a8e72879125eb (diff) | |
parent | 20bff91c8b8e450d913deeb1750a00a14f1b1061 (diff) | |
download | puppet-fe45c2417af580597cd39adec96a30a05a7cd66a.tar.gz puppet-fe45c2417af580597cd39adec96a30a05a7cd66a.tar.xz puppet-fe45c2417af580597cd39adec96a30a05a7cd66a.zip |
Merge branch 'next'
* next: (23 commits)
(maint) Indentation fixes
(#6490) Add plugin initialization callback system to core
(Maint) Fix uninitialized constant.
(5200) -- replace containers with sentinals
(#5528) Add REST API for signing, revoking, retrieving, cleaning certs
Fix #4339 - Locally save the last report to $lastrunreport
Fix #4339 - Save a last run report summary to $statedir/last_run_summary.yaml
Fixed #3127 - removed legacy debug code
Fixed #3127 - Fixed gem selection regex
(6911) Cleanup and renaming of transaction internals
(6911) Core change -- replace topsort with frontier ordered by salted SHA1
(6911) Add bookkeeping facade around Transaction#relationship_graph
(#5437) Invalidate cached TypeCollection when there was an error parsing
(#6937) Adjust formatting of recurse's desc
(#6937) Document the recurse parameter of File type.
(#6937) Document the recurse parameter of File type.
(6911) Cleanup of generate_additional_resources
(6911) Refactor to localize eval_generate dependency assumptions
(#6893) Document the cron type in the case of specials.
(maint) Fix for require order issue
...
Diffstat (limited to 'lib/puppet/application.rb')
-rw-r--r-- | lib/puppet/application.rb | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/lib/puppet/application.rb b/lib/puppet/application.rb index 7ef71bc81..57bd88877 100644 --- a/lib/puppet/application.rb +++ b/lib/puppet/application.rb @@ -1,4 +1,5 @@ require 'optparse' +require 'puppet/util/plugins' # This class handles all the aspects of a Puppet application/executable # * setting up options @@ -298,11 +299,11 @@ class Application # This is the main application entry point def run - exit_on_fail("initialize") { preinit } - exit_on_fail("parse options") { parse_options } + 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") { setup } - exit_on_fail("run") { run_command } + exit_on_fail("prepare for execution") { hook('setup') { setup } } + exit_on_fail("run") { hook('run_command') { run_command } } end def main @@ -392,11 +393,18 @@ class Application private def exit_on_fail(message, code = 1) - yield + yield rescue RuntimeError, NotImplementedError => detail - puts detail.backtrace if Puppet[:trace] - $stderr.puts "Could not #{message}: #{detail}" - exit(code) + puts detail.backtrace if Puppet[:trace] + $stderr.puts "Could not #{message}: #{detail}" + exit(code) + end + + def hook(step,&block) + Puppet::Plugins.send("before_application_#{step}",:application_object => self) + x = yield + Puppet::Plugins.send("after_application_#{step}",:application_object => self, :return_value => x) + x end end end |