From 4ff5769119aefafa33e05449ebcfac78ba0c0fe0 Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Thu, 3 Feb 2011 15:36:50 -0800 Subject: (#5823) run mode can now be set dynamically... Third party scripts, and complex command line tools, depend on being able to configure the run_mode value at runtime, not just when they fire up. For better or worse we used to allow this sort of thing to work, but stopped, and we have no sane, safe and consensual alternative, so we broke a bunch of client code. This enables the feature again, but does not add any safety catch; you can now happily slice off your own feet with this, if you really want to. --- lib/puppet/application.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lib/puppet/application.rb') diff --git a/lib/puppet/application.rb b/lib/puppet/application.rb index 17ad69cee..b944a554e 100644 --- a/lib/puppet/application.rb +++ b/lib/puppet/application.rb @@ -264,9 +264,14 @@ class Application def initialize(command_line = nil) require 'puppet/util/command_line' @command_line = command_line || Puppet::Util::CommandLine.new - @run_mode = self.class.run_mode + set_run_mode self.class.run_mode @options = {} + require 'puppet' + end + + def set_run_mode(mode) + @run_mode = mode $puppet_application_mode = @run_mode $puppet_application_name = name @@ -281,8 +286,6 @@ class Application Puppet.settings.set_value(:rundir, Puppet.run_mode.run_dir, :mutable_defaults) Puppet.settings.set_value(:run_mode, Puppet.run_mode.name.to_s, :mutable_defaults) end - - require 'puppet' end # This is the main application entry point -- cgit From 04ea8269e70e9c1f81394ac6da2b48dcfb49b1d5 Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Thu, 3 Feb 2011 16:19:03 -0800 Subject: (#5823) document the not-an-API status of set_run_mode Since this is totally not API, document that in big, threatening letters so that folks actually know what is going on. Include promises so they don't feel too unhappy with us. Paired-with: matt@puppetlabs.com --- lib/puppet/application.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/puppet/application.rb') diff --git a/lib/puppet/application.rb b/lib/puppet/application.rb index b944a554e..c3d7355f6 100644 --- a/lib/puppet/application.rb +++ b/lib/puppet/application.rb @@ -270,6 +270,13 @@ class Application require 'puppet' end + # WARNING: This is a totally scary, frightening, and nasty internal API. We + # strongly advise that you do not use this, and if you insist, we will + # politely allow you to keep both pieces of your broken code. + # + # We plan to provide a supported, long-term API to deliver this in a way + # that you can use. Please make sure that you let us know if you do require + # this, and this message is still present in the code. --daniel 2011-02-03 def set_run_mode(mode) @run_mode = mode $puppet_application_mode = @run_mode -- cgit